Reputation: 2800
Is there a way to disable warning from reek
gem per method, per line or per block?
What we have for rubocop
for example
# suppress warning Use snake_case for method names
def fooBar(baz) # rubocop:disable Naming/MethodName
baz
end
this example will suppress warnings for rubocop, I'm looking something similar for reek
tool.
def foo(bar) # reek:disable TooManyStatements
baz = bar + bar
# other line
# more line
# that produce reek warning
baz
end
In documentation I found that it is configurable only by config file, but that's not what I'm looking for
Upvotes: 3
Views: 1991
Reputation: 86
There are always the Basic Smell Options you can use in your configuration file. But in this document we would like to focus on a completely different way - via special comments.
A simple example:
# This method smells of :reek:NestedIterators
def smelly_method(foo)
foo.each { |bar| bar.each { |baz| baz.qux } }
end
The method smelly_method will not be reported. The general pattern is to put the string
:reek:
, followed by the smell class, in a comment before the method or class.
Upvotes: 7