disable inline or per method reek code smell detector

1.6k Views Asked by At

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

1

There are 1 best solutions below

1
On BEST ANSWER

https://github.com/troessner/reek/blob/master/docs/Smell-Suppression.md#how-to-disable-smell-detection

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.