diff --git a/CHANGELOG.md b/CHANGELOG.md index bb32d2899b..968431bc00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,12 @@ [Martin Redington](https://github.com/mildm8nnered) [#5660](https://github.com/realm/SwiftLint/issues/5660) +* Fix `opening_brace` correction and make sure that disable commands + are taken into account before applying a fix. + [swiftty](https://github.com/swiftty) + [SimplyDanny](https://github.com/SimplyDanny) + [#5598](https://github.com/realm/SwiftLint/issues/5598) + ## 0.55.1: Universal Washing Powder #### Breaking diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/OpeningBraceRuleExamples.swift b/Source/SwiftLintBuiltInRules/Rules/Style/OpeningBraceRuleExamples.swift index 37d05fb1b2..f144b6c8c5 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/OpeningBraceRuleExamples.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/OpeningBraceRuleExamples.swift @@ -546,5 +546,25 @@ struct OpeningBraceRuleExamples { return } """), + // https://github.com/realm/SwiftLint/issues/5598 + Example(""" + func foo() { + if q1, q2 + { + do1() + } else if q3, q4 + { + do2() + } + } + """): Example(""" + func foo() { + if q1, q2 { + do1() + } else if q3, q4 { + do2() + } + } + """), ] } diff --git a/Tests/SwiftLintTestHelpers/TestHelpers.swift b/Tests/SwiftLintTestHelpers/TestHelpers.swift index 5418b7377e..7c965b4642 100644 --- a/Tests/SwiftLintTestHelpers/TestHelpers.swift +++ b/Tests/SwiftLintTestHelpers/TestHelpers.swift @@ -216,9 +216,13 @@ private extension Configuration { let linter = collecter.collect(into: storage) let corrections = linter.correct(using: storage).sorted { $0.location < $1.location } if expectedLocations.isEmpty { - XCTAssertEqual( - corrections.count, before.code != expected.code ? 1 : 0, #function + ".expectedLocationsEmpty", - file: before.file, line: before.line) + XCTAssertGreaterThanOrEqual( + corrections.count, + before.code != expected.code ? 1 : 0, + #function + ".expectedLocationsEmpty", + file: before.file, + line: before.line + ) } else { XCTAssertEqual( corrections.count,