IBM-Swift/Kitura

View on GitHub

Showing 279 of 850 total issues

Function testCookieFromServer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    func testCookieFromServer() {
        performServerTest(router, asyncTasks: { expectation in
            self.performRequest("get", path: "/1/sendcookie", callback: {response in
                XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "/1/sendcookie route did not match single path request")

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

Function testFileServer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    func testFileServer() {
        performServerTest(router, asyncTasks: { expectation in
            self.performRequest("get", path:"/qwer", 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/TestStaticFileServer.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

Function constructTupleArrayOutResultHandler has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static func constructTupleArrayOutResultHandler<Id: Identifier, OutputType: Codable>(successStatus: HTTPStatusCode = .OK, response: RouterResponse, completion: @escaping () -> Void) -> IdentifierCodableArrayResultClosure<Id, OutputType> {
        return { codableOutput, error in
            var status = successStatus
            if let error = error {
                status = httpStatusCode(from: error)
Severity: Minor
Found in Sources/Kitura/CodableRouter.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

Function constructOutResultHandler has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static func constructOutResultHandler<OutputType: Codable>(successStatus: HTTPStatusCode = .OK, response: RouterResponse, completion: @escaping () -> Void) -> CodableResultClosure<OutputType> {
        return { codableOutput, error in
            var status = successStatus
            if let error = error {
                status = httpStatusCode(from: error)
Severity: Minor
Found in Sources/Kitura/CodableRouter.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

Function startUnixSocketServer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private func startUnixSocketServer(router: ServerDelegate, options: ServerOptions?) -> String? {
        // Servers with options (live for duration of one test)
        if (options != nil) {
            let server = doStartUnixSocketServer(router: router, options: options)
            return server?.unixDomainSocketPath
Severity: Minor
Found in Tests/KituraTests/KituraTest.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

Function Status has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var Status = function() {
        "use strict";
        function Status(options) {
            this.$el = $("<span></span>", {
                role: "status",
Severity: Minor
Found in docs/js/typeahead.jquery.js - About 1 hr to fix

    Function Status has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var Status = function() {
            "use strict";
            function Status(options) {
                this.$el = $("<span></span>", {
                    role: "status",

      Function testParameterExit has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Function cookieFrom has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func cookieFrom(response: ClientResponse?, named: String) -> (HTTPCookie?, String?) {
                guard let response = response else {
                    return (nil, nil)
                }
                var resultCookie: HTTPCookie? = nil
        Severity: Minor
        Found in Tests/KituraTests/TestCookies.swift - About 1 hr to fix

          Function attach has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                          function attach() {
                              var $input, $wrapper, $hint, $menu, defaultHint, defaultMenu, eventBus, input, menu, status, typeahead, MenuConstructor;
                              _.each(datasets, function(d) {
                                  d.highlight = !!o.highlight;
                              });
          Severity: Minor
          Found in docs/js/typeahead.jquery.js - About 1 hr to fix

            Function attach has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                            function attach() {
                                var $input, $wrapper, $hint, $menu, defaultHint, defaultMenu, eventBus, input, menu, status, typeahead, MenuConstructor;
                                _.each(datasets, function(d) {
                                    d.highlight = !!o.highlight;
                                });

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

                  func testBasicPost() {
                      router.post("/users") { (user: User, respondWith: (User?, RequestError?) -> Void) in
                          print("POST on /users for user \(user)")
                          respondWith(user, nil)
                      }
              Severity: Minor
              Found in Tests/KituraTests/TestCodableRouter.swift - 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"
                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

                        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 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 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
                              Severity
                              Category
                              Status
                              Source
                              Language