You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Is this still an issue for you with the latest version of the extension? Some changes were introduced in how Rubocop is run in v0.16.0 so wondering if that fixed it.
I just ran Rubocop on a single file, and it respected exclusions.
Specifically, certain rules by default in Rubocop, don't apply to files in specs and test folders, yet in this extension, they still run. Like Metrics/ClassLength.
Things like Metrics/ClassLength are applied when they shouldn't be. Presumably because rubocop isn't getting enough context when linting. Haven't investigated yet.
Files that are listed under Exclude still get linted (like db/schema.rb). I bet adding --force-exclusion will solve this problem.
@garyking what's your rubocop config for this extension look like? Both of those issues basically mean Rubocop is either not finding the .rubocop.yml or is ignoring the settings. I'm wondering if one of the extension settings is activating a CLI option that causes things to be ignored.
Back in my workspace, in the file test/test_file.rb, if I run Rubocop on the file from Terminal, then I get no errors. But in VSC, this ext gives me the Metrics/ClassLength error, indicating that Exclude is not inherited. But the Max value definitely is, because it says 205/150.
I had the same problem but noticed that when it was run in Visual Studio, Rubocop wasn't referencing the same root directory as my project. So I tried making the exclusion root-independent and it then worked fine:
@peternixey I tried your solution and works in vs code but then it does not work in the command line. When I tried to run in the terminal bundle exec rubocop I got an error like the following:
/path/to/your/project/.rubocop.yml): did not find expected alphabetic or numeric character while scanning an alias at line 5 column 7
/path/to/your/home/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych.rb:456:in `parse'/path/to/your/home/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych.rb:456:in `parse_stream'/path/to/your/home/.rbenv/versions/2.7.1/lib/ruby/2.7.0/psych.rb:390:in `parse'...
This helps while developing with VS code but if you have rubocop integrated in your deployment pipeline it is not a final solution.
@heragu - it actually doesn’t even work in Vscode any more for me. I find anything to do with Ruby (solargraph etc too) a bit of a black art to get working!
The "forceExclusion": true solution does not work for me. What's the status of this bug? Is anyone working on it?
Reacted by Sam-Wilkinson, Ryan Hageman, Evgenii Neumerzhitckii, Roger Peixoto , Kenta Katsumata, Soumya Ray, Márcio Martins, Rigo and Laura Murphy-Clarkin
This behavior is really strange. I created experiment project: https://github.com/shrkw/vscode-ruby-dev-env-sample , and rubocop and "Exclude" settings works very well yesterday.
I opened it today, "Exclude" settings does not work at all!
Debug Output view for "Ruby Language Server" shows rubocop has correct option...
Since this is an old issue with lots of comments, it's possible there are multiple bugs being represented here. However, I strongly suspect this issue is a duplicate of #578 and #719, and is fixed by PR #720. However, the fix hasn't made it into a release yet.
Since this is an old issue with lots of comments, it's possible there are multiple bugs being represented here. However, I strongly suspect this issue is a duplicate of #578 and #719, and is fixed by PR #720. However, the fix hasn't made it into a release yet.
@benzado if I am not mistaken PR #720 fixes only language-server-ruby/src/linters/ and this issue is related to language-server-ruby/src/formatters/ (which has exactly the same issue -- extra single quotes). I created PR #825 and appreciate it if you can review it.
Even if PR #825 gets merged and doesn't work, we're no worse off than we are right now with 0.28.1. Could #641 even be reproduced at this point, given the 78 (I counted) releases rubocop has had since August 01, 2020?
Rather than dealing with the fallout of that commit for 2 more years, can PR #647 just be reverted until it can be shown that there actually is a problem in the first place?
#840 (which could supersede #825 - although @senhalil should feel free to merge this and let things continue over there) finishes reverting all of the changes from #647, which hadn't already been reverted elsewhere.
You should really also document the pattern syntax. Whether it's a Dir.glob or fnmatch, or shell glob, explicitly state so. If it's a custom syntax, document it.
Activity
karuppasamy commentedon Dec 27, 2017
I don't have any experience with Windows 10. But, I am guessing the below config (in user settings) will solve your problem.
wingrunr21 commentedon Mar 5, 2018
Hi @johnunclesam
Is this still an issue for you with the latest version of the extension? Some changes were introduced in how Rubocop is run in v0.16.0 so wondering if that fixed it.
WA9ACE commentedon Mar 9, 2018
I personally still have this problem and I'm using version 0.17.0 on macOS.
msokk commentedon Mar 10, 2018
Still a problem for me, v0.17.0 with rubocop v0.53.0 on macOS.
schema.rbstill gets linted by extension.wingrunr21 commentedon Apr 3, 2018
Closing for issue cleanup. Apologies if this is still an issue. We are working to improve the core extension experience.
garyking commentedon Apr 10, 2018
Yep still a problem.
gurgeous commentedon Apr 10, 2018
I bet rubocop doesn't apply
Excluderules when you run it on a single file. Perhaps this will help - rubocop/rubocop#893garyking commentedon Apr 10, 2018
I just ran Rubocop on a single file, and it respected exclusions.
Specifically, certain rules by default in Rubocop, don't apply to files in
specsandtestfolders, yet in this extension, they still run. LikeMetrics/ClassLength.gurgeous commentedon Apr 10, 2018
@garyking, there are two separate issues:
Metrics/ClassLengthare applied when they shouldn't be. Presumably because rubocop isn't getting enough context when linting. Haven't investigated yet.Excludestill get linted (likedb/schema.rb). I bet adding--force-exclusionwill solve this problem.wingrunr21 commentedon Apr 10, 2018
@garyking what's your rubocop config for this extension look like? Both of those issues basically mean Rubocop is either not finding the
.rubocop.ymlor is ignoring the settings. I'm wondering if one of the extension settings is activating a CLI option that causes things to be ignored.garyking commentedon Apr 11, 2018
This ext isn't importing Excludes from inherited rules for some reason.
I have a workspace in VSC. There's a
.rubocop.ymlin the workspace's root. It just has:inherit_from: /Users/gary/.base-rubocop.yml.In that inherited file, it has:
Back in my workspace, in the file
test/test_file.rb, if I run Rubocop on the file from Terminal, then I get no errors. But in VSC, this ext gives me theMetrics/ClassLengtherror, indicating thatExcludeis not inherited. But theMaxvalue definitely is, because it says205/150.29 remaining items
fedeth commentedon Jul 13, 2021
The
forceExclusionoption combined with"useBundler": trueworks for me.peternixey commentedon Sep 14, 2021
I had the same problem but noticed that when it was run in Visual Studio, Rubocop wasn't referencing the same root directory as my project. So I tried making the exclusion root-independent and it then worked fine:
heragu commentedon Nov 9, 2021
@peternixey I tried your solution and works in vs code but then it does not work in the command line. When I tried to run in the terminal
bundle exec rubocopI got an error like the following:This helps while developing with VS code but if you have
rubocopintegrated in your deployment pipeline it is not a final solution.peternixey commentedon Nov 9, 2021
@heragu - it actually doesn’t even work in Vscode any more for me. I find anything to do with Ruby (solargraph etc too) a bit of a black art to get working!
evgenyneu commentedon Dec 23, 2021
The
"forceExclusion": truesolution does not work for me. What's the status of this bug? Is anyone working on it?shrkw commentedon Apr 19, 2022
This behavior is really strange. I created experiment project: https://github.com/shrkw/vscode-ruby-dev-env-sample , and rubocop and "Exclude" settings works very well yesterday.
I opened it today, "Exclude" settings does not work at all!
Debug Output view for "Ruby Language Server" shows rubocop has correct option...
and same command returns no offenses.
It's really difficult to understand.
evgenyneu commentedon Apr 19, 2022
I found what caused the problem, it's this setting:
I removed it and it worked! It should be
ruby.rubocop.useBundlerand NOTruby.lint.rubocop.useBundler.VS Code: Fix issue where rubocop `Exclude` wasn't working
benzado commentedon Apr 20, 2022
Since this is an old issue with lots of comments, it's possible there are multiple bugs being represented here. However, I strongly suspect this issue is a duplicate of #578 and #719, and is fixed by PR #720. However, the fix hasn't made it into a release yet.
fix(language-server-ruby): pass valid filenames to RuboCop
senhalil commentedon Jun 16, 2022
@benzado if I am not mistaken PR #720 fixes only
language-server-ruby/src/linters/and this issue is related tolanguage-server-ruby/src/formatters/(which has exactly the same issue -- extra single quotes). I created PR #825 and appreciate it if you can review it.qwell commentedon Dec 8, 2022
Even if PR #825 gets merged and doesn't work, we're no worse off than we are right now with 0.28.1. Could #641 even be reproduced at this point, given the 78 (I counted) releases rubocop has had since August 01, 2020?
Rather than dealing with the fallout of that commit for 2 more years, can PR #647 just be reverted until it can be shown that there actually is a problem in the first place?
qwell commentedon Dec 8, 2022
#840 (which could supersede #825 - although @senhalil should feel free to merge this and let things continue over there) finishes reverting all of the changes from #647, which hadn't already been reverted elsewhere.
celesteking commentedon Jan 11, 2023
You should really also document the pattern syntax. Whether it's a
Dir.globorfnmatch, or shell glob, explicitly state so. If it's a custom syntax, document it.Use rubocop as just a ruby formatter in vscode to avoid vscode-ruby b…