diff --git a/Snapshots/Layout/Layout/LayoutNode.swift b/Snapshots/Layout/Layout/LayoutNode.swift index c0c8a4a9..7c741196 100755 --- a/Snapshots/Layout/Layout/LayoutNode.swift +++ b/Snapshots/Layout/Layout/LayoutNode.swift @@ -278,7 +278,7 @@ public class LayoutNode: NSObject { public override func observeValue( forKeyPath _: String?, of _: Any?, - change: [NSKeyValueChangeKey: Any]?, + change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer? ) { guard _setupComplete, _updateLock == 0, _evaluating.isEmpty, diff --git a/Snapshots/Layout/Layout/Shared/XMLParser.swift b/Snapshots/Layout/Layout/Shared/XMLParser.swift index 84e140ad..023070dd 100755 --- a/Snapshots/Layout/Layout/Shared/XMLParser.swift +++ b/Snapshots/Layout/Layout/Shared/XMLParser.swift @@ -185,7 +185,7 @@ class XMLParser: NSObject, XMLParserDelegate { top = node } - func parser(_: Foundation.XMLParser, didEndElement elementName: String, namespaceURI _: String?, qualifiedName _: String?) { + func parser(_: Foundation.XMLParser, didEndElement _: String, namespaceURI _: String?, qualifiedName _: String?) { if !top!.isHTML { if top!.children.isEmpty { text = text.trimmingCharacters(in: .whitespacesAndNewlines) diff --git a/Snapshots/Layout/Layout/UIView+Layout.swift b/Snapshots/Layout/Layout/UIView+Layout.swift index 2b624f1e..8dea2dbf 100755 --- a/Snapshots/Layout/Layout/UIView+Layout.swift +++ b/Snapshots/Layout/Layout/UIView+Layout.swift @@ -334,7 +334,7 @@ extension UIView: LayoutManaged { /// Called immediately before a child node is added /// Returning false will cancel insertion of the node - @objc open func shouldInsertChildNode(_ node: LayoutNode, at _: Int) -> Bool { + @objc open func shouldInsertChildNode(_: LayoutNode, at _: Int) -> Bool { return true } diff --git a/Snapshots/Layout/Layout/UIViewController+Layout.swift b/Snapshots/Layout/Layout/UIViewController+Layout.swift index 6d02f0b4..3906aa6c 100755 --- a/Snapshots/Layout/Layout/UIViewController+Layout.swift +++ b/Snapshots/Layout/Layout/UIViewController+Layout.swift @@ -315,7 +315,7 @@ extension UIViewController: LayoutManaged { /// Called immediately before a child node is added /// Returning false will cancel insertion of the node - @objc open func shouldInsertChildNode(_ node: LayoutNode, at _: Int) -> Bool { + @objc open func shouldInsertChildNode(_: LayoutNode, at _: Int) -> Bool { return true } diff --git a/Sources/Rules.swift b/Sources/Rules.swift index 9292571d..30839fcc 100644 --- a/Sources/Rules.swift +++ b/Sources/Rules.swift @@ -2840,9 +2840,11 @@ public struct _FormatRules { formatter.index(of: .nonSpaceOrCommentOrLinebreak, after: externalNameIndex) else { return } let nextToken = formatter.tokens[nextIndex] switch nextToken { - case let .identifier(name) where name != "_": - argNames.append(nextToken.unescaped()) - nameIndexPairs.append((externalNameIndex, nextIndex)) + case let .identifier(name): + if name != "_" { + argNames.append(nextToken.unescaped()) + nameIndexPairs.append((externalNameIndex, nextIndex)) + } case .delimiter(":"): let externalNameToken = formatter.tokens[externalNameIndex] if case let .identifier(name) = externalNameToken, name != "_" { diff --git a/Tests/CommandLineTests.swift b/Tests/CommandLineTests.swift index 915049d6..36fa9560 100644 --- a/Tests/CommandLineTests.swift +++ b/Tests/CommandLineTests.swift @@ -228,6 +228,7 @@ class CommandLineTests: XCTestCase { CLI.print = { message, _ in Swift.print(message) } - XCTAssertEqual(CLI.run(in: projectDirectory.path, with: "Snapshots --unexclude Snapshots --symlinks follow --lint --cache ignore"), .ok) + // NOTE: to update regression suite, run again without `--lint` argument + XCTAssertEqual(CLI.run(in: projectDirectory.path, with: "Snapshots --unexclude Snapshots --symlinks follow --cache ignore --lint"), .ok) } } diff --git a/Tests/RulesTests.swift b/Tests/RulesTests.swift index 92131d83..034ed018 100644 --- a/Tests/RulesTests.swift +++ b/Tests/RulesTests.swift @@ -7339,6 +7339,18 @@ class RulesTests: XCTestCase { testFormatting(for: input, rule: FormatRules.unusedArguments) } + func testPartiallyMarkedUnusedArguments() { + let input = "func foo(bar: Bar, baz _: Baz) {}" + let output = "func foo(bar _: Bar, baz _: Baz) {}" + testFormatting(for: input, output, rule: FormatRules.unusedArguments) + } + + func testPartiallyMarkedUnusedArguments2() { + let input = "func foo(bar _: Bar, baz: Baz) {}" + let output = "func foo(bar _: Bar, baz _: Baz) {}" + testFormatting(for: input, output, rule: FormatRules.unusedArguments) + } + // functions (closure-only) func testNoMarkFunctionArgument() { diff --git a/Tests/XCTestManifests.swift b/Tests/XCTestManifests.swift index e8522cfb..f1f35e0c 100644 --- a/Tests/XCTestManifests.swift +++ b/Tests/XCTestManifests.swift @@ -1259,6 +1259,8 @@ extension RulesTests { ("testParensRemovedBeforeTrailingClosure3", testParensRemovedBeforeTrailingClosure3), ("testParensRemovedBeforeTrailingClosureInsideHashIf", testParensRemovedBeforeTrailingClosureInsideHashIf), ("testParensRemovedOnLineAfterSelectorIdentifier", testParensRemovedOnLineAfterSelectorIdentifier), + ("testPartiallyMarkedUnusedArguments", testPartiallyMarkedUnusedArguments), + ("testPartiallyMarkedUnusedArguments2", testPartiallyMarkedUnusedArguments2), ("testPerformBatchUpdatesNotMadeTrailing", testPerformBatchUpdatesNotMadeTrailing), ("testPInExponentialNotConvertedToLower", testPInExponentialNotConvertedToLower), ("testPInExponentialNotConvertedToUpper", testPInExponentialNotConvertedToUpper),