Skip to content

directories in config relative to cwd, not to configuration file itself. #1486

@leonelgalan

Description

@leonelgalan

Setup

Rails app, where helpers smell of UtilityFunction

.reek.yml

directories:
  "app/helpers":
    UtilityFunction:
      enabled: false

app/helpers/foo_helper.rb

module FooHelper
  def smelly_method(bar)
    bar.presence
  end
end

Happy Path

reek --show-configuration-path app/helpers/foo_helper.rb
Using '.reek.yml' as configuration file.
Inspecting 1 file(s):
.

Possible Bug

When linting through atom-linter, the current working directory (cwd) is set to the one the file being linted exists, in this case: app/helpers. Reek will still find the correct .reek.yml from it's ancestors, first in app and ultimately on the project's root. But, it won't match the directory "app/helpers", because it's looking for "app/helpers" relative to the cwd instead of relative to the configuration file.

cd app/helpers
reek --show-configuration-path foo_helper.rb
Using '../../.reek.yml' as configuration file.
Inspecting 1 file(s):
S

foo_helper.rb -- 1 warning:
  [5]:UtilityFunction: FooHelper#smelly_method doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/v5.4.0/docs/Utility-Function.md]

I'm on reek 5.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions