-
Notifications
You must be signed in to change notification settings - Fork 172
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
Rubocop errors are not displayed in the VSCode #2992
Comments
Did you try this? |
Yes. The rubocop command works correctly. We use bundle exec rubocop app/target_file.rb
# ~~
1 file inspected, xx offenses detected, zz offenses autocorrectable |
Keep in mind that running RuboCop in the terminal is not representative of what's happening in the editor. When you're editing files, the Ruby LSP will constantly see files in their intermediate state as you are in the middle of typing. When you run RuboCop in the terminal, you are likely already done editing, so in that environment RuboCop always sees the final form of the file. These errors mean that the cop fails in some intermediate state. Maybe the implementation of the cop is making assumptions about certain parts of the code being present, which works on the command line, but will fail if you are in the middle of typing. For example, imagine someone created a cop to verify that Rails' # The command line sees this. The complete version of the code
class Foo
validate :something
end
# The LSP sees the entire progression of typing, one keypress at a time
# At a certain moment in time, no matter how fast you are typing, the LSP
# will see this code.
#
# In this case, you are typing the validate call, but haven't finished yet.
# If the cop assumes that validate will always have one argument with a symbol
# then it will crash in the editor
class Foo
validate
end If you can figure out under which conditions the cop crashes, then it would be nice to report it to From our side, I think we need to make the message clearer about when this notification pops up. And maybe it should be converted to a window log message, rather than a window show message. |
Thank you for the information. The It is strange that this error is showing up on the LSP side, as |
Description
Ruby LSP Information
VS Code Version
1.96.0
Ruby LSP Extension Version
0.8.16
Ruby Version Manager
rbenv
gem Versions
rubocop 1.68.0
rubocop-rails 2.20.2
Reproduction steps
Code snippet or error message
Supplement
The same issue occurred with Rubocop 1.41.1 when using Ruby-LSP version 0.8.13. At that time, I upgraded Rubocop to version 1.68.0.
Constantly upgrading the Rubocop version increases the operational burden, which is challenging.
The text was updated successfully, but these errors were encountered: