Closed
Description
New Issue Checklist
- Updated SwiftLint to the latest versionI searched for existing GitHub issues
Describe the bug
I have adopted the new Swift 5.1 property wrapper feature. It seems to cause a false positive with the opt-in rule let_var_whitespace
.
Relevant file:
import Foundation
public enum Defaults {
@UserDefault("isFirstTimeUser", defaultValue: true)
public static var isFirstTimeUser: Bool
}
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint --config ../.swiftlint.yml
Loading configuration from '../.swiftlint.yml'
Linting Swift files at paths
Linting 'Defaults.swift' (1/1)
<path>/Defaults.swift:6:5: warning: Variable Declaration Whitespace Violation: Let and var should be separated from other statements by a blank line. (let_var_whitespace)
Done linting! Found 1 violation, 0 serious in 1 files.
Environment
- SwiftLint version (run
swiftlint version
to be sure)? 0.37.0 - Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
- Paste your configuration file:
opt_in_rules:
- let_var_whitespace
- Are you using nested configurations? No
- Which Xcode version are you using? 11.2.1
- Do you have a sample that shows the issue?
echo "public enum Defaults {
@UserDefault("isFirstTimeUser", defaultValue: true)
public static var isFirstTimeUser: Bool
}" | swiftlint lint --no-cache --use-stdin --enable-all-rules
Activity
akwilliamson commentedon Mar 23, 2020
What is the status of this? Is anybody working on it?
jshier commentedon Mar 30, 2020
I've found that this can be avoided by adding a doc comment above the property wrapper. Still rather annoying.
bdrelling commentedon May 14, 2020
Adding a +1 here and really appreciative of the workaround @jshier !
Tayphoon commentedon Jun 27, 2020
+++
DimaZava commentedon Aug 3, 2020
The same
fidmor89 commentedon Aug 20, 2020
+1
Also, another workaround would be to have the property wrapper in the same line as the variable definition, something like:
@Inject var foo: Foo
jpsim commentedon Nov 7, 2020
If anyone here has started working on this and has hit a dead end, I'm happy to help answer any questions you might have.
The CONTRIBUTING.md doc should be a good first step in looking into making changes to SwiftLint.
stale commentedon Jan 6, 2021
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!
Igor-Palaguta commentedon Jan 7, 2021
+1
Tayphoon commentedon Jan 13, 2021
MarshalGeazipp commentedon Jan 22, 2021
I hit this annoying bug today.
What is the status of this? Is anybody working on it?
edorphy commentedon May 15, 2021
+1
13 remaining items