New Issue Checklist
Describe the bug
The indentation_width rule fails to detect when a closing brace } is indented incorrectly (doesn't match the indentation of its opening statement). The rule correctly detects indentation issues on regular statements but misses closing braces that are under-indented.
Steps to Reproduce
Run the following command:
echo 'import SwiftUI
struct TestView: View {
var body: some View {
VStack {
Text("Hello")
}
.onTapGesture {
if true {
print("inside if")
}
}
}
}' | swiftlint lint --no-cache --use-stdin --enable-all-rules
File structure explained:
import SwiftUI
struct TestView: View {
var body: some View {
VStack {
Text("Hello")
}
.onTapGesture {
if true { // Line 9: 12 spaces (3 levels)
print("inside if") // Line 10: 16 spaces (4 levels) ✓
} // Line 11: 8 spaces (2 levels) ✗ WRONG - should be 12
} // Line 12: 8 spaces (2 levels) ✓
}
}
The closing } on line 11 (closing the if statement) has only 8 spaces of indentation, but it should have 12 spaces to match the if true { on line 9.
Expected behavior
SwiftLint should report an indentation_width violation on line 11:
<nopath>:11:1: warning: Indentation Width Violation: Code should be indented using one tab or 4 spaces (indentation_width)
Actual behavior
No violation is reported for line 11. The output only shows other violations (explicit_acl, file_header, etc.) but no indentation_width violation for the incorrectly indented closing brace.
Proof that the rule works for other cases
The rule DOES correctly detect indentation issues on regular statements:
echo 'import SwiftUI
struct TestView: View {
var body: some View {
if true {
print("wrong indent")
}
}
}' | swiftlint lint --no-cache --use-stdin --enable-all-rules
Output includes:
<nopath>:6:1: error: Indentation Width Violation: Code should be indented using one tab or 4 spaces (indentation_width)
This proves the rule is active and working, but it specifically misses closing braces.
Environment
- SwiftLint version: 0.63.2
- Installation method: Pre-built binary
- Xcode version: 16.x
- macOS version: macOS 15.x (Sequoia)
New Issue Checklist
Describe the bug
The
indentation_widthrule fails to detect when a closing brace}is indented incorrectly (doesn't match the indentation of its opening statement). The rule correctly detects indentation issues on regular statements but misses closing braces that are under-indented.Steps to Reproduce
Run the following command:
File structure explained:
The closing
}on line 11 (closing theifstatement) has only 8 spaces of indentation, but it should have 12 spaces to match theif true {on line 9.Expected behavior
SwiftLint should report an
indentation_widthviolation on line 11:Actual behavior
No violation is reported for line 11. The output only shows other violations (explicit_acl, file_header, etc.) but no
indentation_widthviolation for the incorrectly indented closing brace.Proof that the rule works for other cases
The rule DOES correctly detect indentation issues on regular statements:
Output includes:
This proves the rule is active and working, but it specifically misses closing braces.
Environment