Repository navigation
Automatically correct certain violations - #241
Conversation
d743035 to
da1ddbc
Compare
|
@keith it'd be great to get your feedback on this one. |
There was a problem hiding this comment.
Maybe instead of keeping a separate list we have to maintain we could flatMap enabled rules from the configuration as? CorrectableRule ?
There was a problem hiding this comment.
good idea, I think that should work.
|
I'm totally on board with this approach! |
|
Re the last check mark, I think I'd prefer a separate autocorrect command. I feel like it's a big enough of a difference it's worth being separate. |
There was a problem hiding this comment.
I really want this to be in the standard lib 😞
There was a problem hiding this comment.
I see this method being used by the regex matchers. Since NSString is based around UTF-16 code units and not grapheme clusters, wouldn't this give wrong results for certain kinds of strings?
There was a problem hiding this comment.
You're right! 😱 I just fixed this. Nice catch!
pre-correction keys map to post-correction values
since we encourage users to have backups of their files right after
|
|
|
Thanks for reviewing, @keith! |
Automatically correct certain violations
|
👍 |
This is a first stab at #5.
Not super helpful at the moment because there's no reporting of what was corrected, which we'll want to add before merging this inedit: done.Since this sets the direction for future autocorrect behavior, feedback is greatly appreciated!
Turns out this is kind of tricky to do in a robust way. Specifically: modifying files on disk can cause previous violation offsets to become invalid, or new violations to be created, or previous violations to vanish. For this reason, I've opted for
--autocorrectto not lint in the normal sense, not reporting any violations.Remaining:
disabled_rules// swiftlint:disableautocorrectcommand is preferable to an--autocorrectflag on thelintcommand (requires moving a lot more of the logic currently inswiftlint.LintCommandintoSwiftLintFramework.Linter, which is probably a good thing to do anyway)