mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
Apply small refactorings
This commit is contained in:
@@ -11,16 +11,16 @@ public struct NestingRule: ConfigurationProviderRule {
|
||||
public static let description = RuleDescription(
|
||||
identifier: "nesting",
|
||||
name: "Nesting",
|
||||
description: "Types should be nested at most 1 level deep, " +
|
||||
"and functions should be nested at most 2 levels deep.",
|
||||
description:
|
||||
"Types should be nested at most 1 level deep, and functions should be nested at most 2 levels deep.",
|
||||
kind: .metrics,
|
||||
nonTriggeringExamples: NestingRuleExamples.nonTriggeringExamples,
|
||||
triggeringExamples: NestingRuleExamples.triggeringExamples
|
||||
)
|
||||
|
||||
private let omittedStructureKinds: [SwiftStructureKind] =
|
||||
[.declaration(.enumcase), .declaration(.enumelement)]
|
||||
+ SwiftDeclarationKind.variableKinds.map { .declaration($0) }
|
||||
private let omittedStructureKinds = SwiftDeclarationKind.variableKinds
|
||||
.union([.enumcase, .enumelement])
|
||||
.map(SwiftStructureKind.declaration)
|
||||
|
||||
private struct ValidationArgs {
|
||||
var typeLevel: Int = -1
|
||||
@@ -146,17 +146,4 @@ private enum SwiftStructureKind: Equatable {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
static func == (lhs: SwiftStructureKind, rhs: SwiftStructureKind) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case let (.declaration(lhsKind), .declaration(rhsKind)):
|
||||
return lhsKind == rhsKind
|
||||
case let (.expression(lhsKind), .expression(rhsKind)):
|
||||
return lhsKind == rhsKind
|
||||
case let (.statement(lhsKind), .statement(rhsKind)):
|
||||
return lhsKind == rhsKind
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,10 @@ public struct NestingConfiguration: RuleConfiguration, Equatable {
|
||||
if let functionLevelConfiguration = configurationDict["function_level"] {
|
||||
try functionLevel.apply(configuration: functionLevelConfiguration)
|
||||
}
|
||||
// swiftlint:disable:next line_length
|
||||
checkNestingInClosuresAndStatements = configurationDict["check_nesting_in_closures_and_statements"] as? Bool ?? true
|
||||
alwaysAllowOneTypeInFunctions = configurationDict["always_allow_one_type_in_functions"] as? Bool ?? false
|
||||
checkNestingInClosuresAndStatements =
|
||||
configurationDict["check_nesting_in_closures_and_statements"] as? Bool ?? true
|
||||
alwaysAllowOneTypeInFunctions =
|
||||
configurationDict["always_allow_one_type_in_functions"] as? Bool ?? false
|
||||
}
|
||||
|
||||
func severity(with config: SeverityLevelsConfiguration, for level: Int) -> ViolationSeverity? {
|
||||
|
||||
Reference in New Issue
Block a user