SublimeLinter / SublimeLinter-rubocop

SublimeLinter 3 plugin for Ruby, using rubocop.
MIT License
159 stars 40 forks source link

File exclusion doesn't work #20

Closed maksimf closed 8 years ago

maksimf commented 9 years ago

I have .rubocop.yml:

AllCops:
  RunRailsCops: true
  Exclude:
    - db/schema.rb
Documentation:
  Enabled: false
Metrics/MethodLength:
  Max: 20

And so I expect linter to ignore db/schema.rb which it doesn't. I asked guys from rubocop and they told me that I need to specify --force-exclusion flag to make linter work, which i did in my SublimeLinter.sublime-settings:

"linters": {
    "rubocop": {
        "@disable": false,
        "args": [
            "--force-exclusion"
        ],
        "excludes": []
    }
}

But this doesn't work. I ran linter in debug mode and figured out that it uses the following command: /usr/local/opt/rbenv/shims/ruby -S rubocop --force-exclusion --config=/Users/m.filippov/myproject/.rubocop.yml db/schema.rb And when I run this command in console manually, then everything works just fine, schema.rb is skipped. Do you have any idea what can be wrong?

reconbot commented 9 years ago

We lose the directory part of the file's path when we send it to rubocop. SublimeLinter does this to support unsaved files. I've been exploring a patch to use in our linter to recreate the directories in tmp for the very related #10 about railscops.

maksimf commented 9 years ago

Should this config work then?

AllCops:
  RunRailsCops: true
  Exclude:
    - schema.rb
Documentation:
  Enabled: false
Metrics/MethodLength:
  Max: 20
reconbot commented 9 years ago

I think, but only in the linter. If you run rubocop from the command line (or in a CI server) it might not match.

reconbot commented 9 years ago

And due to #10 the rails cops wont work yet.

rafaelcgo commented 9 years ago

I'm having the same issue.

I even tried to specify the filename usign - '*_spec.rb' with no luck.

# Removing BlockDelimiters Cop for RSpec
Style/BlockDelimiters:
  Exclude:
    - 'spec/**/*'
    - '*_spec.rb'