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

diagnostics ignoring .rubocop.yml excludes #155

Closed
Zhorian opened this issue Jan 10, 2020 · 2 comments
Closed

diagnostics ignoring .rubocop.yml excludes #155

Zhorian opened this issue Jan 10, 2020 · 2 comments

Comments

@Zhorian
Copy link

Zhorian commented Jan 10, 2020

When using rubocop diagnostics I expect it to utilise the .rubocop.yml config at the root of my project, this doesn't seem to be the case as I'm getting errors on a file I've excluded. The yml file is picked up if I run rubocop from the command line. The same issue seems to be happening with vscode-ruby.

image

settings.json
{ "editor.formatOnSave": true, "editor.formatOnSaveTimeout": 5000, "emmet.includeLanguages": { "html.erb": "html", "erb": "html" }, "powermode.enabled": true, "powermode.enableShake": false, "ruby.useLanguageServer": true, // "ruby.lint": { // "rubocop": { // "useBundler": true // } // }, "ruby.format": "rubocop", "ruby.useBundler": true, "solargraph.diagnostics": true, "workbench.colorTheme": "Blueberry Banana", "workbench.iconTheme": "vscode-icons", "git.enableSmartCommit": true, "git.confirmSync": false, "files.autoSave": "afterDelay" }

.rubocop.yml
AllCops: TargetRubyVersion: 2.6.5 Exclude: - "**/*.erb" - db/schema.rb - "bin/**/*" - "node_modules/**/*" - test/test_helper.rb - test/channels/application_cable/connection_test.rb

.solargraph.yml
AllCops: TargetRubyVersion: 2.6.5 Exclude: - "**/*.erb" - db/schema.rb - "bin/**/*" - "node_modules/**/*" - test/test_helper.rb - test/channels/application_cable/connection_test.rb

@castwide
Copy link
Owner

The way RuboCop handles excluded_files is a little confusing. When you run RuboCop on a directory, it uses the configuration. When you run it on a specific file, it assumes that you want a report regardless of whether the file is excluded. Solargraph runs RuboCop on the file when you open it in an editor, so you get the latter behavior.

It's hard to say which option is correct. Some users might want to see diagnostics while they're in the process of editing an excluded file, even if it won't appear in directory reports. Others might not.

The current workaround is to add a .rubocop file with the following:

---force-exclusion

@Zhorian
Copy link
Author

Zhorian commented Jan 12, 2020

Thanks that worked except I think you may have added an extra dash?

--force-exclusion worked for me!

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

2 participants