Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -73,7 +73,7 @@ private extension CodeBlockItemListSyntax {
typealias IndexRange = Range<Self.Index>
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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
struct ReduceIntoInsteadOfLoopRuleExamples {
static let nonTriggeringExamples: [Example] = [
Example("""
let encountered: Array<SomeType> = someSequence.reduce(into: Array<SomeType>(), { result, eachN in
let result: [SomeType] = someSequence.reduce(into: [], { result, eachN in
result.insert(eachN)
})
"""),
Example("""
let encountered: Set<SomeType> = someSequence.reduce(into: Set<SomeType>(), { result, eachN in
let result: Set<SomeType> = someSequence.reduce(into: []], { result, eachN in
result.insert(eachN)
})
"""),
Example("""
let encountered: Dictionary<SomeType1, SomeType2> = someSequence.reduce(into: Dictionary<SomeType1, SomeType2>(), { result, eachN in
let result: [SomeType1: SomeType2] = someSequence.reduce(into: [:], { result, eachN in
result[SomeType1Value] = SomeType2Value
})
"""),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftSyntax

typealias ReduceIntoInsteadOfLoopModels = ReduceIntoInsteadOfLoopRule
struct ReduceIntoInsteadOfLoopRuleModels {}

internal extension ReduceIntoInsteadOfLoopRule {
struct ReferencedVariable: Hashable {
Expand Down
Loading