IBM-Swift/Kitura

View on GitHub
Tests/KituraTests/TestMultiplicity.swift

Summary

Maintainability
D
1 day
Test Coverage

Function setupRouter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static func setupRouter() -> Router {
        let router = Router()

        router.get("/1/(plus)+") {_, response, next in
            do {
Severity: Minor
Found in Tests/KituraTests/TestMultiplicity.swift - About 1 hr to fix

    Function setupRouter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        static func setupRouter() -> Router {
            let router = Router()
    
            router.get("/1/(plus)+") {_, response, next in
                do {
    Severity: Minor
    Found in Tests/KituraTests/TestMultiplicity.swift - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

        func testStar() {
            performServerTest(router, asyncTasks: { expectation in
                self.performRequest("get", path: "/2/star", callback: {response in
                        XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "Star route did not match single path request")
                      expectation.fulfill()
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 2 hrs to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 35..52
    Tests/KituraTests/TestMultiplicity.swift on lines 73..90
    Tests/KituraTests/TestMultiplicity.swift on lines 92..109

    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 157.

    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 4 locations. Consider refactoring.
    Open

        func testCombined() {
            performServerTest(router, asyncTasks: { expectation in
                self.performRequest("get", path: "/4/question/plus", callback: {response in
                        XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "Complex route did not match dropped star ending")
                      expectation.fulfill()
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 2 hrs to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 35..52
    Tests/KituraTests/TestMultiplicity.swift on lines 54..71
    Tests/KituraTests/TestMultiplicity.swift on lines 73..90

    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 157.

    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 4 locations. Consider refactoring.
    Open

        func testQuestion() {
            performServerTest(router, asyncTasks: { expectation in
                self.performRequest("get", path: "/3/question", callback: {response in
                        XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "Question route did not match single path request")
                      expectation.fulfill()
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 2 hrs to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 35..52
    Tests/KituraTests/TestMultiplicity.swift on lines 54..71
    Tests/KituraTests/TestMultiplicity.swift on lines 92..109

    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 157.

    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 4 locations. Consider refactoring.
    Open

        func testPlus() {
            performServerTest(router, asyncTasks: { expectation in
                self.performRequest("get", path: "/1/plus", callback: {response in
                    XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "Plus route did not match single path request")
                    expectation.fulfill()
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 2 hrs to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 54..71
    Tests/KituraTests/TestMultiplicity.swift on lines 73..90
    Tests/KituraTests/TestMultiplicity.swift on lines 92..109

    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 157.

    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 3 locations. Consider refactoring.
    Open

        static var allTests: [(String, (TestMultiplicity) -> () throws -> Void)] {
            return [
                ("testPlus", testPlus),
                ("testStar", testStar),
                ("testQuestion", testQuestion),
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 2 other locations - About 1 hr to fix
    Tests/KituraTests/TestDecodingErrorExtension.swift on lines 21..29
    Tests/KituraTests/TestRouterHTTPVerbs_generated.swift on lines 31..38

    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 70.

    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 4 locations. Consider refactoring.
    Open

            router.get("/1/(plus)+") {_, response, next in
                do {
                    try response.status(HTTPStatusCode.OK).end()
                } catch {}
    
    
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 35 mins to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 122..127
    Tests/KituraTests/TestMultiplicity.swift on lines 129..135
    Tests/KituraTests/TestMultiplicity.swift on lines 137..143

    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 44.

    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 4 locations. Consider refactoring.
    Open

            router.get("/2/(star)*") {_, response, next in
                do {
                    try response.status(HTTPStatusCode.OK).end()
                } catch {}
                next()
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 35 mins to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 114..120
    Tests/KituraTests/TestMultiplicity.swift on lines 129..135
    Tests/KituraTests/TestMultiplicity.swift on lines 137..143

    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 44.

    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 4 locations. Consider refactoring.
    Open

            router.get("/3/(question)?") {_, response, next in
                do {
                    try response.status(HTTPStatusCode.OK).end()
                } catch {}
    
    
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 35 mins to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 114..120
    Tests/KituraTests/TestMultiplicity.swift on lines 122..127
    Tests/KituraTests/TestMultiplicity.swift on lines 137..143

    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 44.

    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 4 locations. Consider refactoring.
    Open

            router.get ("/4/(question)?/(plus+)+/(star)*") {_, response, next in
                do {
                    try response.status(HTTPStatusCode.OK).end()
                } catch {}
    
    
    Severity: Major
    Found in Tests/KituraTests/TestMultiplicity.swift and 3 other locations - About 35 mins to fix
    Tests/KituraTests/TestMultiplicity.swift on lines 114..120
    Tests/KituraTests/TestMultiplicity.swift on lines 122..127
    Tests/KituraTests/TestMultiplicity.swift on lines 129..135

    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 44.

    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

    Parameter clause in closure signature should be preceded by exactly one space
    Open

            router.get("/1/(plus)+") {_, response, next in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/3/question", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/1/plus/plus", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/2/star/star", callback: {response in

    Closure is the function's final argument and may be passed as a trailing closure instead
    Open

            }, { expectation in

    trailing-closure

    Closures that are the last argument of a function should be passed into the function using trailing closure syntax.

    Preferred

    reversed = names.sort { s1, s2 in return s1 > s2 }

    Not Preferred

    reversed = names.sort({ s1, s2 in return s1 > s2 })

    Closure is the function's final argument and may be passed as a trailing closure instead
    Open

            }, { expectation in

    trailing-closure

    Closures that are the last argument of a function should be passed into the function using trailing closure syntax.

    Preferred

    reversed = names.sort { s1, s2 in return s1 > s2 }

    Not Preferred

    reversed = names.sort({ s1, s2 in return s1 > s2 })

    Closure is the function's final argument and may be passed as a trailing closure instead
    Open

            }, { expectation in

    trailing-closure

    Closures that are the last argument of a function should be passed into the function using trailing closure syntax.

    Preferred

    reversed = names.sort { s1, s2 in return s1 > s2 }

    Not Preferred

    reversed = names.sort({ s1, s2 in return s1 > s2 })

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/1", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

            router.get("/3/(question)?") {_, response, next in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/3", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/4/plus/plus/star", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

            router.get("/2/(star)*") {_, response, next in

    Closure is the function's final argument and may be passed as a trailing closure instead
    Open

            }, { expectation in

    trailing-closure

    Closures that are the last argument of a function should be passed into the function using trailing closure syntax.

    Preferred

    reversed = names.sort { s1, s2 in return s1 > s2 }

    Not Preferred

    reversed = names.sort({ s1, s2 in return s1 > s2 })

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/3/question/question", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/4/question/plus", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/2", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

            router.get ("/4/(question)?/(plus+)+/(star)*") {_, response, next in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/1/plus", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/2/star", callback: {response in

    Parameter clause in closure signature should be preceded by exactly one space
    Open

                self.performRequest("get", path: "/4/question/plusssssss/plus/pluss/star/star", callback: {response in

    There are no issues that match your filters.

    Category
    Status