IBM-Swift/Kitura

View on GitHub

Showing 850 of 850 total issues

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

    public func post<T: TypeSafeMiddleware, I: Codable, Id: Identifier, O: Codable>(
        _ route: String,
        handler: @escaping (T, I, @escaping IdentifierCodableResultClosure<Id, O>) -> Void
    ) {
        registerPostRoute(route: route, id: Id.self, inputType: I.self, outputType: O.self)
Severity: Minor
Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 1 other location - About 40 mins to fix
Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 435..449

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

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

        userStore = [1: User(id: 1, name: "Andy"), 2: User(id: 2, name: "Dave"), 3: User(id: 3, name: "Ian")]
Severity: Minor
Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 1 other location - About 40 mins to fix
Tests/KituraTests/TestCodableRouter.swift on lines 56..56

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

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

Function runGetResponseTest has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private func runGetResponseTest(path: String, expectedResponseText: String? = nil,
                                    expectedStatusCode: HTTPStatusCode = HTTPStatusCode.OK,
                                    bodyChecker: BodyChecker? = nil,
                                    withRouter: Router? = nil) {
Severity: Minor
Found in Tests/KituraTests/TestStaticFileServer.swift - About 35 mins to fix

    Function assertMatch has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        func assertMatch(_ target: String?, _ pattern: String, matchedGroups: inout [String], file: StaticString = #file, line: UInt = #line) {
    Severity: Minor
    Found in Tests/KituraTests/TestStaticFileServer.swift - About 35 mins to fix

      Function log has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public func log(_ type: LoggerMessageType, msg: String,
                          functionName: String, lineNum: Int, fileName: String ) {
      Severity: Minor
      Found in Tests/KituraTests/PrintLogger.swift - About 35 mins to fix

        Function request has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public func request<T: Encodable>(_ method: String, path: String, data: T, headers: [String:String]?, encoder: @escaping () -> BodyEncoder) -> AssertionTestBuilder {
        Severity: Minor
        Found in Tests/KituraTests/KituraTestBuilder.swift - About 35 mins to fix

          Function render has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              func render<T: Encodable>(filePath: String, with: T, forKey: String?, options: RenderingOptions, templateName: String) throws -> String {
          Severity: Minor
          Found in Tests/KituraTests/TestTemplateEngine.swift - About 35 mins to fix

            Function addCookie has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public func addCookie(name: String, value: String, domain: String, path: String, otherAttributes: [AdditionalCookieAttribute]? = nil ) {
            Severity: Minor
            Found in Sources/Kitura/RouterResponse.swift - About 35 mins to fix

              Function buildServerTest has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  func buildServerTest(_ router: ServerDelegate, sslOption: SSLOption = SSLOption.both, socketTypeOption: SocketTypeOption = SocketTypeOption.both, timeout: TimeInterval = 10,
                                         line: Int = #line) -> RequestTestBuilder {
              Severity: Minor
              Found in Tests/KituraTests/KituraTest.swift - About 35 mins to fix

                Function handleMiddleware has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        _ middlewareOneType: T1.Type,
                        _ middlewareTwoType: T2.Type,
                        request: RouterRequest,
                        response: RouterResponse,
                        completion: @escaping (T1?, T2?) -> Void
                Severity: Minor
                Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift - About 35 mins to fix

                  Function serveExistingFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          private func serveExistingFile(_ filePath: String, requestPath: String, queryString: String,
                                                         isDirectory: Bool, response: RouterResponse) {
                  Severity: Minor
                  Found in Sources/Kitura/staticFileServer/FileServer.swift - About 35 mins to fix

                    Function handleMatch has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            private static func handleMatch(rawHeaderValue: String, type: String, matchAllPattern: String,
                                                            criteriaMatches: inout CriteriaMatches, headerOrder: Int) {
                    Severity: Minor
                    Found in Sources/Kitura/MimeTypeAcceptor.swift - About 35 mins to fix

                      Function doPerformServerTest has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          func doPerformServerTest(router: ServerDelegate, options: ServerOptions?, timeout: TimeInterval, line: Int, asyncTasks: [(XCTestExpectation) -> Void]) {
                      Severity: Minor
                      Found in Tests/KituraTests/KituraTest.swift - About 35 mins to fix

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

                                    if let urlEncoded = requestBody.asURLEncoded {
                                        do {
                                            response.headers["Content-Type"] = "text/html; charset=utf-8"
                                            try response.send("<!DOCTYPE html><html><body><b>Received URL encoded body</b><br> \(urlEncoded) </body></html>\n\n").end()
                                        } catch {
                        Severity: Minor
                        Found in Tests/KituraTests/TestResponse.swift and 2 other locations - About 35 mins to fix
                        Tests/KituraTests/TestResponse.swift on lines 1307..1335
                        Tests/KituraTests/TestResponse.swift on lines 1314..1335

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

                        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

                                    } else if let urlEncoded = requestBody.asURLEncodedMultiValue {
                                        do {
                                            response.headers["Content-Type"] = "text/html; charset=utf-8"
                                            try response.send("<!DOCTYPE html><html><body><b>Received URL encoded body</b><br> \(urlEncoded) </body></html>\n\n").end()
                                        } catch {
                        Severity: Minor
                        Found in Tests/KituraTests/TestResponse.swift and 2 other locations - About 35 mins to fix
                        Tests/KituraTests/TestResponse.swift on lines 1300..1335
                        Tests/KituraTests/TestResponse.swift on lines 1314..1335

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

                        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

                                XCTAssertEqual(strings![0], "id")
                        
                                (regex, isSimpleString, strings) = RouteRegex.sharedInstance.buildRegex(fromPattern: "/test/(Kitura\\d*)", allowPartialMatch: false)
                        Severity: Major
                        Found in Tests/KituraTests/TestRouteRegex.swift and 3 other locations - About 35 mins to fix
                        Tests/KituraTests/TestRouteRegex.swift on lines 108..110
                        Tests/KituraTests/TestRouteRegex.swift on lines 116..118
                        Tests/KituraTests/TestRouteRegex.swift on lines 124..126

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

                        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

                                    } else if let text = requestBody.asText {
                                        do {
                                            response.headers["Content-Type"] = "text/html; charset=utf-8"
                                            try response.send("<!DOCTYPE html><html><body><b>Received text body: </b>\(text)</body></html>\n\n").end()
                                        } catch {
                        Severity: Minor
                        Found in Tests/KituraTests/TestResponse.swift and 2 other locations - About 35 mins to fix
                        Tests/KituraTests/TestResponse.swift on lines 1300..1335
                        Tests/KituraTests/TestResponse.swift on lines 1307..1335

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

                        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

                                XCTAssertEqual(strings![0], "id")
                        
                                (regex, isSimpleString, strings) = RouteRegex.sharedInstance.buildRegex(fromPattern: "/test/:id(Kitura\\d*)", allowPartialMatch: false)
                        Severity: Major
                        Found in Tests/KituraTests/TestRouteRegex.swift and 3 other locations - About 35 mins to fix
                        Tests/KituraTests/TestRouteRegex.swift on lines 108..110
                        Tests/KituraTests/TestRouteRegex.swift on lines 116..118
                        Tests/KituraTests/TestRouteRegex.swift on lines 132..134

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

                        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

                                XCTAssertEqual(strings![0], "id")
                        
                                (regex, isSimpleString, strings) = RouteRegex.sharedInstance.buildRegex(fromPattern: "test/:id*", allowPartialMatch: false)
                        Severity: Major
                        Found in Tests/KituraTests/TestRouteRegex.swift and 3 other locations - About 35 mins to fix
                        Tests/KituraTests/TestRouteRegex.swift on lines 116..118
                        Tests/KituraTests/TestRouteRegex.swift on lines 124..126
                        Tests/KituraTests/TestRouteRegex.swift on lines 132..134

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

                        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

                                XCTAssertEqual(strings![0], "id")
                        
                                (regex, isSimpleString, strings) = RouteRegex.sharedInstance.buildRegex(fromPattern: "/test/:id(\\d*)", allowPartialMatch: false)
                        Severity: Major
                        Found in Tests/KituraTests/TestRouteRegex.swift and 3 other locations - About 35 mins to fix
                        Tests/KituraTests/TestRouteRegex.swift on lines 108..110
                        Tests/KituraTests/TestRouteRegex.swift on lines 124..126
                        Tests/KituraTests/TestRouteRegex.swift on lines 132..134

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language