mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
Added init-only option for redundantSelf
This commit is contained in:
@@ -146,7 +146,7 @@ func printHelp(as type: CLI.OutputType) {
|
||||
--patternlet let/var placement in patterns. "hoist" (default) or "inline"
|
||||
--ranges spacing for ranges. "spaced" (default) or "nospace"
|
||||
--semicolons allow semicolons. "never" or "inline" (default)
|
||||
--self use self for member variables. "remove" (default) or "insert"
|
||||
--self explicit self. "insert", "remove" (default) or "init-only"
|
||||
--importgrouping "testable-top", "testable-bottom" or "alphabetized" (default)
|
||||
--stripunusedargs "closure-only", "unnamed-only" or "always" (default)
|
||||
--trimwhitespace trim trailing space. "always" (default) or "nonblank-lines"
|
||||
|
||||
@@ -729,7 +729,8 @@ public func inferFormatOptions(from tokens: [Token]) -> FormatOptions {
|
||||
}
|
||||
}()
|
||||
|
||||
options.removeSelf = {
|
||||
// TODO: handle init-only case
|
||||
options.explicitSelf = {
|
||||
var removed = 0, unremoved = 0
|
||||
|
||||
var typeStack = [String]()
|
||||
@@ -1166,7 +1167,7 @@ public func inferFormatOptions(from tokens: [Token]) -> FormatOptions {
|
||||
}
|
||||
var index = 0
|
||||
processBody(at: &index, localNames: ["init"], members: [], isTypeRoot: false)
|
||||
return removed >= unremoved // if both zero or equal, should be true
|
||||
return removed >= unremoved ? .remove : .insert // if both zero or equal, should be true
|
||||
}()
|
||||
|
||||
options.spaceAroundOperatorDeclarations = {
|
||||
|
||||
+10
-3
@@ -171,6 +171,13 @@ public enum ImportGrouping: String {
|
||||
case testableBottom = "testable-bottom"
|
||||
}
|
||||
|
||||
/// Self insertion mode
|
||||
public enum SelfMode: String {
|
||||
case insert
|
||||
case remove
|
||||
case initOnly = "init-only"
|
||||
}
|
||||
|
||||
/// Configuration options for formatting. These aren't actually used by the
|
||||
/// Formatter class itself, but it makes them available to the format rules.
|
||||
public struct FormatOptions: CustomStringConvertible {
|
||||
@@ -203,7 +210,7 @@ public struct FormatOptions: CustomStringConvertible {
|
||||
public var hoistPatternLet: Bool
|
||||
public var stripUnusedArguments: ArgumentStrippingMode
|
||||
public var elseOnNextLine: Bool
|
||||
public var removeSelf: Bool
|
||||
public var explicitSelf: SelfMode
|
||||
public var experimentalRules: Bool
|
||||
public var fragment: Bool
|
||||
public var importGrouping: ImportGrouping
|
||||
@@ -242,7 +249,7 @@ public struct FormatOptions: CustomStringConvertible {
|
||||
hoistPatternLet: Bool = true,
|
||||
stripUnusedArguments: ArgumentStrippingMode = .all,
|
||||
elseOnNextLine: Bool = false,
|
||||
removeSelf: Bool = true,
|
||||
explicitSelf: SelfMode = .remove,
|
||||
experimentalRules: Bool = false,
|
||||
fragment: Bool = false,
|
||||
ignoreConflictMarkers: Bool = false,
|
||||
@@ -276,7 +283,7 @@ public struct FormatOptions: CustomStringConvertible {
|
||||
self.hoistPatternLet = hoistPatternLet
|
||||
self.stripUnusedArguments = stripUnusedArguments
|
||||
self.elseOnNextLine = elseOnNextLine
|
||||
self.removeSelf = removeSelf
|
||||
self.explicitSelf = explicitSelf
|
||||
self.experimentalRules = experimentalRules
|
||||
self.fragment = fragment
|
||||
self.ignoreConflictMarkers = ignoreConflictMarkers
|
||||
|
||||
@@ -198,7 +198,7 @@ extension FormatOptions.Descriptor {
|
||||
letPatternPlacement,
|
||||
stripUnusedArguments,
|
||||
elsePosition,
|
||||
removeSelf,
|
||||
explicitSelf,
|
||||
importGrouping,
|
||||
|
||||
// Deprecated
|
||||
@@ -445,15 +445,13 @@ extension FormatOptions.Descriptor {
|
||||
trueValues: ["next-line", "nextline"],
|
||||
falseValues: ["same-line", "sameline"]
|
||||
)
|
||||
static let removeSelf = FormatOptions.Descriptor(
|
||||
static let explicitSelf = FormatOptions.Descriptor(
|
||||
argumentName: "self",
|
||||
propertyName: "removeSelf",
|
||||
propertyName: "explicitSelf",
|
||||
displayName: "Self",
|
||||
keyPath: \.removeSelf,
|
||||
trueValues: ["remove"],
|
||||
falseValues: ["insert"]
|
||||
keyPath: \.explicitSelf,
|
||||
options: ["insert", "remove", "init-only"]
|
||||
)
|
||||
|
||||
static let importGrouping = FormatOptions.Descriptor(
|
||||
argumentName: "importgrouping",
|
||||
propertyName: "importGrouping",
|
||||
|
||||
+30
-19
@@ -2069,13 +2069,18 @@ extension FormatRules {
|
||||
index += 1
|
||||
}
|
||||
}
|
||||
func processBody(at index: inout Int, localNames: Set<String>, members: Set<String>, isTypeRoot: Bool) {
|
||||
let explicitSelf = formatter.options.explicitSelf
|
||||
func processBody(at index: inout Int,
|
||||
localNames: Set<String>,
|
||||
members: Set<String>,
|
||||
isTypeRoot: Bool,
|
||||
isInit: Bool) {
|
||||
let currentScope = formatter.currentScope(at: index)
|
||||
let isWhereClause = index > 0 && formatter.tokens[index - 1] == .keyword("where")
|
||||
assert(isWhereClause || currentScope.map { token -> Bool in
|
||||
[.startOfScope("{"), .startOfScope(":")].contains(token)
|
||||
} ?? true)
|
||||
if formatter.options.removeSelf {
|
||||
if explicitSelf == .remove {
|
||||
// Check if scope actually includes self before we waste a bunch of time
|
||||
var scopeCount = 0
|
||||
loop: for i in index ..< formatter.tokens.count {
|
||||
@@ -2100,7 +2105,7 @@ extension FormatRules {
|
||||
var members = type.flatMap { membersByType[$0] } ?? members
|
||||
var classMembers = type.flatMap { classMembersByType[$0] } ?? Set<String>()
|
||||
var localNames = localNames
|
||||
if !isTypeRoot || !formatter.options.removeSelf {
|
||||
if !isTypeRoot || explicitSelf != .remove {
|
||||
var i = index
|
||||
var classOrStatic = false
|
||||
outer: while let token = formatter.token(at: i) {
|
||||
@@ -2218,7 +2223,7 @@ extension FormatRules {
|
||||
}
|
||||
index = scopeStart + 1
|
||||
typeStack.append(name)
|
||||
processBody(at: &index, localNames: ["init"], members: [], isTypeRoot: true)
|
||||
processBody(at: &index, localNames: ["init"], members: [], isTypeRoot: true, isInit: false)
|
||||
typeStack.removeLast()
|
||||
case .keyword("var"), .keyword("let"):
|
||||
index += 1
|
||||
@@ -2246,7 +2251,7 @@ extension FormatRules {
|
||||
return // error
|
||||
}
|
||||
index = startIndex + 1
|
||||
processBody(at: &index, localNames: scopedNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: scopedNames, members: members, isTypeRoot: false, isInit: isInit)
|
||||
lastKeyword = ""
|
||||
default:
|
||||
lastKeyword = token.string
|
||||
@@ -2265,7 +2270,7 @@ extension FormatRules {
|
||||
}
|
||||
}
|
||||
index += 1
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false, isInit: isInit)
|
||||
continue
|
||||
case .keyword("while") where lastKeyword == "repeat":
|
||||
lastKeyword = ""
|
||||
@@ -2296,7 +2301,7 @@ extension FormatRules {
|
||||
var localNames = localNames
|
||||
localNames.insert("error") // Implicit error argument
|
||||
index += 1
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false, isInit: isInit)
|
||||
continue
|
||||
case .startOfScope("{") where lastKeyword == "in":
|
||||
lastKeyword = ""
|
||||
@@ -2313,10 +2318,10 @@ extension FormatRules {
|
||||
index += 1
|
||||
if classOrStatic {
|
||||
assert(isTypeRoot)
|
||||
processBody(at: &index, localNames: localNames, members: classMembers, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: classMembers, isTypeRoot: false, isInit: false)
|
||||
classOrStatic = false
|
||||
} else {
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false, isInit: isInit)
|
||||
}
|
||||
continue
|
||||
case .startOfScope("{") where isWhereClause:
|
||||
@@ -2332,7 +2337,7 @@ extension FormatRules {
|
||||
switch token {
|
||||
case .endOfScope("case"), .endOfScope("default"):
|
||||
let localNames = localNames
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false, isInit: isInit)
|
||||
index -= 1
|
||||
case .endOfScope("}"):
|
||||
break loop
|
||||
@@ -2345,7 +2350,7 @@ extension FormatRules {
|
||||
fallthrough
|
||||
case .startOfScope("{") where lastKeyword == "repeat":
|
||||
index += 1
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false, isInit: isInit)
|
||||
continue
|
||||
case .startOfScope("{") where lastKeyword == "var":
|
||||
lastKeyword = ""
|
||||
@@ -2377,7 +2382,7 @@ extension FormatRules {
|
||||
case .startOfScope:
|
||||
index = formatter.endOfScope(at: index) ?? (formatter.tokens.count - 1)
|
||||
case .identifier("self") where !isTypeRoot:
|
||||
if formatter.isEnabled, formatter.options.removeSelf,
|
||||
if formatter.isEnabled, explicitSelf == .remove || (explicitSelf == .initOnly && !isInit),
|
||||
formatter.last(.nonSpaceOrCommentOrLinebreak, before: index)?.isOperator(".") == false,
|
||||
let dotIndex = formatter.index(of: .nonSpaceOrLinebreak, after: index, if: {
|
||||
$0 == .operator(".", .infix)
|
||||
@@ -2396,7 +2401,9 @@ extension FormatRules {
|
||||
}), formatter.next(.nonSpaceOrCommentOrLinebreak, after: parenIndex) == .identifier("of") else {
|
||||
fallthrough
|
||||
}
|
||||
case .identifier where formatter.isEnabled && !formatter.options.removeSelf && !isTypeRoot:
|
||||
case .identifier where formatter.isEnabled && !isTypeRoot &&
|
||||
(explicitSelf == .insert || (explicitSelf == .initOnly && isInit &&
|
||||
formatter.next(.nonSpaceOrCommentOrLinebreak, after: index) == .operator("=", .infix))):
|
||||
let name = token.unescaped()
|
||||
if members.contains(name), !localNames.contains(name), !["for", "var", "let"].contains(lastKeyword) {
|
||||
if let lastToken = formatter.last(.nonSpaceOrCommentOrLinebreak, before: index),
|
||||
@@ -2459,7 +2466,7 @@ extension FormatRules {
|
||||
break
|
||||
}
|
||||
}
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false, isInit: false)
|
||||
}
|
||||
if foundAccessors {
|
||||
guard let endIndex = formatter.index(of: .endOfScope("}"), after: index) else { return }
|
||||
@@ -2467,11 +2474,11 @@ extension FormatRules {
|
||||
} else {
|
||||
index += 1
|
||||
localNames.insert(name)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false, isInit: false)
|
||||
}
|
||||
}
|
||||
func processFunction(at index: inout Int, localNames: Set<String>, members: Set<String>) {
|
||||
let isSubscript = (formatter.tokens[index] == .keyword("subscript"))
|
||||
let startToken = formatter.tokens[index]
|
||||
var localNames = localNames
|
||||
guard let startIndex = formatter.index(of: .startOfScope("("), after: index),
|
||||
let endIndex = formatter.index(of: .endOfScope(")"), after: startIndex) else { return }
|
||||
@@ -2512,16 +2519,20 @@ extension FormatRules {
|
||||
}), formatter.tokens[bodyStartIndex] == .startOfScope("{") else {
|
||||
return
|
||||
}
|
||||
if isSubscript {
|
||||
if startToken == .keyword("subscript") {
|
||||
index = bodyStartIndex
|
||||
processAccessors(["get", "set"], for: "", at: &index, localNames: localNames, members: members)
|
||||
} else {
|
||||
index = bodyStartIndex + 1
|
||||
processBody(at: &index, localNames: localNames, members: members, isTypeRoot: false)
|
||||
processBody(at: &index,
|
||||
localNames: localNames,
|
||||
members: members,
|
||||
isTypeRoot: false,
|
||||
isInit: startToken == .keyword("init"))
|
||||
}
|
||||
}
|
||||
var index = 0
|
||||
processBody(at: &index, localNames: ["init"], members: [], isTypeRoot: false)
|
||||
processBody(at: &index, localNames: ["init"], members: [], isTypeRoot: false, isInit: false)
|
||||
}
|
||||
|
||||
/// Replace unused arguments with an underscore
|
||||
|
||||
@@ -467,7 +467,7 @@ class InferenceTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let options = inferFormatOptions(from: tokenize(input))
|
||||
XCTAssertFalse(options.removeSelf)
|
||||
XCTAssertEqual(options.explicitSelf, .insert)
|
||||
}
|
||||
|
||||
func testInferRemoveSelf() {
|
||||
@@ -482,7 +482,7 @@ class InferenceTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let options = inferFormatOptions(from: tokenize(input))
|
||||
XCTAssertTrue(options.removeSelf)
|
||||
XCTAssertEqual(options.explicitSelf, .remove)
|
||||
}
|
||||
|
||||
func testInferRemoveSelf2() {
|
||||
@@ -497,7 +497,7 @@ class InferenceTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let options = inferFormatOptions(from: tokenize(input))
|
||||
XCTAssertTrue(options.removeSelf)
|
||||
XCTAssertEqual(options.explicitSelf, .remove)
|
||||
}
|
||||
|
||||
// MARK: spaceAroundOperatorDeclarations
|
||||
|
||||
@@ -376,16 +376,17 @@ class OptionsDescriptorTests: XCTestCase {
|
||||
validateDescriptorThrowsOptionsError(descriptor)
|
||||
}
|
||||
|
||||
func testRemoveSelf() {
|
||||
let descriptor = FormatOptions.Descriptor.removeSelf
|
||||
let fromOptionsExpectation: [OptionArgumentMapping<Bool>] = [
|
||||
(optionValue: true, argumentValue: "remove"),
|
||||
(optionValue: false, argumentValue: "insert"),
|
||||
func testExplicitSelf() {
|
||||
let descriptor = FormatOptions.Descriptor.explicitSelf
|
||||
let expectedMapping: [OptionArgumentMapping<SelfMode>] = [
|
||||
(optionValue: .remove, argumentValue: "remove"),
|
||||
(optionValue: .insert, argumentValue: "insert"),
|
||||
(optionValue: .initOnly, argumentValue: "init-only"),
|
||||
]
|
||||
validateDescriptor(descriptor, displayName: "Self", argumentName: "self", propertyName: "removeSelf")
|
||||
validateArgumentsBinaryType(descriptor, controlTrue: ["remove"], controlFalse: ["insert"])
|
||||
validateFromOptions(descriptor, keyPath: \FormatOptions.removeSelf, expectations: fromOptionsExpectation)
|
||||
validateFromArgumentsBinaryType(descriptor, keyPath: \FormatOptions.removeSelf)
|
||||
validateDescriptor(descriptor, displayName: "Self", argumentName: "self", propertyName: "explicitSelf")
|
||||
validateArgumentsListType(descriptor, validArguments: ["remove", "insert", "init-only"])
|
||||
validateFromOptions(descriptor, keyPath: \FormatOptions.explicitSelf, expectations: expectedMapping)
|
||||
validateFromArguments(descriptor, keyPath: \FormatOptions.explicitSelf, expectations: expectedMapping)
|
||||
validateDescriptorThrowsOptionsError(descriptor)
|
||||
}
|
||||
|
||||
|
||||
+141
-69
@@ -4685,7 +4685,7 @@ class RulesTests: XCTestCase {
|
||||
|
||||
// MARK: redundantSelf
|
||||
|
||||
// removeSelf = true
|
||||
// explicitSelf = .remove
|
||||
|
||||
func testSimpleRemoveRedundantSelf() {
|
||||
let input = "func foo() { self.bar() }"
|
||||
@@ -5203,9 +5203,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSwitchCaseLetVarRecognized() {
|
||||
@@ -5218,9 +5217,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSwitchCaseHoistedLetVarRecognized() {
|
||||
@@ -5233,9 +5231,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSwitchCaseWhereMemberNotTreatedAsVar() {
|
||||
@@ -5253,9 +5250,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSelfNotRemovedInClosureAfterSwitch() {
|
||||
@@ -5272,9 +5268,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSelfNotRemovedInClosureInCaseWithWhereClause() {
|
||||
@@ -5285,9 +5280,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSelfRemovedInDidSet() {
|
||||
@@ -5309,9 +5303,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSelfNotRemovedInGetter() {
|
||||
@@ -5323,9 +5316,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testSelfNotRemovedInIfdef() {
|
||||
@@ -5337,17 +5329,16 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf]), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
// removeSelf = false
|
||||
// explicitSelf = .insert
|
||||
|
||||
func testInsertSelf() {
|
||||
let input = "class Foo {\n let foo: Int\n init() { foo = 5 }\n}"
|
||||
let output = "class Foo {\n let foo: Int\n init() { self.foo = 5 }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5355,7 +5346,7 @@ class RulesTests: XCTestCase {
|
||||
func testInsertSelfAfterReturn() {
|
||||
let input = "class Foo {\n let foo: Int\n func bar() -> Int { return foo }\n}"
|
||||
let output = "class Foo {\n let foo: Int\n func bar() -> Int { return self.foo }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5363,7 +5354,7 @@ class RulesTests: XCTestCase {
|
||||
func testInsertSelfInsideStringInterpolation() {
|
||||
let input = "class Foo {\n var bar: String?\n func baz() {\n print(\"\\(bar)\")\n }\n}"
|
||||
let output = "class Foo {\n var bar: String?\n func baz() {\n print(\"\\(self.bar)\")\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5371,7 +5362,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInterpretGenericTypesAsMembers() {
|
||||
let input = "class Foo {\n let foo: Bar<Int, Int>\n init() { self.foo = Int(5) }\n}"
|
||||
let output = "class Foo {\n let foo: Bar<Int, Int>\n init() { self.foo = Int(5) }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5379,7 +5370,7 @@ class RulesTests: XCTestCase {
|
||||
func testInsertSelfForStaticMemberInClassFunction() {
|
||||
let input = "class Foo {\n static var foo: Int\n class func bar() { foo = 5 }\n}"
|
||||
let output = "class Foo {\n static var foo: Int\n class func bar() { self.foo = 5 }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5387,7 +5378,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForInstanceMemberInClassFunction() {
|
||||
let input = "class Foo {\n var foo: Int\n class func bar() { foo = 5 }\n}"
|
||||
let output = "class Foo {\n var foo: Int\n class func bar() { foo = 5 }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5395,7 +5386,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForStaticMemberInInstanceFunction() {
|
||||
let input = "class Foo {\n static var foo: Int\n func bar() { foo = 5 }\n}"
|
||||
let output = "class Foo {\n static var foo: Int\n func bar() { foo = 5 }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5403,7 +5394,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForShadowedClassMemberInClassFunction() {
|
||||
let input = "class Foo {\n class func foo() {\n var foo: Int\n func bar() { foo = 5 }\n }\n}"
|
||||
let output = "class Foo {\n class func foo() {\n var foo: Int\n func bar() { foo = 5 }\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5411,7 +5402,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfInForLoopTuple() {
|
||||
let input = "class Foo {\n var bar: Int\n func foo() { for (bar, baz) in quux {} }\n}"
|
||||
let output = "class Foo {\n var bar: Int\n func foo() { for (bar, baz) in quux {} }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5419,7 +5410,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForTupleTypeMembers() {
|
||||
let input = "class Foo {\n var foo: (Int, UIColor) {\n let bar = UIColor.red\n }\n}"
|
||||
let output = "class Foo {\n var foo: (Int, UIColor) {\n let bar = UIColor.red\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5427,7 +5418,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForArrayElements() {
|
||||
let input = "class Foo {\n var foo = [1, 2, nil]\n func bar() { baz(nil) }\n}"
|
||||
let output = "class Foo {\n var foo = [1, 2, nil]\n func bar() { baz(nil) }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5435,7 +5426,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForNestedVarReference() {
|
||||
let input = "class Foo {\n func bar() {\n var bar = 5\n repeat { bar = 6 } while true\n }\n}"
|
||||
let output = "class Foo {\n func bar() {\n var bar = 5\n repeat { bar = 6 } while true\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5443,7 +5434,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfInSwitchCaseLet() {
|
||||
let input = "class Foo {\n var foo: Bar? {\n switch bar {\n case let .baz(foo, _):\n return nil\n }\n }\n}"
|
||||
let output = "class Foo {\n var foo: Bar? {\n switch bar {\n case let .baz(foo, _):\n return nil\n }\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5451,7 +5442,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfInFuncAfterImportedClass() {
|
||||
let input = "import class Foo.Bar\nfunc foo() {\n var bar = 5\n if true {\n bar = 6\n }\n}"
|
||||
let output = "import class Foo.Bar\nfunc foo() {\n var bar = 5\n if true {\n bar = 6\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5459,7 +5450,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForSubscriptGetSet() {
|
||||
let input = "class Foo {\n func get() {}\n func set() {}\n subscript(key: String) -> String {\n get { return get(key) }\n set { set(key, newValue) }\n }\n}"
|
||||
let output = "class Foo {\n func get() {}\n func set() {}\n subscript(key: String) -> String {\n get { return self.get(key) }\n set { self.set(key, newValue) }\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5467,7 +5458,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfInIfCaseLet() {
|
||||
let input = "enum Foo {\n case bar(Int)\n var value: Int? {\n if case let .bar(value) = self { return value }\n }\n}"
|
||||
let output = "enum Foo {\n case bar(Int)\n var value: Int? {\n if case let .bar(value) = self { return value }\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5475,7 +5466,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForPatternLet() {
|
||||
let input = "class Foo {\n func foo() {}\n func bar() {\n switch x {\n case .bar(let foo, var bar): print(foo + bar)\n }\n }\n}"
|
||||
let output = "class Foo {\n func foo() {}\n func bar() {\n switch x {\n case .bar(let foo, var bar): print(foo + bar)\n }\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5483,7 +5474,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForPatternLet2() {
|
||||
let input = "class Foo {\n func foo() {}\n func bar() {\n switch x {\n case let .foo(baz): print(baz)\n case .bar(let foo, var bar): print(foo + bar)\n }\n }\n}"
|
||||
let output = "class Foo {\n func foo() {}\n func bar() {\n switch x {\n case let .foo(baz): print(baz)\n case .bar(let foo, var bar): print(foo + bar)\n }\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5491,7 +5482,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForTypeOf() {
|
||||
let input = "class Foo {\n var type: String?\n func bar() {\n print(\"\\(type(of: self))\")\n }\n}"
|
||||
let output = "class Foo {\n var type: String?\n func bar() {\n print(\"\\(type(of: self))\")\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5499,7 +5490,7 @@ class RulesTests: XCTestCase {
|
||||
func testNoInsertSelfForConditionalLocal() {
|
||||
let input = "class Foo {\n func foo() {\n #if os(watchOS)\n var foo: Int\n #else\n var foo: Float\n #endif\n print(foo)\n }\n}"
|
||||
let output = "class Foo {\n func foo() {\n #if os(watchOS)\n var foo: Int\n #else\n var foo: Float\n #endif\n print(foo)\n }\n}"
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5527,7 +5518,7 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5547,7 +5538,7 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5565,7 +5556,7 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5585,7 +5576,7 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5617,7 +5608,7 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5649,7 +5640,7 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5681,7 +5672,7 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5705,7 +5696,92 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: false)
|
||||
let options = FormatOptions(explicitSelf: .insert)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
|
||||
// explicitSelf = .initOnly
|
||||
|
||||
func testPreserveSelfInsideClassInit() {
|
||||
let input = """
|
||||
class Foo {
|
||||
var bar = 5
|
||||
init() {
|
||||
self.bar = 6
|
||||
}
|
||||
}
|
||||
"""
|
||||
let output = input
|
||||
let options = FormatOptions(explicitSelf: .initOnly)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
|
||||
func testRemoveSelfIfNotInsideClassInit() {
|
||||
let input = """
|
||||
class Foo {
|
||||
var bar = 5
|
||||
func baz() {
|
||||
self.bar = 6
|
||||
}
|
||||
}
|
||||
"""
|
||||
let output = """
|
||||
class Foo {
|
||||
var bar = 5
|
||||
func baz() {
|
||||
bar = 6
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(explicitSelf: .initOnly)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
|
||||
func testInsertSelfInsideClassInit() {
|
||||
let input = """
|
||||
class Foo {
|
||||
var bar = 5
|
||||
init() {
|
||||
bar = 6
|
||||
}
|
||||
}
|
||||
"""
|
||||
let output = """
|
||||
class Foo {
|
||||
var bar = 5
|
||||
init() {
|
||||
self.bar = 6
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(explicitSelf: .initOnly)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
|
||||
func testNoInsertSelfInsideClassInitIfNotLvalue() {
|
||||
let input = """
|
||||
class Foo {
|
||||
var bar = 5
|
||||
let baz = 6
|
||||
init() {
|
||||
bar = baz
|
||||
}
|
||||
}
|
||||
"""
|
||||
let output = """
|
||||
class Foo {
|
||||
var bar = 5
|
||||
let baz = 6
|
||||
init() {
|
||||
self.bar = baz
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(explicitSelf: .initOnly)
|
||||
XCTAssertEqual(try format(input, rules: [FormatRules.redundantSelf], options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
}
|
||||
@@ -5735,9 +5811,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"]), options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"])), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testDisableNextRemoveSelf() {
|
||||
@@ -5761,9 +5836,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"]), options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"])), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testMultilineDisableRemoveSelf() {
|
||||
@@ -5785,9 +5859,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"]), options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"])), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
func testMultilineDisableNextRemoveSelf() {
|
||||
@@ -5811,9 +5884,8 @@ class RulesTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
"""
|
||||
let options = FormatOptions(removeSelf: true)
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"]), options: options), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default, options: options), output + "\n")
|
||||
XCTAssertEqual(try format(input, rules: FormatRules.all(named: ["redundantSelf"])), output)
|
||||
XCTAssertEqual(try format(input + "\n", rules: FormatRules.default), output + "\n")
|
||||
}
|
||||
|
||||
// MARK: unusedArguments
|
||||
|
||||
Reference in New Issue
Block a user