diff --git a/src/ameba/ast/scope.cr b/src/ameba/ast/scope.cr index 5f082d38..729176a9 100644 --- a/src/ameba/ast/scope.cr +++ b/src/ameba/ast/scope.cr @@ -90,8 +90,9 @@ module Ameba::AST # false if not. def references?(variable : Variable) variable.references.any? do |reference| - reference.scope == self || inner_scopes.any?(&.references? variable) - end + reference.scope == self || + inner_scopes.any?(&.references? variable) + end || variable.used_in_macro? end # Returns true if current scope is a def, false if not. diff --git a/src/ameba/rule/lint/unused_argument.cr b/src/ameba/rule/lint/unused_argument.cr index d4d9a1b9..6abadca8 100644 --- a/src/ameba/rule/lint/unused_argument.cr +++ b/src/ameba/rule/lint/unused_argument.cr @@ -55,7 +55,7 @@ module Ameba::Rule::Lint private def find_unused_arguments(source, scope) scope.arguments.each do |argument| - next if argument.ignored? || scope.references?(argument.variable) || argument.variable.used_in_macro? + next if argument.ignored? || scope.references?(argument.variable) name_suggestion = scope.node.is_a?(Crystal::Block) ? '_' : "_#{argument.name}" issue_for argument.node, MSG % {argument.name, name_suggestion}