-
Notifications
You must be signed in to change notification settings - Fork 74
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
update PatchCop to support spanning errors #79
Merged
ashkulz
merged 3 commits into
prontolabs:master
from
nevinera:handle-errors-with-line-ranges
Jan 17, 2023
Merged
update PatchCop to support spanning errors #79
ashkulz
merged 3 commits into
prontolabs:master
from
nevinera:handle-errors-with-line-ranges
Jan 17, 2023
Conversation
This file contains 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
We want to keep an error if it _includes_ any lines in a given patch. We also want only the first such line, since it likely includes more than one (this singularism was implicit before, because each line was only passed through once)
ashkulz
approved these changes
Dec 31, 2022
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.
ashkulz
reviewed
Jan 16, 2023
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.
Sorry for the late review!
ashkulz
approved these changes
Jan 17, 2023
Thank you sir! No rush, we have a workaround in place :-) |
This has been pushed to RubyGems 🎉 |
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.
Purpose
Currently, if a changeset appends a bunch of logic to a large method, and the resulting method is "too complex", rubocop will complain, but pronto-rubocop will not notice. This is because we're comparing the
offense.line
against the patch to see if that line is part of the changes being checked.. but theoffense.line
is actuallyoffense.location.first_line
, which can be outside the changes, despite the violation being introduced.Implementation
select
todetect
- the prior implementation only ever hit a given offense once, since it only traversed each line-number once. But now it's possible (likely) to hit the same offense multiple times on consecutive lines, and we're only interested in the first time the offense was affected.patch_cop_spec.rb
.