Address several autofix output issues by adding per-file line/column offset tracking - #4429
Merged
Conversation
ievans
approved these changes
Dec 15, 2021
ievans
left a comment
Member
There was a problem hiding this comment.
@chair6 thanks for a terrific first contribution. This looks good to me. I think a docstring in code about what FileOffsets represents might be helpful, as it wasn't obvious to me at first, but as I understand it maintains the state the is necessary to track maintain correct behavior when applying multiple fixes to a single file/line.
Contributor
Author
|
Thanks for the review, @ievans! Yup, you got it.. I've added the docstring. |
emjin
approved these changes
Dec 15, 2021
emjin
left a comment
Collaborator
There was a problem hiding this comment.
This looks awesome! Made a very minor clarification to your comment. Also, I believe this won't work if two rules make a change to the same line, so we should just make a note of that.
Thank you so much for this contribution! A huge improvement for autofix
brendongo
approved these changes
Dec 16, 2021
3 tasks
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.
This change addresses several autofix-related issues by adding per-file line/column offset tracking, and using those offsets when making edits to files.
There is no change in usage or documentation; it just addresses several edge cases within the existing autofix implementation (multi-line fixes, multiple-fixes-in-one-line fixes) that were not cleanly handled until now.
This should address several open issues; #4428, #3577, and #3388.
It adds several new e2e tests with rules/targets based on the issues above, and passes the existing tests in
tests/e2e/test_autofix.pyon my local machine.PR checklist: