AtomLinter / linter-reek

An Atom Linter package for Reek, the Ruby code smell detector.
https://atom.io/packages/linter-reek
MIT License
7 stars 5 forks source link

Linter changes working directory, breaking config rules #149

Open arielj opened 3 years ago

arielj commented 3 years ago

Reek configuration allows us to configure reek depending on the files' directory. They suggest for example this config for projects using Rails https://github.com/troessner/reek#working-with-rails

directories:
  "app/controllers":
    IrresponsibleModule:
      enabled: false
    NestedIterators:
      max_allowed_nesting: 2
    UnusedPrivateMethod:
      enabled: false
    InstanceVariableAssumption:
      enabled: false

This is not working because the linter is changing the working directory for the reek command to the current file's directory instead of the root of the project here https://github.com/AtomLinter/linter-reek/blob/master/lib/linter-reek.js#L116

        const execOpts = {
          cwd: path.dirname(filePath),
          ignoreExitCode: true,
        };

Changing that to:

        const execOpts = {
          cwd: atom.project.getPaths()[0],
          ignoreExitCode: true,
        };

fixes the issue (setting the working directory as the root of the project.

I can create a PR, but I'm not sure if that there's for a specific reason.