IBM-Swift/Kitura

View on GitHub

Showing 279 of 850 total issues

Function testSimpleModifiers has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    func testSimpleModifiers() {
        var router = Router()

        router.all("/:id?", handler: handler)

Severity: Minor
Found in Tests/KituraTests/TestRouteRegex.swift - About 6 hrs 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

File RouterResponse.swift has 433 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import KituraNet
import KituraTemplateEngine
import LoggerAPI
import Foundation
import KituraContracts
Severity: Minor
Found in Sources/Kitura/RouterResponse.swift - About 6 hrs to fix

    Function Menu has 144 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var Menu = function() {
            "use strict";
            function Menu(o, www) {
                var that = this;
                o = o || {};
    Severity: Major
    Found in docs/js/typeahead.jquery.js - About 5 hrs to fix

      Function Menu has 144 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var Menu = function() {
              "use strict";
              function Menu(o, www) {
                  var that = this;
                  o = o || {};

        Function _ has 140 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var _ = function() {
                "use strict";
                return {
                    isMsie: function() {
                        return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false;
        Severity: Major
        Found in docs/js/typeahead.jquery.js - About 5 hrs to fix

          Function _ has 140 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var _ = function() {
                  "use strict";
                  return {
                      isMsie: function() {
                          return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false;

            TestStaticFileServer has 39 methods (exceeds 20 allowed). Consider refactoring.
            Open

            final class TestStaticFileServer: KituraTest, KituraTestSuite {
            
                static var allTests: [(String, (TestStaticFileServer) -> () throws -> Void)] {
                    return [
                        ("testFileServer", testFileServer),
            Severity: Minor
            Found in Tests/KituraTests/TestStaticFileServer.swift - About 5 hrs to fix

              TestResponse has 38 methods (exceeds 20 allowed). Consider refactoring.
              Open

              final class TestResponse: KituraTest, KituraTestSuite {
              
                  static var allTests: [(String, (TestResponse) -> () throws -> Void)] {
                      return [
                          ("testSimpleResponse", testSimpleResponse),
              Severity: Minor
              Found in Tests/KituraTests/TestResponse.swift - About 5 hrs to fix

                File TestTemplateEngine.swift has 375 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import XCTest
                import Foundation
                import KituraTemplateEngine
                import KituraContracts
                
                
                Severity: Minor
                Found in Tests/KituraTests/TestTemplateEngine.swift - About 5 hrs to fix

                  TestTypeSafeMiddleware has 34 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  final class TestTypeSafeMiddleware: KituraTest, KituraTestSuite {
                      static var allTests: [(String, (TestTypeSafeMiddleware) -> () throws -> Void)] {
                          return [
                              ("testSingleMiddlewareGetSingleton", testSingleMiddlewareGetSingleton),
                              ("testMultipleMiddlewareGetSingleton", testMultipleMiddlewareGetSingleton),
                  Severity: Minor
                  Found in Tests/KituraTests/TestTypeSafeMiddleware.swift - About 4 hrs to fix

                    File TestRequests.swift has 344 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import XCTest
                    import Foundation
                    import KituraContracts
                    
                    @testable import Kitura
                    Severity: Minor
                    Found in Tests/KituraTests/TestRequests.swift - About 4 hrs to fix

                      Function testSend has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          func testSend() {
                              performServerTest(router) { expectation in
                                  self.performRequest("get", path: "/data", 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: Major
                      Found in Tests/KituraTests/TestResponse.swift - About 4 hrs to fix

                        Function addCookie has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public func addCookie(name: String, value: String, domain: String, path: String, otherAttributes: [AdditionalCookieAttribute]? = nil ) {
                                var cookieProperties = [HTTPCookiePropertyKey: Any]()
                                cookieProperties[HTTPCookiePropertyKey.name] = name
                                cookieProperties[HTTPCookiePropertyKey.value] = value
                                cookieProperties[HTTPCookiePropertyKey.domain] = domain
                        Severity: Minor
                        Found in Sources/Kitura/RouterResponse.swift - About 4 hrs 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 97 lines of code (exceeds 25 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: Major
                        Found in Tests/KituraTests/TestStaticFileServer.swift - About 3 hrs to fix

                          Function testMultipartFormParsing has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              func testMultipartFormParsing() {
                          
                                  // ensure NSData.components works just like String.components
                                  dataComponentsTest("AxAyAzA", separator: "A")
                                  dataComponentsTest("HelloWorld", separator: "World")
                          Severity: Major
                          Found in Tests/KituraTests/TestResponse.swift - About 3 hrs to fix

                            Function WWW has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                var WWW = function() {
                                    "use strict";
                                    var defaultClassNames = {
                                        wrapper: "twitter-typeahead",
                                        input: "tt-input",
                            Severity: Major
                            Found in docs/js/typeahead.jquery.js - About 3 hrs to fix

                              Function WWW has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  var WWW = function() {
                                      "use strict";
                                      var defaultClassNames = {
                                          wrapper: "twitter-typeahead",
                                          input: "tt-input",

                                Function testSimplePaths has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    func testSimplePaths() {
                                        var router = Router()
                                
                                        router.all("", handler: handler)
                                
                                
                                Severity: Major
                                Found in Tests/KituraTests/TestRouteRegex.swift - About 3 hrs to fix

                                  Function EventEmitter has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      var EventEmitter = function() {
                                          "use strict";
                                          var splitter = /\s+/, nextTick = getNextTick();
                                          return {
                                              onSync: onSync,

                                    Function EventEmitter has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        var EventEmitter = function() {
                                            "use strict";
                                            var splitter = /\s+/, nextTick = getNextTick();
                                            return {
                                                onSync: onSync,
                                    Severity: Major
                                    Found in docs/js/typeahead.jquery.js - About 3 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language