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
35 lines
1.3 KiB
Swift
35 lines
1.3 KiB
Swift
import TestHelpers
|
|
import Testing
|
|
|
|
@testable import SwiftLintBuiltInRules
|
|
|
|
@Suite(.rulesRegistered)
|
|
struct ConditionalReturnsOnNewlineRuleTests {
|
|
@Test
|
|
func conditionalReturnsOnNewlineWithIfOnly() {
|
|
// Test with `if_only` set to true
|
|
let nonTriggeringExamples = [
|
|
Example("guard true else {\n return true\n}"),
|
|
Example("guard true,\n let x = true else {\n return true\n}"),
|
|
Example("if true else {\n return true\n}"),
|
|
Example("if true,\n let x = true else {\n return true\n}"),
|
|
Example("if textField.returnKeyType == .Next {"),
|
|
Example("if true { // return }"),
|
|
Example("/*if true { */ return }"),
|
|
Example("guard true else { return }"),
|
|
]
|
|
let triggeringExamples = [
|
|
Example("↓if true { return }"),
|
|
Example("↓if true { break } else { return }"),
|
|
Example("↓if true { break } else { return }"),
|
|
Example("↓if true { return \"YES\" } else { return \"NO\" }"),
|
|
]
|
|
|
|
let description = ConditionalReturnsOnNewlineRule.description
|
|
.with(triggeringExamples: triggeringExamples)
|
|
.with(nonTriggeringExamples: nonTriggeringExamples)
|
|
|
|
verifyRule(description, ruleConfiguration: ["if_only": true])
|
|
}
|
|
}
|