Skip to content

Commit 44adf5a

Browse files
committed
[swiftlint] Fix rule: empty_parentheses_with_trailing_closure
warning: Empty Parentheses with Trailing Closure Violation: When using trailing closures, empty parentheses should be avoided after the method call.
1 parent a025c0c commit 44adf5a

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

All-Pairs Shortest Paths/APSP/APSP/FloydWarshall.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public struct FloydWarshallResult<T>: APSPResult where T: Hashable {
175175
public func path(fromVertex from: Vertex<T>, toVertex to: Vertex<T>, inGraph graph: AbstractGraph<T>) -> [T]? {
176176

177177
if let path = recursePathFrom(fromVertex: from, toVertex: to, path: [ to ], inGraph: graph) {
178-
let pathValues = path.map() { vertex in
178+
let pathValues = path.map { vertex in
179179
vertex.data
180180
}
181181
return pathValues

Bloom Filter/BloomFilter.playground/Contents.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class BloomFilter<T> {
1010
}
1111

1212
private func computeHashes(_ value: T) -> [Int] {
13-
return hashFunctions.map() { hashFunc in abs(hashFunc(value) % array.count) }
13+
return hashFunctions.map { hashFunc in abs(hashFunc(value) % array.count) }
1414
}
1515

1616
public func insert(_ element: T) {
@@ -29,7 +29,7 @@ public class BloomFilter<T> {
2929
let hashValues = computeHashes(value)
3030

3131
// Map hashes to indices in the Bloom Filter
32-
let results = hashValues.map() { hashValue in array[hashValue] }
32+
let results = hashValues.map { hashValue in array[hashValue] }
3333

3434
// All values must be 'true' for the query to return true
3535

Bloom Filter/BloomFilter.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class BloomFilter<T> {
88
}
99

1010
private func computeHashes(_ value: T) -> [Int] {
11-
return hashFunctions.map() { hashFunc in abs(hashFunc(value) % array.count) }
11+
return hashFunctions.map { hashFunc in abs(hashFunc(value) % array.count) }
1212
}
1313

1414
public func insert(_ element: T) {
@@ -27,7 +27,7 @@ public class BloomFilter<T> {
2727
let hashValues = computeHashes(value)
2828

2929
// Map hashes to indices in the Bloom Filter
30-
let results = hashValues.map() { hashValue in array[hashValue] }
30+
let results = hashValues.map { hashValue in array[hashValue] }
3131

3232
// All values must be 'true' for the query to return true
3333

Graph/Graph/AdjacencyListGraph.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ open class AdjacencyListGraph<T>: AbstractGraph<T> where T: Equatable, T: Hashab
6464

6565
open override func createVertex(_ data: T) -> Vertex<T> {
6666
// check if the vertex already exists
67-
let matchingVertices = vertices.filter() { vertex in
67+
let matchingVertices = vertices.filter { vertex in
6868
return vertex.data == data
6969
}
7070

Graph/Graph/AdjacencyMatrixGraph.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ open class AdjacencyMatrixGraph<T>: AbstractGraph<T> where T: Equatable, T: Hash
4646
// Performance: possibly O(n^2) because of the resizing of the matrix.
4747
open override func createVertex(_ data: T) -> Vertex<T> {
4848
// check if the vertex already exists
49-
let matchingVertices = vertices.filter() { vertex in
49+
let matchingVertices = vertices.filter { vertex in
5050
return vertex.data == data
5151
}
5252

Single-Source Shortest Paths (Weighted)/SSSP/BellmanFord.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension BellmanFord: SSSPAlgorithm {
4141

4242
for _ in 0 ..< vertices.count - 1 {
4343
var weightsUpdated = false
44-
edges.forEach() { edge in
44+
edges.forEach { edge in
4545
let weight = edge.weight!
4646
let relaxedDistance = weights[edge.from.index] + weight
4747
let nextVertexIdx = edge.to.index
@@ -116,7 +116,7 @@ extension BellmanFordResult: SSSPResult {
116116
return nil
117117
}
118118

119-
return path.map() { vertex in
119+
return path.map { vertex in
120120
return vertex.data
121121
}
122122
}

Trie/Trie/TrieTests/TrieTests.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class TrieTests: XCTestCase {
101101

102102
/// Tests the performance of the insert method.
103103
func testInsertPerformance() {
104-
self.measure() {
104+
self.measure {
105105
let trie = Trie()
106106
for word in self.wordArray! {
107107
trie.insert(word: word)
@@ -114,7 +114,7 @@ class TrieTests: XCTestCase {
114114
/// Tests the performance of the insert method when the words are already
115115
/// present.
116116
func testInsertAgainPerformance() {
117-
self.measure() {
117+
self.measure {
118118
for word in self.wordArray! {
119119
self.trie.insert(word: word)
120120
}
@@ -123,7 +123,7 @@ class TrieTests: XCTestCase {
123123

124124
/// Tests the performance of the contains method.
125125
func testContainsPerformance() {
126-
self.measure() {
126+
self.measure {
127127
for word in self.wordArray! {
128128
XCTAssertTrue(self.trie.contains(word: word))
129129
}
@@ -136,7 +136,7 @@ class TrieTests: XCTestCase {
136136
for word in self.wordArray! {
137137
self.trie.remove(word: word)
138138
}
139-
self.measure() {
139+
self.measure {
140140
self.insertWordsIntoTrie()
141141
for word in self.wordArray! {
142142
self.trie.remove(word: word)

0 commit comments

Comments
 (0)