IBM-Swift/Kitura

View on GitHub

Showing 850 of 850 total issues

Function buildCss has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function buildCss() {
            var css = {
                wrapper: {
                    position: "relative",
                    display: "inline-block"
Severity: Minor
Found in docs/js/typeahead.jquery.js - About 1 hr to fix

    Function buildCss has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function buildCss() {
                var css = {
                    wrapper: {
                        position: "relative",
                        display: "inline-block"

      Function serveNonDirectoryFile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              private func serveNonDirectoryFile(_ filePath: String, response: RouterResponse) {
                  if  !isValidFilePath(filePath) {
                      return
                  }
      
      
      Severity: Minor
      Found in Sources/Kitura/staticFileServer/FileServer.swift - About 1 hr to fix

        Function testMultipleParametersMultipleHandlers has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func testMultipleParametersMultipleHandlers() {
                let router = Router()
        
                router.parameter(["id"], handlers: [
                    { request, response, value, next in
        Severity: Minor
        Found in Tests/KituraTests/TestRequests.swift - About 1 hr to fix

          Function testNoCookies has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              func testNoCookies() {
                  performServerTest(router, asyncTasks: { expectation in
                      self.performRequest("get", path: "/1/cookiedump", callback: {response in
                          XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "cookiedump route did not match single path request")
                          do {
          Severity: Minor
          Found in Tests/KituraTests/TestCookies.swift - About 1 hr 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 2 locations. Consider refactoring.
          Open

                  buildServerTest(router, timeout: 30)
                      // Test that handler is invoked successfully when all middlewares are satisfied
                      .request("delete", path: "/userMultiMiddleware/1", headers: goodHeaders)
                      .hasStatus(.noContent)
                      .hasNoData()
          Severity: Major
          Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 1 other location - About 1 hr to fix
          Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 717..734

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

          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

                  buildServerTest(router, timeout: 30)
                      // Test that handler is invoked successfully when all middlewares are satisfied
                      .request("delete", path: "/userMultiMiddleware?id=1", headers: goodHeaders)
                      .hasStatus(.noContent)
                      .hasNoData()
          Severity: Major
          Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 1 other location - About 1 hr to fix
          Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 626..643

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

          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

                  router.get("/user/:name") { request, response, next in
                      response.status(.OK)
                      XCTAssertTrue(request.userInfo["handler3"] as? Bool ?? false)
                      XCTAssertTrue(request.userInfo["handler4"] as? Bool ?? false)
                      XCTAssertNil(request.userInfo["handler1"])
          Severity: Major
          Found in Tests/KituraTests/TestRequests.swift and 1 other location - About 1 hr to fix
          Tests/KituraTests/TestRequests.swift on lines 342..349

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

          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

                  router.get("/item/:id") { request, response, next in
                      response.status(.OK)
                      XCTAssertTrue(request.userInfo["handler1"] as? Bool ?? false)
                      XCTAssertTrue(request.userInfo["handler2"] as? Bool ?? false)
                      XCTAssertNil(request.userInfo["handler3"])
          Severity: Major
          Found in Tests/KituraTests/TestRequests.swift and 1 other location - About 1 hr to fix
          Tests/KituraTests/TestRequests.swift on lines 351..358

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

          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

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

          /**
           * Copyright IBM Corporation 2018
           *
           * Licensed under the Apache License, Version 2.0 (the "License");
           * you may not use this file except in compliance with the License.
          Severity: Major
          Found in Tests/KituraTests/TestCustomCoders.swift and 1 other location - About 1 hr to fix
          Tests/KituraTests/TestCustomCoders.swift on lines 1..244

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

          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

              override public func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws {
                  guard request.body == nil else {
                      return next() // the body was already parsed
                  }
          
          
          Severity: Major
          Found in Sources/Kitura/bodyParser/BodyParser.swift and 1 other location - About 1 hr to fix
          Sources/Kitura/bodyParser/BodyParser.swift on lines 85..97

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

          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

              public func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws {
                  guard request.body == nil else {
                      return next() // the body was already parsed
                  }
          
          
          Severity: Major
          Found in Sources/Kitura/bodyParser/BodyParser.swift and 1 other location - About 1 hr to fix
          Sources/Kitura/bodyParser/BodyParser.swift on lines 225..237

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

          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 testSimpleCustomMatches has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func testSimpleCustomMatches() {
                  var router = Router()
          
                  router.all("/:id(\\d+)", handler: handler)
          
          
          Severity: Minor
          Found in Tests/KituraTests/TestRouteRegex.swift - About 1 hr to fix

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

                static func setupRouter() -> Router {
                    let router = Router()
            
                    router.get("/1/cookiedump") {request, response, next in
                        var cookies: [String] = []
            Severity: Minor
            Found in Tests/KituraTests/TestCookies.swift - About 1 hr to fix

              Function testRawCustomCoder has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  func testRawCustomCoder() {
                      // Set up router for this test
                      let customRouter = Router()
                      let jsonDecoder: () -> BodyDecoder = {
                          let decoder = JSONDecoder()
              Severity: Minor
              Found in Tests/KituraTests/TestCustomCoders.swift - About 1 hr to fix

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

                extension TestMiddleware3 {
                    static func handle(request: RouterRequest, response: RouterResponse, completion: @escaping (Self?, RequestError?) -> Void) {
                        guard let expectedHeader = request.headers["TestHeader3"] else {
                            return completion(nil, .badRequest)
                        }
                Severity: Major
                Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 2 other locations - About 1 hr to fix
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 1170..1178
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 1185..1193

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

                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

                extension TestMiddleware {
                    static func handle(request: RouterRequest, response: RouterResponse, completion: @escaping (Self?, RequestError?) -> Void) {
                        guard let expectedHeader = request.headers["TestHeader"] else {
                            return completion(nil, .badRequest)
                        }
                Severity: Major
                Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 2 other locations - About 1 hr to fix
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 1185..1193
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 1200..1208

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

                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

                extension TestMiddleware2 {
                    static func handle(request: RouterRequest, response: RouterResponse, completion: @escaping (Self?, RequestError?) -> Void) {
                        guard let expectedHeader = request.headers["TestHeader2"] else {
                            return completion(nil, .notAcceptable)
                        }
                Severity: Major
                Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 2 other locations - About 1 hr to fix
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 1170..1178
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 1200..1208

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

                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 testAcceptTypes has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    func testAcceptTypes() {
                
                        router.get("/customPage") { request, response, next in
                
                            XCTAssertEqual(request.accepts(type: "html"), "html", "Accepts did not return expected value")
                Severity: Minor
                Found in Tests/KituraTests/TestResponse.swift - About 1 hr to fix

                  Function testFormat has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      func testFormat() {
                          performServerTest(router) { expectation in
                              self.performRequest("get", path:"/format", callback: {response in
                                  XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
                                  XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "HTTP Status code was \(String(describing: response?.statusCode))")
                  Severity: Minor
                  Found in Tests/KituraTests/TestResponse.swift - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language