Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging linter rules #116

Merged
merged 11 commits into from
Jul 27, 2023
Merged

Debugging linter rules #116

merged 11 commits into from
Jul 27, 2023

Conversation

awnawab
Copy link
Contributor

@awnawab awnawab commented Jul 12, 2023

This PR adds the following two linter rules:

  • ArgSizeMismatchRule: check for size discrepancies between arguments and dummy arguments
  • DynamicUboundCheckRule: check for dynamic UBOUND checks for assumed-shape dummy arguments

Other changes include:

  • Extension of GenericRule.check and GenericRule.check_subroutine API to allow optional passing of scheduler targets
  • Move some of the boilerplate in lint_rules/tests to conftest.py

@github-actions
Copy link

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/116/index.html

@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Merging #116 (cb73473) into main (45e51fd) will increase coverage by 0.03%.
The diff coverage is 95.42%.

@@            Coverage Diff             @@
##             main     #116      +/-   ##
==========================================
+ Coverage   92.12%   92.15%   +0.03%     
==========================================
  Files          89       90       +1     
  Lines       16494    16650     +156     
==========================================
+ Hits        15195    15344     +149     
- Misses       1299     1306       +7     
Flag Coverage Δ
lint_rules 95.96% <95.00%> (-0.71%) ⬇️
loki 92.09% <100.00%> (+<0.01%) ⬆️
transformations 91.78% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
lint_rules/lint_rules/debug_rules.py 94.70% <94.70%> (ø)
lint_rules/lint_rules/ifs_coding_standards_2011.py 97.35% <100.00%> (ø)
loki/lint/linter.py 96.20% <100.00%> (ø)
loki/lint/rules.py 98.57% <100.00%> (+0.10%) ⬆️

... and 1 file with indirect coverage changes

Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic! Thanks so much and a perfect start to what I imagine could grow into a quite handy collection of similar utilities.

My main request would be to document this in the loki-lint documentation: https://github.com/ecmwf-ifs/loki/blob/main/docs/source/loki_lint.rst

Otherwise a few comments and questions but nothing that would stop this from going in.

"""

# first resolve associates
resolve_associates(subroutine)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[no action required] Just a thought on design: We should probably expose somehow whether a linter rule is changing the IR (and, optionally, call these rules with a cloned IR to ensure rules applied subsequently in the same linter pass get to see the original IR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, great idea!

lint_rules/lint_rules/debug_rules.py Outdated Show resolved Hide resolved
lint_rules/lint_rules/debug_rules.py Outdated Show resolved Hide resolved
lint_rules/tests/conftest.py Outdated Show resolved Hide resolved
loki/bulk/scheduler.py Outdated Show resolved Hide resolved
@awnawab awnawab force-pushed the naan-debug-linter-rules branch 3 times, most recently from fe8f704 to 366889d Compare July 19, 2023 17:00
Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, very happy with this now.

continue

arg_map = {carg: rarg for rarg, carg in call.arg_iter()}
for arg in arg_map:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could even go further and use for carg, rarg in arg_map.items() to save the arg_map[arg] lookups in the loop body. But mentioning this only for educational purposes.

@reuterbal reuterbal merged commit f85297e into main Jul 27, 2023
11 checks passed
@reuterbal reuterbal deleted the naan-debug-linter-rules branch July 27, 2023 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants