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

Multiline property wrappers cause false positives for let_var_whitespace #4801

Closed
2 tasks done
mildm8nnered opened this issue Mar 6, 2023 · 1 comment · Fixed by #5367
Closed
2 tasks done

Multiline property wrappers cause false positives for let_var_whitespace #4801

mildm8nnered opened this issue Mar 6, 2023 · 1 comment · Fixed by #5367
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@mildm8nnered
Copy link
Collaborator

New Issue Checklist

Describe the bug

Given the following code, let_var_whitespace will fire at lines 4 and 8.

internal struct Foo {
    @Flag(name: [.long, .customLong("autocorrect")], help: "Correct violations whenever possible.")
    internal var fix = false
    @Flag(help: """
        Should reformat the Swift files using the same mechanism used by Xcode (via SourceKit).
        Only applied with `--fix`/`--autocorrect`.
        """)
    internal var format = false
    @Flag(help: "Use an alternative algorithm to exclude paths for `excluded`, which may be faster in some cases.")
    internal var useAlternativeExcluding = false
}

This code is actually from LintOrAnalyzeArguments.swift

Complete output when running SwiftLint, including the stack trace and command used
% swiftlint lint --no-cache --enable-all-rules Foo.swift
Linting Swift files at paths Foo.swift
Linting 'Foo.swift' (1/1)
The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release.
/tmp/Foo.swift:3:14: warning: Explicit Type Interface Violation: Properties should have a type interface (explicit_type_interface)
/tmp/Foo.swift:8:14: warning: Explicit Type Interface Violation: Properties should have a type interface (explicit_type_interface)
/tmp/Foo.swift:10:14: warning: Explicit Type Interface Violation: Properties should have a type interface (explicit_type_interface)
/tmp/Foo.swift:4:5: warning: Variable Declaration Whitespace Violation: Let and var should be separated from other statements by a blank line. (let_var_whitespace)
/tmp/Foo.swift:8: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 5 violations, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.50.3
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
  • Paste your configuration file:

none

no

  • Which Xcode version are you using (check xcodebuild -version)?
Xcode 14.2
Build version 14C18
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.

See above.

@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Mar 12, 2023
@florentdouine
Copy link

Hi !
I did the same observation on another kind of code, if it could help the resolution :

struct Example {
    @available(
        *, deprecated, renamed: "buttonStyle", message: """
    XXX
    """
    )
    public var style: Style = .primary { /// <-- Swiftlint warning `let_var_whitespace` here
        didSet {
            self.buttonStyle = .init(style: self.style, colorScheme: self.colorScheme)
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants