Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
u-abyss committed Feb 11, 2024
2 parents 9e68eae + 32f813d commit ab5ebba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[#5372](https://github.com/realm/SwiftLint/issues/5372)

* Add new `ignore_one_liners` option to `switch_case_alignment`
* Add new `ignore_one_liners` option to `switch_case_alignment`
rule to ignore switch statements written in a single line.
[tonell-m](https://github.com/tonell-m)
[#5373](https://github.com/realm/SwiftLint/issues/5373)
Expand Down Expand Up @@ -108,6 +109,10 @@
[Ben P](https://github.com/ben-p-commits)
[#5263](https://github.com/realm/SwiftLint/issues/5263)

* Add new `functions_arguments_spacing` rule to remove the space before the first function argument
and after the last argument.
[u-abyss](https://github.com/u-abyss)
[#5259](https://github.com/realm/SwiftLint/issues/5224)
* Refine violation position of `superfluous_else` rule.
[SimplyDanny](https://github.com/SimplyDanny)

Expand Down
29 changes: 29 additions & 0 deletions Source/SwiftLintBuiltInRules/Rules/Idiomatic/ExplicitACLRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ struct ExplicitACLRule: OptInRule {
↓let b = 2
}
}
"""),
Example("""
public extension E {
let a = 1
struct S {
↓let b = 2
}
}
""")
]
)
Expand Down Expand Up @@ -173,7 +181,11 @@ private extension ExplicitACLRule {
}

override func visitPost(_ node: FunctionDeclSyntax) {
<<<<<<< HEAD
collectViolations(decl: node, token: node.funcKeyword)
=======
collectViolations(decl: node, token: node.staticOrClassKeyword ?? node.funcKeyword)
>>>>>>> 32f813d79349a0ad240d02e65d39fb1a71f33806
}

override func visitPost(_ node: InitializerDeclSyntax) {
Expand All @@ -195,15 +207,23 @@ private extension ExplicitACLRule {
}

override func visitPost(_ node: SubscriptDeclSyntax) {
<<<<<<< HEAD
collectViolations(decl: node, token: node.subscriptKeyword)
=======
collectViolations(decl: node, token: node.staticOrClassKeyword ?? node.subscriptKeyword)
>>>>>>> 32f813d79349a0ad240d02e65d39fb1a71f33806
}

override func visitPost(_ node: TypeAliasDeclSyntax) {
collectViolations(decl: node, token: node.typealiasKeyword)
}

override func visitPost(_ node: VariableDeclSyntax) {
<<<<<<< HEAD
collectViolations(decl: node, token: node.bindingSpecifier)
=======
collectViolations(decl: node, token: node.staticOrClassKeyword ?? node.bindingSpecifier)
>>>>>>> 32f813d79349a0ad240d02e65d39fb1a71f33806
}

private func collectViolations(decl: some WithModifiersSyntax, token: TokenSyntax) {
Expand All @@ -212,5 +232,14 @@ private extension ExplicitACLRule {
violations.append(token.positionAfterSkippingLeadingTrivia)
}
}
<<<<<<< HEAD
=======
}
}

private extension WithModifiersSyntax {
var staticOrClassKeyword: TokenSyntax? {
modifiers.first { [.keyword(.static), .keyword(.class)].contains($0.name.tokenKind) }?.name
>>>>>>> 32f813d79349a0ad240d02e65d39fb1a71f33806
}
}
20 changes: 0 additions & 20 deletions Source/SwiftLintBuiltInRules/Rules/Style/SuperfluousElseRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,38 +281,22 @@ private extension SuperfluousElseRule {

override func visit(_ list: CodeBlockItemListSyntax) -> CodeBlockItemListSyntax {
var newStatements = CodeBlockItemListSyntax()
<<<<<<< HEAD
var ifExprRewritten = false
for item in list {
guard let ifExpr = item.item.as(ExpressionStmtSyntax.self)?.expression.as(IfExprSyntax.self),
let elseKeyword = ifExpr.superfluousElse,
=======
var ifStmtRewritten = false
for item in list {
guard let ifStmt = item.item.as(ExpressionStmtSyntax.self)?.expression.as(IfExprSyntax.self),
let elseKeyword = ifStmt.superfluousElse,
>>>>>>> 5c5bff12 (Refine violation positions of `superfluous_else` rule (#5420))
!elseKeyword.isContainedIn(regions: disabledRegions, locationConverter: locationConverter) else {
newStatements.append(item)
continue
}
<<<<<<< HEAD
ifExprRewritten = true
let (newIfStm, removedItems) = modify(ifExpr: ifExpr)
=======
ifStmtRewritten = true
let (newIfStm, removedItems) = modify(ifStmt: ifStmt)
>>>>>>> 5c5bff12 (Refine violation positions of `superfluous_else` rule (#5420))
newStatements.append(
CodeBlockItemSyntax(item: CodeBlockItemSyntax.Item(ExpressionStmtSyntax(expression: newIfStm)))
)
newStatements.append(contentsOf: removedItems)
}
<<<<<<< HEAD
return ifExprRewritten ? visit(newStatements) : super.visit(newStatements)
=======
return ifStmtRewritten ? visit(newStatements) : super.visit(newStatements)
>>>>>>> 5c5bff12 (Refine violation positions of `superfluous_else` rule (#5420))
}

private func modify(ifExpr: IfExprSyntax) -> (newIfExpr: IfExprSyntax, removedItems: [CodeBlockItemSyntax]) {
Expand Down Expand Up @@ -353,11 +337,7 @@ private extension IfExprSyntax {
if elseKeyword == nil {
return nil
}
<<<<<<< HEAD
if !lastStatementExitsScope(in: body) {
=======
if !lastStatementReturns(in: body) {
>>>>>>> 5c5bff12 (Refine violation positions of `superfluous_else` rule (#5420))
return nil
}
if let parent = parent?.as(IfExprSyntax.self) {
Expand Down
1 change: 0 additions & 1 deletion Tests/SwiftLintFrameworkTests/NestingRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

private let detectingTypes = ["actor", "class", "struct", "enum"]

// swiftlint:disable:next type_body_length
class NestingRuleTests: SwiftLintTestCase {
// swiftlint:disable:next function_body_length
func testNestingWithAlwaysAllowOneTypeInFunctions() {
Expand Down

0 comments on commit ab5ebba

Please sign in to comment.