Skip to content

Instantly share code, notes, and snippets.

@cobbr2
Created April 18, 2017 20:14
Show Gist options
  • Save cobbr2/8ba8523fea3a9c08811211a608a60ab6 to your computer and use it in GitHub Desktop.
Save cobbr2/8ba8523fea3a9c08811211a608a60ab6 to your computer and use it in GitHub Desktop.
4 reek UtilityFunction cases; only one should smell
# Test case for disabling utility function smells. Should smell like
# UtilityFunction
class NoSuppression
def utility_function
STDOUT.puts "I'm a utility function"
end
end
# Should suppress utility function smell; in my real code, does work.
class SuppressInPrivateSection
private
# :reek:UtilityFunction
def utility_function
STDOUT.puts "I'm a utility function"
end
end
# Should suppress disable utility function smell; does not for me.
class SuppressOnPrivateDef
# :reek:UtilityFunction
private def utility_function
STDOUT.puts "I'm a utility function"
end
end
# Should disable utility function smell; works
class SuppressOnPublicMethod
# :reek:UtilityFunction
def utility_function
STDOUT.puts "I'm a utility function"
end
end
$ reek *
Inspecting 4 file(s):
S.S.
no_suppression.rb -- 1 warning:
[4]:UtilityFunction: NoSuppression#utility_function doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
suppress_on_private_def.rb -- 1 warning:
[4]:UtilityFunction: SuppressOnPrivateDef#utility_function doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
2 total warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment