Don't skip partially ignored arguments lists

This commit is contained in:
Nick Lockwood
2020-04-25 10:34:07 +01:00
parent 50eab67cde
commit 034df64984
8 changed files with 25 additions and 8 deletions
+1 -1
View File
@@ -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,
@@ -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)
+1 -1
View File
@@ -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
}
@@ -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
}
+5 -3
View File
@@ -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 != "_" {
+2 -1
View File
@@ -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)
}
}
+12
View File
@@ -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() {
+2
View File
@@ -1259,6 +1259,8 @@ extension RulesTests {
("testParensRemovedBeforeTrailingClosure3", testParensRemovedBeforeTrailingClosure3),
("testParensRemovedBeforeTrailingClosureInsideHashIf", testParensRemovedBeforeTrailingClosureInsideHashIf),
("testParensRemovedOnLineAfterSelectorIdentifier", testParensRemovedOnLineAfterSelectorIdentifier),
("testPartiallyMarkedUnusedArguments", testPartiallyMarkedUnusedArguments),
("testPartiallyMarkedUnusedArguments2", testPartiallyMarkedUnusedArguments2),
("testPerformBatchUpdatesNotMadeTrailing", testPerformBatchUpdatesNotMadeTrailing),
("testPInExponentialNotConvertedToLower", testPInExponentialNotConvertedToLower),
("testPInExponentialNotConvertedToUpper", testPInExponentialNotConvertedToUpper),