Merged
Conversation
Contributor
|
dhruvmanila
approved these changes
Jun 5, 2025
Member
dhruvmanila
left a comment
There was a problem hiding this comment.
This looks pretty straightforward!
crates/ruff_server/src/lint.rs
Outdated
Comment on lines
277
to
267
| code: rule.noqa_code().to_string(), | ||
| code: code?.to_string(), |
Member
There was a problem hiding this comment.
nit: we could short-circuit if code is None and avoid generating the edits although I think currently it's only the syntax errors that doesn't have code and those doesn't have fixes, so maybe this isn't that useful
Contributor
Author
There was a problem hiding this comment.
Yeah, I think the fix.is_some() || noqa_edit.is_some() condition should virtually guarantee this is never None, but I can move it to the top of the closure just in case. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a spin-off from #18447 (comment) to avoid using
Message::noqa_codeto differentiate between lints and syntax errors. I went through all of the calls onmainand on the branch from #18447, and the instance inruff_servernoted in the linked comment was actually the primary place where this was being done. Other calls tonoqa_codeare typically some variation ofmessage.noqa_code().map_or(String::new, format!(...)), with the major exception of the gitlab output format:ruff/crates/ruff_linter/src/message/gitlab.rs
Lines 93 to 105 in a120610
which obviously assumes that
Nonemeans syntax error. A simple fix here would be to usemessage.name()forcheck_nameinstead of the noqa code, but I'm not sure how breaking that would be. This could just be:In that case. This sounds reasonable based on the Code Quality report format docs:
Test Plan
Existing tests