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

opening_brace triggers when the brace is preceded by a comment #5578

Closed
2 tasks done
DanielRouxSA opened this issue May 15, 2024 · 0 comments · Fixed by #5582
Closed
2 tasks done

opening_brace triggers when the brace is preceded by a comment #5578

DanielRouxSA opened this issue May 15, 2024 · 0 comments · Fixed by #5582
Assignees
Labels

Comments

@DanielRouxSA
Copy link

New Issue Checklist

Describe the bug

When an opening brace is preceded by a comment (for example a clarifying comment in an if statement, a commented out inheritance, etc.), the opening_brace rule reports a warning, even when the line is technically compliant (one space between the end of the comment and the brace).

Environment

  • SwiftLint 0.55.0
  • CocoaPods
  • Configuration file does not configure opening_brace.
  • Xode 15.4

Samples

The following three examples produce the Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration (opening_brace) warning:

// Here I added a clarifying comment since it might not be obvious that the unit here is seconds.
if timeSpent < 60.0 /* Seconds */ {
    // Do something here...
}
do {
    // Try something that may throw
} catch /*where error is CancellationError == false*/ { // The error handling logic here has changed and thus the catch condition is no longer needed, but kept here for a while for reference.
    // Error handling...
}
class SomeClass: SomeBaseClass/*, SomeProtocol*/ { // Inheritance of SomeProtocol is no longer needed.
    
}

I did notice that this may already be a known issue stemming from this rule's rewrite using SwiftSyntax (#5164 (review)).

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

Successfully merging a pull request may close this issue.

2 participants