From 60306f89ab95b87d5a61a445fdee5812e1bb8331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ba=CC=A8k?= Date: Wed, 6 Sep 2023 22:36:07 +0200 Subject: [PATCH] Remove unnecessary casting --- Sources/SwiftFormat/Rules/OmitExplicitReturns.swift | 2 +- Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftFormat/Rules/OmitExplicitReturns.swift b/Sources/SwiftFormat/Rules/OmitExplicitReturns.swift index a7391491..21f9833f 100644 --- a/Sources/SwiftFormat/Rules/OmitExplicitReturns.swift +++ b/Sources/SwiftFormat/Rules/OmitExplicitReturns.swift @@ -123,7 +123,7 @@ public final class OmitExplicitReturns: SyntaxFormatRule { } private func containsSingleReturn(_ body: CodeBlockItemListSyntax) -> ReturnStmtSyntax? { - guard let element = body.firstAndOnly?.as(CodeBlockItemSyntax.self), + guard let element = body.firstAndOnly, let returnStmt = element.item.as(ReturnStmtSyntax.self) else { return nil diff --git a/Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift b/Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift index 927070df..01de282c 100644 --- a/Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift +++ b/Sources/SwiftFormat/Rules/ReplaceForEachWithForLoop.swift @@ -29,8 +29,8 @@ public final class ReplaceForEachWithForLoop : SyntaxLintRule { return .visitChildren } - guard let memberName = member.declName.baseName.as(TokenSyntax.self), - memberName.text == "forEach" else { + let memberName = member.declName.baseName + guard memberName.text == "forEach" else { return .visitChildren }