Skip to content

Commit

Permalink
[swiftlint] Fix rule: empty_parentheses_with_trailing_closure
Browse files Browse the repository at this point in the history
warning: Empty Parentheses with Trailing Closure Violation: When using trailing closures, empty parentheses should be avoided after the method call.
  • Loading branch information
jawwad committed Apr 29, 2017
1 parent a025c0c commit 44adf5a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion All-Pairs Shortest Paths/APSP/APSP/FloydWarshall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public struct FloydWarshallResult<T>: APSPResult where T: Hashable {
public func path(fromVertex from: Vertex<T>, toVertex to: Vertex<T>, inGraph graph: AbstractGraph<T>) -> [T]? {

if let path = recursePathFrom(fromVertex: from, toVertex: to, path: [ to ], inGraph: graph) {
let pathValues = path.map() { vertex in
let pathValues = path.map { vertex in
vertex.data
}
return pathValues
Expand Down
4 changes: 2 additions & 2 deletions Bloom Filter/BloomFilter.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class BloomFilter<T> {
}

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

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions Bloom Filter/BloomFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class BloomFilter<T> {
}

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion Graph/Graph/AdjacencyListGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ open class AdjacencyListGraph<T>: AbstractGraph<T> where T: Equatable, T: Hashab

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

Expand Down
2 changes: 1 addition & 1 deletion Graph/Graph/AdjacencyMatrixGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class AdjacencyMatrixGraph<T>: AbstractGraph<T> where T: Equatable, T: Hash
// Performance: possibly O(n^2) because of the resizing of the matrix.
open override func createVertex(_ data: T) -> Vertex<T> {
// check if the vertex already exists
let matchingVertices = vertices.filter() { vertex in
let matchingVertices = vertices.filter { vertex in
return vertex.data == data
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension BellmanFord: SSSPAlgorithm {

for _ in 0 ..< vertices.count - 1 {
var weightsUpdated = false
edges.forEach() { edge in
edges.forEach { edge in
let weight = edge.weight!
let relaxedDistance = weights[edge.from.index] + weight
let nextVertexIdx = edge.to.index
Expand Down Expand Up @@ -116,7 +116,7 @@ extension BellmanFordResult: SSSPResult {
return nil
}

return path.map() { vertex in
return path.map { vertex in
return vertex.data
}
}
Expand Down
8 changes: 4 additions & 4 deletions Trie/Trie/TrieTests/TrieTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TrieTests: XCTestCase {

/// Tests the performance of the insert method.
func testInsertPerformance() {
self.measure() {
self.measure {
let trie = Trie()
for word in self.wordArray! {
trie.insert(word: word)
Expand All @@ -114,7 +114,7 @@ class TrieTests: XCTestCase {
/// Tests the performance of the insert method when the words are already
/// present.
func testInsertAgainPerformance() {
self.measure() {
self.measure {
for word in self.wordArray! {
self.trie.insert(word: word)
}
Expand All @@ -123,7 +123,7 @@ class TrieTests: XCTestCase {

/// Tests the performance of the contains method.
func testContainsPerformance() {
self.measure() {
self.measure {
for word in self.wordArray! {
XCTAssertTrue(self.trie.contains(word: word))
}
Expand All @@ -136,7 +136,7 @@ class TrieTests: XCTestCase {
for word in self.wordArray! {
self.trie.remove(word: word)
}
self.measure() {
self.measure {
self.insertWordsIntoTrie()
for word in self.wordArray! {
self.trie.remove(word: word)
Expand Down

0 comments on commit 44adf5a

Please sign in to comment.