mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
Don't skip partially ignored arguments lists
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
@@ -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 != "_" {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1259,6 +1259,8 @@ extension RulesTests {
|
||||
("testParensRemovedBeforeTrailingClosure3", testParensRemovedBeforeTrailingClosure3),
|
||||
("testParensRemovedBeforeTrailingClosureInsideHashIf", testParensRemovedBeforeTrailingClosureInsideHashIf),
|
||||
("testParensRemovedOnLineAfterSelectorIdentifier", testParensRemovedOnLineAfterSelectorIdentifier),
|
||||
("testPartiallyMarkedUnusedArguments", testPartiallyMarkedUnusedArguments),
|
||||
("testPartiallyMarkedUnusedArguments2", testPartiallyMarkedUnusedArguments2),
|
||||
("testPerformBatchUpdatesNotMadeTrailing", testPerformBatchUpdatesNotMadeTrailing),
|
||||
("testPInExponentialNotConvertedToLower", testPInExponentialNotConvertedToLower),
|
||||
("testPInExponentialNotConvertedToUpper", testPInExponentialNotConvertedToUpper),
|
||||
|
||||
Reference in New Issue
Block a user