Skip to content
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

[Colon Rule] Fix case when comment is used in function call #3740

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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