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 CommaRule
mismatch between violations and corrections
#542
Conversation
CommaRule
did not match between violations and correctionsCommaRule
did not match between violations and corrections
It seems more than two spaces after comma does not generate violation: let a = [1, 2] But correction happens for that. |
@@ -14,6 +14,10 @@ | |||
[Norio Nomura](https://github.com/norio-nomura) | |||
[#535](https://github.com/realm/SwiftLint/issues/535) | |||
|
|||
* Fix `CommaRule` did not match between violations and corrections. |
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.
Fix
CommaRule
mismatch between violations and corrections.
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.
Thanks 🙏
@jpsim I got a question while I'm implementing following won't generate violation and correction. func f(
a: Int,
b: Int // comma+newline+spaces
) {
} Should we generate violation and correction for following? func f(a: Int
, b: Int // newline+spaces+comma+space
) {
} In other word, should we exclude line ending character on checking? |
…_:)` in `CommaRule`
```swift func abc( a: String, // comment bcd: String // comment ) { } ```
```swift func abc( a: String, bcd: String ) { } ```
…Tests.testSwiftLintAutoCorrects()`
69bded7
to
01b0616
Compare
Updated.
I leave it generates on case B. By applying this PR, The duration |
CommaRule
did not match between violations and correctionsCommaRule
did not match between violations and corrections
CommaRule
did not match between violations and correctionsCommaRule
mismatch between violations and corrections
That returns array of SyntaxTokens intersecting with byte range.
On linting Carthage 0.14, the duration of `SyntaxMap.tokensIn(_:)` reduced from 145ms to 51ms.
``` SwiftLintFrameworkTests.IntegrationTests testSwiftLintLints, failed - Documented declarations should be valid. ``` That has been fixed on locally by jpsim/SourceKitten#175
Travis is backlogged at the moment, but the only commit not tested is the changelog one, so this is good to merge. These changes all look good to me. Thanks @norio-nomura! |
Fix `CommaRule` mismatch between violations and corrections
Thanks! 🙏 |
CommaRule
Autocorrect reports success even though nothing happens #466 (comment)
CommaRule.correctFile(_:)
Now corrections happen only on violations.
Because
assertCorrection(_:expected:)
expects one correction for eachcorrections
,and the rule added by 93e8e12 causes two corrections on previous logic.
Fix Autocorrect reports success even though nothing happens #466
CommaRule.validateFile(_:)
map
calls inrangesAndTokensMatching(_:)