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
With enabled rule indentation_width you will get warnings for preprocessor statements in nested structures. Xcode's cmd + i formats the code correctly (preprocessor statements always at the beginning of a line, all other commands, view modifiers etc. indented as expected.
Code Snippet
privatestructMyView:View{#if os(iOS)@StatevarscrollViewHeight:CGFloat=.zero
#endif@EnvironmentObjectvarconfig:MyConfigvarbody:someView{#if os(iOS)ScrollView{ // <- This triggers warning
content
}.frame(maxHeight: scrollViewHeight)#else
content // <- This triggers warning
#endif}}
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Warning Output
Indentation Width Violation: Code should be indented using one tab or 4 spaces. (indentation_width)
Environment
SwiftLint version (run swiftlint version to be sure)? - 0.47.1
Installation method used (Homebrew, CocoaPods, building from source, etc)? - SPM Build Tool Plugin
Thanks @SimplyDanny! You are right, it works for something like in my example.
Unfortunately it doesn't work for something like this (maybe for extensions):
public extension Font {
static var cuLargeTitle: Font {
#if os(iOS)
Font.system(size: UIFontMetrics.default.scaledValue(for: 32), weight: .heavy) // triggers warning
#elseif os(macOS)
Font.system(size: 26, weight: .bold) // triggers warning
#endif
}
static var cuTitle: Font {
#if os(iOS)
Font.system(size: UIFontMetrics.default.scaledValue(for: 26), weight: .bold) // triggers warning
#elseif os(macOS)
Font.system(size: 22, weight: .semibold) // triggers warning
#endif
}
…
}
New Issue Checklist
Describe the bug
With enabled rule
indentation_width
you will get warnings for preprocessor statements in nested structures. Xcode'scmd + i
formats the code correctly (preprocessor statements always at the beginning of a line, all other commands, view modifiers etc. indented as expected.Code Snippet
Complete output when running SwiftLint, including the stack trace and command used
Warning Output
Environment
swiftlint version
to be sure)? -0.47.1
SPM Build Tool Plugin
NO
xcodebuild -version
)?see example above
The text was updated successfully, but these errors were encountered: