Skip to content

Commit

Permalink
ArgSizeMismatchRule: targets now retrieved in GenericRule.check
Browse files Browse the repository at this point in the history
  • Loading branch information
awnawab committed Jul 20, 2023
1 parent 2fe20c5 commit cb73473
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions loki/bulk/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,7 @@ def process(self, transformation, reverse=False, item_filter=SubroutineItem, use
if use_file_graph:
for node in traversal:
items = graph.nodes[node]['items']
transformation.apply(items[0].source, item=items[0], items=items,
targets=items[0].targets)
transformation.apply(items[0].source, item=items[0], items=items)
else:
for item in traversal:
if item_filter and not isinstance(item, item_filter):
Expand Down
8 changes: 7 additions & 1 deletion loki/lint/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def check(cls, ast, rule_report, config, **kwargs):
The rule configuration, filled with externally provided
configuration values or the rule's default configuration.
"""

# Perform checks on source file level
if isinstance(ast, Sourcefile):
cls.check_file(ast, rule_report, config)
Expand Down Expand Up @@ -161,7 +162,12 @@ def check(cls, ast, rule_report, config, **kwargs):
if is_rule_disabled(ast.ir, cls.identifiers()):
return

cls.check_subroutine(ast, rule_report, config, **kwargs)
if not (targets := kwargs.pop('targets', None)):
items = kwargs.get('items', ())
item = [item for item in items if item.local_name.lower() == ast.name.lower()]
if len(item) > 0:
targets = item[0].targets
cls.check_subroutine(ast, rule_report, config, targets=targets, **kwargs)

# Recurse for any procedures contained in a subroutine
if hasattr(ast, 'members') and ast.members is not None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lint/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class AlwaysComplainRule(GenericRule):
docs = {'id': '13.37'}

@classmethod
def check_file(cls, sourcefile, rule_report, config): # pylint: disable=unused-argument
def check_file(cls, sourcefile, rule_report, config, **kwargs): # pylint: disable=unused-argument
rule_report.add(cls.__name__, sourcefile)

check_module = check_file
Expand Down

0 comments on commit cb73473

Please sign in to comment.