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

control_statement asks to illegally unwrap guard. #5846

Closed
2 tasks done
lhunath opened this issue Oct 31, 2024 · 0 comments · Fixed by #5856
Closed
2 tasks done

control_statement asks to illegally unwrap guard. #5846

lhunath opened this issue Oct 31, 2024 · 0 comments · Fixed by #5856
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@lhunath
Copy link

lhunath commented Oct 31, 2024

New Issue Checklist

Bug Description

control_statement checks to ensure the control statement is not unnecessarily wrapped in parenthesis. However, parenthesis are required in certain cases for control statements, such as when the statement itself consists of braces, to disambiguate the braces from the control operator's braces. The following example illustrates where control_statement demands the removal of parentheses which would render the statement illegal in the language.

guard ({ switch target {
    case a: true
    case b: false
}
}())
else { return false }

Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.

$ swiftlint lint test.swift
Linting Swift files at paths test.swift
Linting 'test.swift' (1/1)
/Users/hubstaff/Developer/hubstaff/ios/test.swift:1:1: warning: Control Statement Violation: `if`, `for`, `guard`, `switch`, `while`, and `catch` statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses (control_statement)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure): 0.57.0
  • Xcode version (run xcodebuild -version to be sure): 16.1, 16B40
  • Installation method used (Homebrew, CocoaPods, building from source, etc): brew
@SimplyDanny SimplyDanny self-assigned this Nov 16, 2024
@SimplyDanny SimplyDanny added the bug Unexpected and reproducible misbehavior. label Nov 16, 2024
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.

2 participants