-
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
Colon Rule doesn't apply to dictionaries when used as a type #1074
Comments
It seems SwiftLint 0.15 also missed some other cases, here's what I had to replace manually: wordpress-mobile/WordPress-iOS@df5a04a |
Yeah, that structure is expected. However, that violation should be caught by the "old" implementation. In this case, both tokens are Would you like to try to open a PR to allow two |
I guess looking at the rule description it makes sense:
The
Another cases that doesn't match the pattern is |
Fair enough. I'll change the label from "bug" to "enhancement" then 😅 |
I've tried adding a few more options to that check: // let ↓abc:Void
guard syntaxKinds.starts(with: [.identifier, .typeidentifier])
// let ↓abc:Any
|| syntaxKinds.starts(with: [.identifier, .keyword])
// let abc: [↓Void:Void]
|| syntaxKinds.starts(with: [.typeidentifier, .typeidentifier])
// let abc: [↓Void:Any]
|| syntaxKinds.starts(with: [.typeidentifier, .keyword]) else {
return false
} However this is matching a couple other things that I thing shouldn't be matched: - case .null:
- return "Null"
+ case .null: return "Null" - let even = ranges.enumerated().flatMap { $0 % 2 == 0 ? $1 : nil }
+ let even = ranges.enumerated().flatMap { $0 % 2 == 0 ? $1: nil } I've pushed what I have so far to koke@3788392 |
There's also |
With Version 0.23 and apply_to_dictionaries: false the colon rule now reports a dictionary type like [String : Any] as an error. If I set apply_to_dictionaries: false, I expect the colon rule not to check dictionaries at all. It worked as expected in 0.21 and 0.22. |
@DG0BAB please file a new issue. We've created a new issue template that asks lots of useful questions that would help us fix issues faster, providing critical context and repro steps that drive-by comments on closed issues often doesn't include. |
I've noticed SwiftLint 0.15 doesn't correct an expression like
let abc: [Void:Void]
(should correct tolet abc: [Void: Void]
).I tried to fix it myself, but I'm not sure what's causing the problem. The
File
structure is different when the dictionary is used just as a type than when it's used as a constructor, but I don't know if it's a problem in SwiftLint, SourceKitten, or a SourceKit bug.The text was updated successfully, but these errors were encountered: