I'm learning Rails course by Michael Hartl, on chapter 4, I have function full_title as following:
app/helpers/application_helper.rb
module ApplicationHelper
def full_title page_title = ""
base_title = t "app_name"
page_title.empty? ? base_title : page_title + " | " + base_title
end
end
Runing reek (a code review tool), I got a warning:
app/helpers/application_helper.rb -- 1 warning:
[4, 4]:FeatureEnvy: ApplicationHelper#full_title refers to 'page_title' more than self (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Feature-Envy.md]
So what is FeatureEnvy and how to fix it in this case?
The documentation of reek explains feature envy as follows:
In this particular case, I believe this issue can be ignored. It is natural for helper methods to take arguments and operate on those, instead of referencing
self
, which is the view object in this case.How to exclude helpers from reek's analysis:
You should be able to exclude all helpers from being checked for compliance with the "feature envy" rule by adding this to the config.reek file: