struct Ameba::Rule::Lint::ShadowedArgument
- Ameba::Rule::Lint::ShadowedArgument
- Ameba::Rule::Base
- Struct
- Value
- Object
Overview
A rule that disallows shadowed arguments.
For example, this is considered invalid:
do_something do |foo|
foo = 1 # shadows block argument
foo
end
def do_something(foo)
foo = 1 # shadows method argument
foo
end
and it should be written as follows:
do_something do |foo|
foo = foo + 42
foo
end
def do_something(foo)
foo = foo + 42
foo
end
YAML configuration example:
Lint/ShadowedArgument:
Enabled: true
Defined in:
ameba/rule/lint/shadowed_argument.crConstant Summary
-
MSG =
"Argument `%s` is assigned before it is used"
Constructors
-
.new(config = nil)
A rule that disallows shadowed arguments.
Instance Method Summary
Instance methods inherited from struct Ameba::Rule::Base
==(other)
==,
catch(source : Source)
catch,
excluded?(source)
excluded?,
group
group,
hash
hash,
initialize
initialize,
name
name,
special?
special?,
test(source : Source, node : Crystal::ASTNode, *opts)test(source : Source) test
Constructor methods inherited from struct Ameba::Rule::Base
new
new
Class methods inherited from struct Ameba::Rule::Base
parsed_doc
parsed_doc
Constructor Detail
def self.new(config = nil)
#
A rule that disallows shadowed arguments.
For example, this is considered invalid:
do_something do |foo|
foo = 1 # shadows block argument
foo
end
def do_something(foo)
foo = 1 # shadows method argument
foo
end
and it should be written as follows:
do_something do |foo|
foo = foo + 42
foo
end
def do_something(foo)
foo = foo + 42
foo
end
YAML configuration example:
Lint/ShadowedArgument:
Enabled: true