IBM-Swift/Kitura

View on GitHub
Tests/KituraTests/TestRangeHeader.swift

Summary

Maintainability
C
1 day
Test Coverage

Function assertParseError has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    func assertParseError(_ size: UInt64, _ headerValue: String, error: RangeHeader.Error, combine: Bool = false , file: StaticString = #file, line: UInt = #line) {
Severity: Minor
Found in Tests/KituraTests/TestRangeHeader.swift - About 45 mins to fix

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseStringWithSomeInvalidRanges() {
            let range = parse(200, "bytes=0-499,1000-,500-999")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 0..<199)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseNonBytesRange() {
            let range = parse(1000, "items=0-5")
            XCTAssertEqual(range?.type, "items")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 0..<5)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseNormalString() {
            let range = parse(1000, "bytes=40-80")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 40..<80)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldCapEndAtSize() {
            let range = parse(200, "bytes=0-499")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 0..<199)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseStringWithOnlyStart() {
            let range = parse(1000, "bytes=400-")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 400..<999)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseStringWithBytesEqualZeroZero() {
            let range = parse(1000, "bytes=0-0")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 0..<0)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseWithStartBytesEqualtToZero() {
            let range = parse(1000, "bytes=0-")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 0..<999)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseStringAskingForLastByte() {
            let range = parse(1000, "bytes=-1")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 999..<999)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testParseString() {
            let range = parse(1000, "bytes=0-499")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 0..<499)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 108..113
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 10 locations. Consider refactoring.
    Open

        func testShouldParseStringWithOnlyEnd() {
            let range = parse(1000, "bytes=-400")
            XCTAssertEqual(range?.type, "bytes")
            XCTAssertEqual(range?.ranges.count, 1)
            XCTAssertEqual(range?.ranges[0], 600..<999)
    Severity: Major
    Found in Tests/KituraTests/TestRangeHeader.swift and 9 other locations - About 1 hr to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 87..92
    Tests/KituraTests/TestRangeHeader.swift on lines 94..99
    Tests/KituraTests/TestRangeHeader.swift on lines 101..106
    Tests/KituraTests/TestRangeHeader.swift on lines 115..120
    Tests/KituraTests/TestRangeHeader.swift on lines 122..127
    Tests/KituraTests/TestRangeHeader.swift on lines 129..134
    Tests/KituraTests/TestRangeHeader.swift on lines 136..141
    Tests/KituraTests/TestRangeHeader.swift on lines 152..157
    Tests/KituraTests/TestRangeHeader.swift on lines 159..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 76.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        func testReturnNilOnInvalidNonDigitsRanges() {
            assertParseError(200, "bytes=xyz", error: .notSatisfiable)
            assertParseError(200, "bytes=xyz-", error: .notSatisfiable)
            assertParseError(200, "bytes=-xyz", error: .notSatisfiable)
        }
    Severity: Minor
    Found in Tests/KituraTests/TestRangeHeader.swift and 1 other location - About 35 mins to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 75..79

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        func testReturnNilOnInvalidRanges() {
            assertParseError(200, "bytes=500-20", error: .notSatisfiable)
            assertParseError(200, "bytes=500-999", error: .notSatisfiable)
            assertParseError(200, "bytes=500-999,1000-1499", error: .notSatisfiable)
        }
    Severity: Minor
    Found in Tests/KituraTests/TestRangeHeader.swift and 1 other location - About 35 mins to fix
    Tests/KituraTests/TestRangeHeader.swift on lines 81..85

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Catch clause should not be enclosed within parentheses
    Open

            } catch (let e as RangeHeader.Error) {

    redundant-parentheses

    Control flow constructs (if, else if, switch, for, while, repeat-while, and guard statements), Exception handling constructs (throw, and do/catch statements), and Initializers (array, dictionary, initializer patterns) should not be enclosed in parentheses.

    Additionally, method calls with no parameters and a trailing closure should not have empty parentheses following the method name.

    Control flow constructs

    • if, else if statement

    Preferred

    if SomeCondition {
    
    } else if SomeOtherCondition {
    }

    Not Preferred

    if (SomeCondition) {
    
    } else if (SomeOtherCondition) {
    }
    • switch statement

    Preferred

    switch SomeData {
        default:
            break
    }

    Not Preferred

    switch (SomeData) {
        default:
            break
    }
    • for loop

    Preferred

    for var i = 0; i < 10; i+=1 {
    
    }

    Not Preferred

    for (var i = 0; i < 10; i+=1) {
    
    }
    • while loop

    Preferred

    while SomeCondition {
    
    }

    Not Preferred

    while (SomeCondition) {
    
    }
    • repeat-while loop

    Preferred

    repeat {
    
    } while SomeCondition

    Not Preferred

    repeat {
    
    } while (SomeCondition)
    • guard clause

    Preferred

    guard true else {   }

    Not Preferred

    guard (true) else {   }

    Exception handling constructs

    • do/catch statement

    Preferred

    do  {
    
    } catch SomeException {
    
    }

    Not Preferred

    do  {
    
    } catch (SomeException) {
    
    }
    • throw statement

    Preferred

    throw SomeException

    Not Preferred

    throw (SomeException)

    Initializers

    • array items

    Preferred

    var shoppingList: [String] = ["Eggs", "Milk"]

    Not Preferred

    var shoppingList: [String] = [("Eggs"), ("Milk")]
    • dictionary items

    Preferred

    var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]

    Not Preferred

    var airports: [String: String] = [("YYZ"): ("Toronto Pearson"), ("DUB"): ("Dublin")]
    • initializer patterns

    Preferred

    var x: Int = 2
    var y: String = "Sleekbyte"
    var x = 2

    Not Preferred

    var x: Int = (2)
    var y: String = ("Sleekbyte")
    var x = (2)

    Method calls

    Preferred

    items.map {
      item in item.transform()
    }

    Not Preferred

    items.map() {
      item in item.transform()
    }

    Catch clause should not be enclosed within parentheses
    Open

            } catch (let e) {

    redundant-parentheses

    Control flow constructs (if, else if, switch, for, while, repeat-while, and guard statements), Exception handling constructs (throw, and do/catch statements), and Initializers (array, dictionary, initializer patterns) should not be enclosed in parentheses.

    Additionally, method calls with no parameters and a trailing closure should not have empty parentheses following the method name.

    Control flow constructs

    • if, else if statement

    Preferred

    if SomeCondition {
    
    } else if SomeOtherCondition {
    }

    Not Preferred

    if (SomeCondition) {
    
    } else if (SomeOtherCondition) {
    }
    • switch statement

    Preferred

    switch SomeData {
        default:
            break
    }

    Not Preferred

    switch (SomeData) {
        default:
            break
    }
    • for loop

    Preferred

    for var i = 0; i < 10; i+=1 {
    
    }

    Not Preferred

    for (var i = 0; i < 10; i+=1) {
    
    }
    • while loop

    Preferred

    while SomeCondition {
    
    }

    Not Preferred

    while (SomeCondition) {
    
    }
    • repeat-while loop

    Preferred

    repeat {
    
    } while SomeCondition

    Not Preferred

    repeat {
    
    } while (SomeCondition)
    • guard clause

    Preferred

    guard true else {   }

    Not Preferred

    guard (true) else {   }

    Exception handling constructs

    • do/catch statement

    Preferred

    do  {
    
    } catch SomeException {
    
    }

    Not Preferred

    do  {
    
    } catch (SomeException) {
    
    }
    • throw statement

    Preferred

    throw SomeException

    Not Preferred

    throw (SomeException)

    Initializers

    • array items

    Preferred

    var shoppingList: [String] = ["Eggs", "Milk"]

    Not Preferred

    var shoppingList: [String] = [("Eggs"), ("Milk")]
    • dictionary items

    Preferred

    var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]

    Not Preferred

    var airports: [String: String] = [("YYZ"): ("Toronto Pearson"), ("DUB"): ("Dublin")]
    • initializer patterns

    Preferred

    var x: Int = 2
    var y: String = "Sleekbyte"
    var x = 2

    Not Preferred

    var x: Int = (2)
    var y: String = ("Sleekbyte")
    var x = (2)

    Method calls

    Preferred

    items.map {
      item in item.transform()
    }

    Not Preferred

    items.map() {
      item in item.transform()
    }

    There are no issues that match your filters.

    Category
    Status