Skip to content

Commit

Permalink
Combine compact and flat mapping (#5897)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny authored Dec 15, 2024
1 parent 8e3b50f commit 23ba688
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Source/SwiftLintCore/Models/RuleConfigurationDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ public struct RuleConfigurationDescription: Equatable {
return Self(options: customDescription.options, exclusiveOptions: exclusiveOptions)
}
let options: [RuleConfigurationOption] = Mirror(reflecting: configuration).children
.compactMap { child -> Self? in
.flatMap { child in
// Property wrappers have names prefixed by an underscore.
guard let codingKey = child.label, codingKey.starts(with: "_") else {
return nil
if child.label?.starts(with: "_") == true,
let element = child.value as? any AnyConfigurationElement {
return element.description.options
}
guard let element = child.value as? any AnyConfigurationElement else {
return nil
}
return element.description
}.flatMap(\.options)
return []
}
guard options.isNotEmpty else {
queuedFatalError(
"""
Expand Down

0 comments on commit 23ba688

Please sign in to comment.