mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
# Conflicts: # Tests/BuiltInRulesTests/FileHeaderRuleTests.swift # Tests/BuiltInRulesTests/FileNameNoSpaceRuleTests.swift # Tests/BuiltInRulesTests/IndentationWidthRuleTests.swift # Tests/CoreTests/RegexConfigurationTests.swift # Tests/CoreTests/SwiftLintFileTests.swift # Tests/FileSystemAccessTests/BaselineTests.swift # Tests/FileSystemAccessTests/ConfigurationTests+Mock.swift # Tests/FileSystemAccessTests/ConfigurationTests.swift # Tests/FileSystemAccessTests/GlobTests.swift # Tests/FileSystemAccessTests/MultipleConfigurationsTests.swift # Tests/FileSystemAccessTests/ReporterTests.swift # Tests/FileSystemAccessTests/SourceKitCrashTests.swift # Tests/FrameworkTests/CustomRulesTests.swift # Tests/FrameworkTests/LinterCacheTests.swift # Tests/FrameworkTests/RuleConfigurationTests.swift # Tests/FrameworkTests/SwiftVersionTests.swift # Tests/GeneratedTests/GeneratedTests_02.swift # Tests/GeneratedTests/GeneratedTests_03.swift # Tests/GeneratedTests/GeneratedTests_04.swift # Tests/GeneratedTests/GeneratedTests_05.swift # Tests/GeneratedTests/GeneratedTests_06.swift # Tests/GeneratedTests/GeneratedTests_07.swift # Tests/GeneratedTests/GeneratedTests_08.swift # Tests/GeneratedTests/GeneratedTests_09.swift # Tests/GeneratedTests/GeneratedTests_10.swift # Tests/IntegrationTests/ConfigPathResolutionTests.swift # Tests/IntegrationTests/IntegrationTests.swift # Tests/TestHelpers/TestHelpers.swift
106 lines
3.1 KiB
Swift
106 lines
3.1 KiB
Swift
import TestHelpers
|
|
import Testing
|
|
|
|
@testable import SwiftLintBuiltInRules
|
|
|
|
@Suite(.rulesRegistered)
|
|
struct MultilineArgumentsRuleTests {
|
|
@Test
|
|
func multilineArgumentsWithWithNextLine() {
|
|
let nonTriggeringExamples = [
|
|
Example("foo()"),
|
|
Example("foo(0)"),
|
|
Example("foo(1, bar: baz) { }"),
|
|
Example("foo(2, bar: baz) {\n}"),
|
|
Example("foo(\n" +
|
|
" 3,\n" +
|
|
" bar: baz) { }"),
|
|
Example("foo(\n" +
|
|
" 4, bar: baz) { }"),
|
|
]
|
|
|
|
let triggeringExamples = [
|
|
Example("foo(↓1,\n" +
|
|
" bar: baz) { }"),
|
|
]
|
|
|
|
let description = MultilineArgumentsRule.description
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["first_argument_location": "next_line"])
|
|
}
|
|
|
|
@Test
|
|
func multilineArgumentsWithWithSameLine() {
|
|
let nonTriggeringExamples = [
|
|
Example("foo()"),
|
|
Example("foo(0)"),
|
|
Example("foo(1, bar: 1) { }"),
|
|
Example("foo(2, bar: 2) {\n" +
|
|
" bar()\n" +
|
|
"}"),
|
|
Example("foo(3,\n" +
|
|
" bar: 3) { }"),
|
|
]
|
|
|
|
let triggeringExamples = [
|
|
Example("foo(\n" +
|
|
" ↓1, ↓bar: baz) { }"),
|
|
Example("foo(\n" +
|
|
" ↓2,\n" +
|
|
" bar: baz) { }"),
|
|
]
|
|
|
|
let description = MultilineArgumentsRule.description
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["first_argument_location": "same_line"])
|
|
}
|
|
|
|
@Test
|
|
func multilineArgumentsWithOnlyEnforceAfterFirstClosureOnFirstLine() {
|
|
let nonTriggeringExamples: [Example] = [
|
|
Example("foo()"),
|
|
Example("foo(0)"),
|
|
Example("foo(1, bar: 1) { }"),
|
|
Example("foo(\n" +
|
|
" 4, bar: baz) { }"),
|
|
Example("foo(a: a, b: {\n" +
|
|
"}, c: {\n" +
|
|
"})"),
|
|
Example("foo(\n" +
|
|
" a: a, b: {\n" +
|
|
" }, c: {\n" +
|
|
"})"),
|
|
Example("foo(a: a, b: b, c: {\n" +
|
|
"}, d: {\n" +
|
|
"})"),
|
|
Example("foo(\n" +
|
|
" a: a, b: b, c: {\n" +
|
|
" }, d: {\n" +
|
|
"})"),
|
|
Example("foo(a: a, b: { [weak self] in\n" +
|
|
"}, c: { flag in\n" +
|
|
"})"),
|
|
]
|
|
|
|
let triggeringExamples = [
|
|
Example("foo(a: a,\n" +
|
|
" b: b, c: {\n" +
|
|
"})"),
|
|
Example("foo(a: a, b: b,\n" +
|
|
" c: c, d: {\n" +
|
|
" }, d: {\n" +
|
|
"})"),
|
|
]
|
|
|
|
let description = MultilineArgumentsRule.description
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["only_enforce_after_first_closure_on_first_line": true])
|
|
}
|
|
}
|