update PatchCop to support spanning errors#79
Merged
ashkulz merged 3 commits intoprontolabs:masterfrom Jan 17, 2023
nevinera:handle-errors-with-line-ranges
Merged
update PatchCop to support spanning errors#79ashkulz merged 3 commits intoprontolabs:masterfrom nevinera:handle-errors-with-line-ranges
ashkulz merged 3 commits intoprontolabs:masterfrom
nevinera:handle-errors-with-line-ranges
Conversation
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)
Contributor
Author
ashkulz
approved these changes
Jan 17, 2023
Member
Contributor
Author
|
Thank you sir! No rush, we have a workaround in place :-) |
Member
|
This has been pushed to RubyGems 🎉 |
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.
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.lineagainst the patch to see if that line is part of the changes being checked.. but theoffense.lineis actuallyoffense.location.first_line, which can be outside the changes, despite the violation being introduced.Implementation
selecttodetect- 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.