-
Notifications
You must be signed in to change notification settings - Fork 171
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
Add Prism warnings in diagnostics #1437
Conversation
357f426
to
f77c918
Compare
FYI @kddnewton |
I wonder if we should make this configurable (#1434) since if working on a legacy there project, there could be lot of noise.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this could be a configurable feature, which can be the first new config of .ruby-lsp.yml
.
That said, I think it's fine to merge or even release this first to see how people react to it.
I don't think there will be much noise to be honest, there aren't that many kinds of warnings and all of them are trivially fixable. I do think you could add a configuration option to limit it to "default"-level warnings versus "verbose"-level warnings though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor nitpick, but this is great 🚀.
Concerning configuring this, I honestly wouldn't worry about it ahead of time. If people start complaining about the warnings we can consider it, but I don't think it warrants increasing complexity.
However, I wonder if we can now shutdown some of the RuboCop rules in the rubocop-shopify
configuration. Prism is surely going to be a lot faster in surfacing this and we can reduce the number of cops running.
@kddnewton do you have a list of which warnings are available? (Even better if you know which RuboCop rules they map to).
f77c918
to
a9dc4bc
Compare
@vinistock they're listed here: https://github.com/ruby/prism/blob/f41ba6d7ecfc844535996e24525d4ea47c0a85db/src/diagnostic.c#L305-L314. I haven't taken the time to line them up 1-to-1 with warnings from rubocop, but if you don't mind doing that it would actually help me. I need it for ruby/prism#2513. |
I'll take a stab at matching those to the RuboCop cops. |
|
Thanks for the contribution! |
Motivation
Closes #1406
Add Prism warnings in diagnostics, actually we handle only errors.
Implementation
Same as error, but based on
parse_result.warnings
Some minor changes in
DiagnosticsExpectationsTest
because we are not handling only Rubocop diagnostics now.Automated Tests
Added fixtures and expectations.
Manual Tests
You can open
test/fixtures/syntax_diagnostics.rb
and see errors and warning.