Skip to content

Commit

Permalink
Colon rule should ignore cases when comment is in function argument (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulTaykalo authored Oct 14, 2021
1 parent 383e5b5 commit a87aee1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@

* Speed up Computed Accessors Order rule.
[PaulTaykalo](https://github.com/PaulTaykalo)
[#3727](https://github.com/realm/SwiftLint/issues/3727)
[#3727](https://github.com/realm/SwiftLint/issues/3727)

* [Colon Rule] Fix case when comment is used in function call.
[PaulTaykalo](https://github.com/PaulTaykalo)
[#issue_number](https://github.com/realm/SwiftLint/issues/3740)

## 0.44.0: Travel Size Lint Roller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ extension ColonRule {
internal func functionCallColonViolationRanges(in file: SwiftLintFile, kind: SwiftExpressionKind,
dictionary: SourceKittenDictionary) -> [ByteRange] {
guard kind == .argument,
let argumentRange = dictionary.byteRange,
!file.syntaxMap.tokens(inByteRange: argumentRange).kinds.contains(where: { $0.isCommentLike }),
let ranges = functionCallColonRanges(dictionary: dictionary)
else {
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal struct ColonRuleExamples {
Example("class Foo<T: Equatable>: Bar {}\n"),
Example("class Foo<T, U>: Bar {}\n"),
Example("class Foo<T: Equatable> {}\n"),
Example("object.method(x: /* comment */ 5)\n"),
Example("""
switch foo {
case .bar:
Expand Down

0 comments on commit a87aee1

Please sign in to comment.