IBM-Swift/Kitura

View on GitHub
Tests/KituraTests/TestErrors.swift

Summary

Maintainability
A
2 hrs
Test Coverage

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

        performServerTest(router) { expectation in
            self.performRequest("get", path: "/notreal", callback: {response in
                XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
                XCTAssertEqual(response?.statusCode, HTTPStatusCode.notFound, "HTTP Status code was \(String(describing: response?.statusCode))")
                expectation.fulfill()
Severity: Major
Found in Tests/KituraTests/TestErrors.swift and 2 other locations - About 55 mins to fix
Tests/KituraTests/TestResponse.swift on lines 885..891
Tests/KituraTests/TestResponse.swift on lines 893..899

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

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

    static var allTests: [(String, (TestErrors) -> () throws -> Void)] {
        return [
            ("testInvalidMethod", testInvalidMethod),
            ("testInvalidEndpoint", testInvalidEndpoint),
            ("testInvalidHeader", testInvalidHeader)
Severity: Major
Found in Tests/KituraTests/TestErrors.swift and 3 other locations - About 50 mins to fix
Tests/KituraTests/TestContentType.swift on lines 24..30
Tests/KituraTests/TestCustomCoders.swift on lines 25..31
Tests/KituraTests/TestRangeHeaderDataExtensions.swift on lines 24..30

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

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

/**
 * Copyright IBM Corporation 2016
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
Severity: Minor
Found in Tests/KituraTests/TestErrors.swift and 1 other location - About 50 mins to fix
Tests/KituraTests/TestStaticFileServer.swift on lines 1..710

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

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

            }) {req in
Severity: Minor
Found in Tests/KituraTests/TestErrors.swift by tailor

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

        }, { expectation in
Severity: Minor
Found in Tests/KituraTests/TestErrors.swift by tailor

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: "/notreal", callback: {response in
Severity: Minor
Found in Tests/KituraTests/TestErrors.swift by tailor

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

            self.performRequest("invalid", path: "/qwer", callback: {response in
Severity: Minor
Found in Tests/KituraTests/TestErrors.swift by tailor

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

            self.performRequest("get", path: "/qwer", callback: {response in
Severity: Minor
Found in Tests/KituraTests/TestErrors.swift by tailor

There are no issues that match your filters.

Category
Status