From 21446f1c92b790b52b007b625152488b599139c3 Mon Sep 17 00:00:00 2001 From: Alfons Hoogervorst Date: Tue, 13 May 2025 06:02:10 +0200 Subject: [PATCH] Clean up merge warnings --- .../Rules/Idiomatic/ReduceIntoInsteadOfLoopRule.swift | 4 ++-- .../Idiomatic/ReduceIntoInsteadOfLoopRuleExamples.swift | 6 +++--- .../Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleModels.swift | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRule.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRule.swift index b5f6431bf9..762d9ee3a8 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRule.swift @@ -62,7 +62,7 @@ internal extension ReduceIntoInsteadOfLoopRule { ] static let collectionNames: [String: CollectionType] = - ReduceIntoInsteadOfLoopRule.collectionTypes.reduce(into: [String: CollectionType]()) { partialResult, type in + ReduceIntoInsteadOfLoopRule.collectionTypes.reduce(into: [:]) { partialResult, type in partialResult[type.name] = type } } @@ -73,7 +73,7 @@ private extension CodeBlockItemListSyntax { typealias IndexRange = Range typealias IndexRangeForStmts = (range: IndexRange, forStmt: ForStmtSyntax) // Collect all ForInStmts and track their index ranges - let indexRangeForStatements: [IndexRangeForStmts] = self.reduce(into: [IndexRangeForStmts]()) { partialResult, codeBlockItem in + let indexRangeForStatements: [IndexRangeForStmts] = self.reduce(into: []) { partialResult, codeBlockItem in guard let codeBlockItemIndex = self.index(of: codeBlockItem) else { return } diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleExamples.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleExamples.swift index ddfa1f31fd..d5641bdbb8 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleExamples.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleExamples.swift @@ -1,17 +1,17 @@ struct ReduceIntoInsteadOfLoopRuleExamples { static let nonTriggeringExamples: [Example] = [ Example(""" - let encountered: Array = someSequence.reduce(into: Array(), { result, eachN in + let result: [SomeType] = someSequence.reduce(into: [], { result, eachN in result.insert(eachN) }) """), Example(""" - let encountered: Set = someSequence.reduce(into: Set(), { result, eachN in + let result: Set = someSequence.reduce(into: []], { result, eachN in result.insert(eachN) }) """), Example(""" - let encountered: Dictionary = someSequence.reduce(into: Dictionary(), { result, eachN in + let result: [SomeType1: SomeType2] = someSequence.reduce(into: [:], { result, eachN in result[SomeType1Value] = SomeType2Value }) """), diff --git a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleModels.swift b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleModels.swift index 99f2c70ab7..1a3523b8c3 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleModels.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Idiomatic/ReduceIntoInsteadOfLoopRuleModels.swift @@ -1,6 +1,6 @@ import SwiftSyntax -typealias ReduceIntoInsteadOfLoopModels = ReduceIntoInsteadOfLoopRule +struct ReduceIntoInsteadOfLoopRuleModels {} internal extension ReduceIntoInsteadOfLoopRule { struct ReferencedVariable: Hashable {