Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible false positive on UtilityFunction #1587

Closed
guillermoap opened this issue Feb 14, 2021 · 3 comments
Closed

Possible false positive on UtilityFunction #1587

guillermoap opened this issue Feb 14, 2021 · 3 comments

Comments

@guillermoap
Copy link

Hello,

The method process_file is triggering the UtilityFunction.
This is a helper module, why is it complaining about it not depending on the instance state?

module RepositoryHelper
  CLONE_PATH = Rails.root.join('tmp').to_s
  LOGGER = Rails.logger
  
  ...
  
  def process_file(path, pattern_name, sub_options = [])
    IO.write(path, File.open(path) { |file| file.read.gsub(*sub_options) })
    LOGGER.info("Substituted #{pattern_name} in #{path}")
  end
end
@troessner
Copy link
Owner

troessner commented Feb 16, 2021

Yeah, that was a design decision we took a loooong time ago and it surely was a controversial one ;)
In short, we consider helper modules smelly by definition, hence Reek raises an alert. For more details see here.

You can either disable raising an alert for these methods via magic comment or if you want to disable it for that whole file tweak your Reek configuration like detailed here, e.g. in your case by adding

---
detectors:
  UtilityFunction:
    exclude:
      - "RepositoryHelper#process_file" 

@mvz
Copy link
Collaborator

mvz commented Feb 16, 2021

Also see https://github.com/troessner/reek#working-with-rails

@guillermoap
Copy link
Author

Didn't know that, thanks for the suggestion. I ended up disabling it.

Thanks for the help. Closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants