-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new option
max_number_of_single_line_parameters
to `multiline_…
…parameters` rule (#5781) Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
- Loading branch information
1 parent
c784adc
commit 2a723d0
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Tests/SwiftLintFrameworkTests/MultilineParametersConfigurationTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@testable import SwiftLintBuiltInRules | ||
@testable import SwiftLintCore | ||
import XCTest | ||
|
||
final class MultilineParametersConfigurationTests: SwiftLintTestCase { | ||
func testInvalidMaxNumberOfSingleLineParameters() throws { | ||
for maxNumberOfSingleLineParameters in [0, -1] { | ||
var config = MultilineParametersConfiguration() | ||
|
||
XCTAssertEqual( | ||
try Issue.captureConsole { | ||
try config.apply( | ||
configuration: ["max_number_of_single_line_parameters": maxNumberOfSingleLineParameters] | ||
) | ||
}, | ||
""" | ||
warning: Inconsistent configuration for 'multiline_parameters' rule: Option \ | ||
'max_number_of_single_line_parameters' should be >= 1. | ||
""" | ||
) | ||
} | ||
} | ||
|
||
func testInvalidMaxNumberOfSingleLineParametersWithSingleLineEnabled() throws { | ||
var config = MultilineParametersConfiguration() | ||
|
||
XCTAssertEqual( | ||
try Issue.captureConsole { | ||
try config.apply( | ||
configuration: ["max_number_of_single_line_parameters": 2, "allows_single_line": false] | ||
) | ||
}, | ||
""" | ||
warning: Inconsistent configuration for 'multiline_parameters' rule: Option \ | ||
'max_number_of_single_line_parameters' has no effect when 'allows_single_line' is false. | ||
""" | ||
) | ||
} | ||
} |