You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
statement_position rule triggers for missing space before else in if stmt, but not in guard #6153
A clear and concise description of what the bug is. Ideally, provide a small (but compilable) example code snippet that
can be used to reproduce the issue.
guardfoo()else{return} // This should trigger a violation, but doesn't
iffoo(){}else{ // This triggers a violation (statement_position)
}
Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.
$ swiftlint test.swift
Linting Swift files at paths test.swift
Linting 'test.swift' (1/1)
/Users/lukas/temp/test.swift:4:1: warning: Statement Position Violation: Else and catch should be on the same line, one space after the previous declaration (statement_position)
Done linting! Found 1 violation, 0 serious in 1 file.
Opened #6543 for this. The rule was only checking else/catch after a closing brace, so guard foo()else never matched. I added a small guard-specific matcher, wired it into autocorrect, and covered it with the generated rule examples.
Activity
theamodhshetty commentedon Mar 16, 2026
Opened #6543 for this. The rule was only checking
else/catchafter a closing brace, soguard foo()elsenever matched. I added a small guard-specific matcher, wired it into autocorrect, and covered it with the generated rule examples.