Skip to content

Commit 3e451ef

Browse files
committed
Fix warning to use CollectionType method instead
1 parent 6aa70af commit 3e451ef

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Sources/SwiftFormatRules/DoNotUseSemicolons.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ public final class DoNotUseSemicolons: SyntaxFormatRule {
7474
// 'while' statement.
7575
if Syntax(item).as(CodeBlockItemSyntax.self)?
7676
.children(viewMode: .sourceAccurate).first?.is(DoStmtSyntax.self) == true,
77-
idx < node.count - 1
77+
idx < node.count - 1,
78+
let childrenIdx = node.index(of: item)
7879
{
7980
let children = node.children(viewMode: .sourceAccurate)
80-
let nextItem = children[children.index(after: item.index)]
81+
let nextItem = children[children.index(after: childrenIdx)]
8182
if Syntax(nextItem).as(CodeBlockItemSyntax.self)?
8283
.children(viewMode: .sourceAccurate).first?.is(WhileStmtSyntax.self) == true
8384
{

Sources/SwiftFormatRules/UseWhereClausesInForLoops.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public final class UseWhereClausesInForLoops: SyntaxFormatRule {
8585
return updateWithWhereCondition(
8686
node: forInStmt,
8787
condition: condition,
88-
statements: forInStmt.body.statements.removingFirst()
88+
statements: CodeBlockItemListSyntax(forInStmt.body.statements.dropFirst())
8989
)
9090

9191
default:

0 commit comments

Comments
 (0)