Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Add Stdin-filename arg to Reek linter #575

Merged
merged 1 commit into from
Feb 23, 2020
Merged

Add Stdin-filename arg to Reek linter #575

merged 1 commit into from
Feb 23, 2020

Conversation

guzart
Copy link
Contributor

@guzart guzart commented Dec 24, 2019

Passes an --stdin-filename argument to Reek when linting files.

This gives Reek context about the piped contents and supports using the directories configuration.

Caveat:
Because this change sends the absolute path to the file, the configuration in directories must be prefixed with ** for it to work. e.g.

directories:
  '**/app/controllers':
    IrresponsibleModule:
      enabled: false

Passes an `--stdin-filename` argument to Reek when linting files.

This gives Reek context about the piped contents and supports using the [`directories` configuration](/~https://github.com/troessner/reek#working-with-rails).

Caveat:
Because this change sends the absolute path to the file, the configuration in directories must be prefixed with `**` for it to work. e.g.
```yml
directories:
  '**/app/controllers':
    IrresponsibleModule:
      enabled: false
```
@minkir014
Copy link

When this PR will be merged???

@wingrunr21 wingrunr21 merged commit f672675 into rubyide:master Feb 23, 2020
@leonelgalan
Copy link

leonelgalan commented May 1, 2022

Caveat:
Because this change sends the absolute path to the file, the configuration in directories must be prefixed with ** for it to work. e.g.

Because of this change and before I add the ** the linter from the extension will show smells that won't show when I run:

bundle exec reek folder/file.rb

If I prefix directories with ** as suggested, the smells don't show on vscode-ruby, but show up when I run reek on it's own, or through CodeClimate.

Possible Solution

For future readers, configuring the directory directive as shown, seems to work with both the reek command line tool and vscode-ruby:

directories:
  "folder|**/folder":
    UtilityFunction:
      enabled: false

It's not ideal to have to repeat the folder name twice, but at least this allows both tools to use the same configuration. My own caveat: the documentation and and the tests say a Dir.glob (like) pattern can be used, but ultimately a Regex is used, which is why | appears to work.

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

Successfully merging this pull request may close these issues.

4 participants