Every repository with this icon (
Every repository with this icon (
Feature Envy
Feature Envy occurs when a code fragment references another object more often than it references itself, or when several clients do the same series of manipulations on a particular type of object.
A simple example would be the following method, which “belongs” on the Item class and not on the Cart class:
class Cart
def price
@item.price + @item.tax
end
end
Feature Envy reduces the code’s ability to communicate intent: code that “belongs” on one class but which is located in another can be hard to find, and may upset the “System of Names” in the host class.
Feature Envy also affects the design’s flexibility: A code fragment that is in the wrong class creates couplings that may not be natural within the application’s domain, and creates a loss of cohesion in the unwilling host class.
Current Support in Reek
Currently Feature Envy reports any method that refers to self less often than it refers to (ie. send messages to) some other object.
Configuration
Feature Envy supports only the Basic Smell Options. The file config/defaults.reek (shipped with the Reek gem) lists the default configuration settings for this smell.







