Fix rewrite issue with `comma` rule (#4635)
This commit is contained in:
parent
7f8eb9de77
commit
73a64d674c
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -43,16 +43,20 @@
|
||||||
[SimplyDanny](https://github.com/SimplyDanny)
|
[SimplyDanny](https://github.com/SimplyDanny)
|
||||||
[#4612](https://github.com/realm/SwiftLint/issues/4612)
|
[#4612](https://github.com/realm/SwiftLint/issues/4612)
|
||||||
|
|
||||||
* Skip `defer` statements being last in an `#if` block if the `#if` statement is
|
* Skip `defer` statements being last in an `#if` block if the `#if`
|
||||||
not itself the last statement in a block.
|
statement is not itself the last statement in a block.
|
||||||
[SimplyDanny](https://github.com/SimplyDanny)
|
[SimplyDanny](https://github.com/SimplyDanny)
|
||||||
[#4615](https://github.com/realm/SwiftLint/issues/4615)
|
[#4615](https://github.com/realm/SwiftLint/issues/4615)
|
||||||
|
|
||||||
* Fix false positives in `empty_enum_arguments` when the called expression
|
* Fix false positives in `empty_enum_arguments` when the called
|
||||||
is an identifier or an init call.
|
expression is an identifier or an init call.
|
||||||
[Steffen Matthischke](https://github.com/heeaad)
|
[Steffen Matthischke](https://github.com/heeaad)
|
||||||
[#4597](https://github.com/realm/SwiftLint/issues/4597)
|
[#4597](https://github.com/realm/SwiftLint/issues/4597)
|
||||||
|
|
||||||
|
* Fix correction issue in `comma` when there was too much whitespace
|
||||||
|
following the comma.
|
||||||
|
[JP Simard](https://github.com/jpsim)
|
||||||
|
|
||||||
## 0.50.1: Artisanal Clothes Pegs Fixup Edition
|
## 0.50.1: Artisanal Clothes Pegs Fixup Edition
|
||||||
|
|
||||||
#### Breaking
|
#### Breaking
|
||||||
|
|
|
@ -49,7 +49,8 @@ struct CommaRule: CorrectableRule, ConfigurationProviderRule, SourceKitFreeRule
|
||||||
message: My.Custom.message↓ ,
|
message: My.Custom.message↓ ,
|
||||||
another: parameter, doIt: true,
|
another: parameter, doIt: true,
|
||||||
alignment: .center)
|
alignment: .center)
|
||||||
""")
|
"""),
|
||||||
|
Example(#"Logger.logError("Hat is too large"↓, info: [])"#)
|
||||||
],
|
],
|
||||||
corrections: [
|
corrections: [
|
||||||
Example("func abc(a: String↓,b: String) {}\n"): Example("func abc(a: String, b: String) {}\n"),
|
Example("func abc(a: String↓,b: String) {}\n"): Example("func abc(a: String, b: String) {}\n"),
|
||||||
|
@ -83,7 +84,9 @@ struct CommaRule: CorrectableRule, ConfigurationProviderRule, SourceKitFreeRule
|
||||||
message: My.Custom.message,
|
message: My.Custom.message,
|
||||||
another: parameter, doIt: true,
|
another: parameter, doIt: true,
|
||||||
alignment: .center)
|
alignment: .center)
|
||||||
""")
|
"""),
|
||||||
|
Example(#"Logger.logError("Hat is too large"↓, info: [])"#):
|
||||||
|
Example(#"Logger.logError("Hat is too large", info: [])"#)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -109,7 +112,9 @@ struct CommaRule: CorrectableRule, ConfigurationProviderRule, SourceKitFreeRule
|
||||||
let nextIsNewline = next.leadingTrivia.containsNewlines()
|
let nextIsNewline = next.leadingTrivia.containsNewlines()
|
||||||
return (ByteRange(location: start, length: end - start), shouldAddSpace: !nextIsNewline)
|
return (ByteRange(location: start, length: end - start), shouldAddSpace: !nextIsNewline)
|
||||||
} else if !current.trailingTrivia.starts(with: [.spaces(1)]), !next.leadingTrivia.containsNewlines() {
|
} else if !current.trailingTrivia.starts(with: [.spaces(1)]), !next.leadingTrivia.containsNewlines() {
|
||||||
return (ByteRange(location: ByteCount(current.position), length: 1), shouldAddSpace: true)
|
let start = ByteCount(current.position)
|
||||||
|
let end = ByteCount(next.positionAfterSkippingLeadingTrivia)
|
||||||
|
return (ByteRange(location: start, length: end - start), shouldAddSpace: true)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue