Files
SwiftLint/Source/SwiftLintBuiltInRules/Rules/RuleConfigurations/IndentationWidthConfiguration.swift
Danny Mösch 1b7fbc4bcd Make postprocessors non-throwing (#5539)
Failing immediately when a property is invalid is too strict. It feels
sufficient to allow to report an issue but otherwise continue with a default
value instead of stopping execution completely.
2024-04-23 16:45:59 -04:00

28 lines
962 B
Swift

import SwiftLintCore
@AutoApply
struct IndentationWidthConfiguration: SeverityBasedRuleConfiguration {
typealias Parent = IndentationWidthRule
private static let defaultIndentationWidth = 4
@ConfigurationElement(key: "severity")
private(set) var severityConfiguration = SeverityConfiguration<Parent>.warning
@ConfigurationElement(
key: "indentation_width",
postprocessor: {
if $0 < 1 {
Issue.invalidConfiguration(ruleID: Parent.identifier).print()
$0 = Self.defaultIndentationWidth
}
}
)
private(set) var indentationWidth = 4
@ConfigurationElement(key: "include_comments")
private(set) var includeComments = true
@ConfigurationElement(key: "include_compiler_directives")
private(set) var includeCompilerDirectives = true
@ConfigurationElement(key: "include_multiline_strings")
private(set) var includeMultilineStrings = true
}