diff --git a/Source/SwiftLintCore/Models/RuleConfigurationDescription.swift b/Source/SwiftLintCore/Models/RuleConfigurationDescription.swift index 66d4aeccf8..a25db38ca6 100644 --- a/Source/SwiftLintCore/Models/RuleConfigurationDescription.swift +++ b/Source/SwiftLintCore/Models/RuleConfigurationDescription.swift @@ -79,7 +79,11 @@ extension RuleConfigurationDescription: Documentable { } public func oneLiner() -> String { - options.map { $0.oneLiner() }.joined(separator: "; ") + oneLiner(separator: ";") + } + + fileprivate func oneLiner(separator: String) -> String { + options.map { $0.oneLiner() }.joined(separator: "\(separator) ") } public func markdown() -> String { @@ -186,7 +190,10 @@ extension OptionType: Documentable { } public func oneLiner() -> String { - yaml() + if case let .nested(value) = self { + return value.oneLiner(separator: ",") + } + return yaml() } public func yaml() -> String { diff --git a/Tests/SwiftLintFrameworkTests/RequiredEnumCaseConfigurationTests.swift b/Tests/SwiftLintFrameworkTests/RequiredEnumCaseConfigurationTests.swift index 1768d93485..6055b59a50 100644 --- a/Tests/SwiftLintFrameworkTests/RequiredEnumCaseConfigurationTests.swift +++ b/Tests/SwiftLintFrameworkTests/RequiredEnumCaseConfigurationTests.swift @@ -37,12 +37,12 @@ class RequiredEnumCaseConfigurationTests: SwiftLintTestCase { } func testConsoleDescriptionReturnsAllConfiguredProtocols() { - let expected = "NetworkResults: error: warning; RequiredProtocol: error: warning; success: warning" + let expected = "NetworkResults: error: warning; RequiredProtocol: error: warning, success: warning" XCTAssertEqual(config.parameterDescription?.oneLiner(), expected) } func testConsoleDescriptionReturnsNoConfiguredProtocols() { - let expected = "{Protocol Name}: {Case Name 1}: {warning|error}; {Case Name 2}: {warning|error}" + let expected = "{Protocol Name}: {Case Name 1}: {warning|error}, {Case Name 2}: {warning|error}" config.protocols.removeAll() XCTAssertEqual(config.parameterDescription?.oneLiner(), expected) diff --git a/Tests/SwiftLintFrameworkTests/RuleConfigurationDescriptionTests.swift b/Tests/SwiftLintFrameworkTests/RuleConfigurationDescriptionTests.swift index a46289ac06..c20313a705 100644 --- a/Tests/SwiftLintFrameworkTests/RuleConfigurationDescriptionTests.swift +++ b/Tests/SwiftLintFrameworkTests/RuleConfigurationDescriptionTests.swift @@ -427,7 +427,7 @@ class RuleConfigurationDescriptionTests: XCTestCase { """) XCTAssertEqual(description.oneLiner(), """ - flag: true; nested 1: integer: 2; nested 2: float: 42.1; symbol: value; string: "value" + flag: true; nested 1: integer: 2, nested 2: float: 42.1, symbol: value; string: "value" """) XCTAssertEqual(description.yaml(), """