-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix crash when disable command is preceded by unicode character #5976
base: main
Are you sure you want to change the base?
Conversation
Generated by 🚫 Danger |
5905446
to
db786b3
Compare
@@ -60,35 +62,54 @@ struct InvalidSwiftLintCommandRule: Rule, SourceKitFreeRule { | |||
|
|||
private func styleViolation(for command: Command, in file: SwiftLintFile, reason: String) -> StyleViolation { | |||
let character = command.startingCharacterPosition(in: file) | |||
let characterOffset = character.flatMap { |
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.
So I think we could make the characterOffset
retrieval a function on the Command
extension, so this reads more nicely here, but having to do all of these line calculations feels a bit off in general.
The reason we have to do this calculations is because Command
's character
property records the character beyond the end of the command. If that instead recorded the start of the command, which is where this rule places the violation, then we could ditch all of this code.
I think that might be possible, but something we could look at separately.
@@ -18,6 +18,9 @@ | |||
|
|||
* Fix issue referencing the Tests package from another Bazel workspace. | |||
[jszumski](https://github.com/jszumski) | |||
* Fix crash when a disable command is preceded by a unicode character. |
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.
Maybe a blank line here?
Fixes #5945.