Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow optional configuration values #5798

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Source/SwiftLintCore/Models/RuleConfigurationDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,10 @@ public protocol AcceptableByConfigurationElement {

/// Update the object.
///
/// - Parameter value: New underlying data for the object.
mutating func apply(_ value: Any?, ruleID: String) throws
/// - Parameters:
/// - value: New underlying data for the object.
/// - ruleID: The rule's identifier in which context the configuration parsing runs.
mutating func apply(_ value: Any, ruleID: String) throws
}

/// Default implementations which are shortcuts applicable for most of the types conforming to the protocol.
Expand All @@ -346,10 +348,8 @@ public extension AcceptableByConfigurationElement {
RuleConfigurationDescription(options: [key => asOption()])
}

mutating func apply(_ value: Any?, ruleID: String) throws {
if let value {
self = try Self(fromAny: value, context: ruleID)
}
mutating func apply(_ value: Any, ruleID: String) throws {
self = try Self(fromAny: value, context: ruleID)
}
}

Expand Down Expand Up @@ -657,10 +657,8 @@ public extension AcceptableByConfigurationElement where Self: RuleConfiguration
return RuleConfigurationDescription(options: [key => asOption()])
}

mutating func apply(_ value: Any?, ruleID _: String) throws {
if let value {
try apply(configuration: value)
}
mutating func apply(_ value: Any, ruleID _: String) throws {
try apply(configuration: value)
}

init(fromAny _: Any, context _: String) throws {
Expand Down