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

let_var_whitespace rule is triggered when on one line before there is #warning statement #2544

Closed
2 tasks done
Igor-Palaguta opened this issue Jan 5, 2019 · 5 comments
Closed
2 tasks done
Labels
bug Unexpected and reproducible misbehavior.

Comments

@Igor-Palaguta
Copy link

New Issue Checklist

Describe the bug

let_var_whitespace rule is triggered when on one line before there is #warning statement

struct SomeStruct {
    let first: Int
    let second: Int

    #warning("Warning")
    let third: Int
}

Variable Declaration Whitespace Violation: Let and var should be separated from other statements by a blank line. (let_var_whitespace)

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.29.2
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    SwiftLint.pkg
  • Paste your configuration file:
opt_in_rules:
  - let_var_whitespace
  • Are you using nested configurations?
    If so, paste their relative paths and respective contents.
    No
  • Which Xcode version are you using (check xcode-select -p)?
    Version 10.0 (10A255)
  • 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.
struct SomeStruct {
    let first: Int
    let second: Int

    #warning("Warning")
    let third: Int
}
@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Jan 5, 2019
@marcelofabri
Copy link
Collaborator

@Igor-Palaguta would you like to work on a PR to fix this? 🚀

@Igor-Palaguta
Copy link
Author

@marcelofabri yes sure, let me check

@undeaDD
Copy link

undeaDD commented Jan 11, 2019

Hey there @Igor-Palaguta, @marcelofabri.

I just found another bug with let_var_whitespace?
Or is this intended? I hope your PR will fix this aswell if its not.

thanks and good luck
Dominic

screenshot 2019-01-11 at 09 20 15

@Igor-Palaguta
Copy link
Author

@undeaDD

Checked rule implementation. And fixing it for #warning is one line fix #2629. But for typealiases not so fast. As we should check that same type is used.

e.g.

Trigger:

typealias A = Int
typealias B = Float
let a = "Hello"

Not trigger:

typealias A = Int
let a: A

And not sure what to do here:

typealias A = Int
typealias B = Float
let a: B

@marcelofabri
Copy link
Collaborator

Fixed in #2629.

@undeaDD Please file a new issue for what you've described.

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

No branches or pull requests

3 participants