Sha256: eb8564f86befbf882ab14d16849a032bc28fbe49dc3cd07e951a4537d00dbe82
Contents?: true
Size: 1.12 KB
Versions: 10
Compression:
Stored size: 1.12 KB
Contents
# Utility Function ## Introduction A _Utility Function_ is any instance method that has no dependency on the state of the instance. _Utility Function_ is heavily related to _[Feature Envy](Feature-Envy.md)_, please check out the explanation there why _Utility Function_ is something you should care about. ## Example Given ```Ruby class UtilityFunction def showcase(argument) argument.to_s + argument.to_i end end ``` `reek` would report: ``` test.rb -- 2 warnings: [2]:UtilityFunction#showcase doesn't depend on instance state (UtilityFunction) ``` ## Current Support in reek _Utility Function_ will warn about any method that: * is non-empty * does not override an inherited method * calls at least one method on another object * doesn't use any of self's instance variables * doesn't use any of self's methods ## Differences to _Feature Envy_ _[Feature Envy](Feature-Envy.md)_ is only triggered if there are some references to self and _Utility Function_ is triggered if there are no references to self. ## Configuration `reek`'s _Utility Function_ detector supports the [Basic Smell Options](Basic-Smell-Options.md).
Version data entries
10 entries across 10 versions & 1 rubygems