IBM-Swift/Kitura

View on GitHub

Showing 279 of 850 total issues

Function testVerifyLinuxTestCount has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        func testVerifyLinuxTestCount() {
            verifyCount(MiscellaneousTests.self)
            verifyCount(TestBridgingHTTPStatusCode.self)
            verifyCount(TestBridgingRequestError.self)
            verifyCount(TestCodablePathParams.self)
Severity: Minor
Found in Tests/KituraTests/TestLinuxSafeguard.swift - About 1 hr to fix

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

        static func setupRouter() -> Router {
            let router = Router()
    
            router.get("/1/(plus)+") {_, response, next in
                do {
    Severity: Minor
    Found in Tests/KituraTests/TestMultiplicity.swift - About 1 hr to fix

      Function getPart has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private func getPart(_ componentPart: Data) -> Part? {
              guard let found = componentPart.range(of: endHeaderData, in: 0 ..< componentPart.count) else {
                  return nil
              }
      
      
      Severity: Minor
      Found in Sources/Kitura/bodyParser/MultiPartBodyParser.swift - About 1 hr to fix

        Function buildRegex has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            internal func buildRegex(fromPattern: String?, allowPartialMatch: Bool = false) -> (NSRegularExpression?, Bool, [String]?) {
                guard let pattern = fromPattern else {
                    return (nil, false, nil)
                }
        
        
        Severity: Minor
        Found in Sources/Kitura/RouteRegex.swift - About 1 hr to fix

          Function constructTupleArrayOutResultHandler has 26 lines of code (exceeds 25 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

            Function testFormat has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 testMergeParams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                func testMergeParams() {
                    let simpleHandler = { (req: RouterRequest, res: RouterResponse, next: () -> Void) throws in
                        next()
                    }
            
            
            Severity: Minor
            Found in Tests/KituraTests/TestSubrouter.swift - About 55 mins 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 testRangeRequestsWithMultipleRanges has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                func testRangeRequestsWithMultipleRanges() {
                    performServerTest(router) { expectation in
                        self.performRequest("get", path: "/qwer/index.html", callback: { response in
                            defer {
                                expectation.fulfill()
            Severity: Minor
            Found in Tests/KituraTests/TestStaticFileServer.swift - About 55 mins 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 testPostRequestUrlEncoded has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                func testPostRequestUrlEncoded() {
                    performServerTest(router) { expectation in
                        self.performRequest("post", path: "/bodytest", callback: {response in
                            XCTAssertNotNil(response, "ERROR!!! ClientRequest response object was nil")
                            XCTAssertNotNil(response?.headers["Date"], "There was No Date header in the response")
            Severity: Minor
            Found in Tests/KituraTests/TestResponse.swift - About 55 mins 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 testJsonp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                func testJsonp() {
                    performServerTest(router) { expectation in
                        self.performRequest("get", path: "/jsonp?callback=testfn", 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 55 mins 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 getParser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                class func getParser(contentType: String) -> BodyParserProtocol? {
                    // Handle Content-Type with parameters.  For example, treat:
                    // "application/x-www-form-urlencoded; charset=UTF-8" as
                    // "application/x-www-form-urlencoded"
                    var contentTypeWithoutParameters = contentType
            Severity: Minor
            Found in Sources/Kitura/bodyParser/BodyParser.swift - About 55 mins 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 getPart has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private func getPart(_ componentPart: Data) -> Part? {
                    guard let found = componentPart.range(of: endHeaderData, in: 0 ..< componentPart.count) else {
                        return nil
                    }
            
            
            Severity: Minor
            Found in Sources/Kitura/bodyParser/MultiPartBodyParser.swift - About 55 mins 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 handleMiddleware has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private func handleMiddleware<T1: TypeSafeMiddleware, T2: TypeSafeMiddleware, T3: TypeSafeMiddleware>(
                    _ middlewareOneType: T1.Type,
                    _ middlewareTwoType: T2.Type,
                    _ middlewareThreeType: T3.Type,
                    request: RouterRequest,
            Severity: Minor
            Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift - About 55 mins 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 startServer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private func startServer(router: ServerDelegate, options: ServerOptions?) -> Int? {
                    // Servers with options (live for duration of one test)
                    if options != nil {
                        let server = doStartServer(router: router, options: options)
                        return server?.port
            Severity: Minor
            Found in Tests/KituraTests/KituraTest.swift - About 55 mins 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 selectResponseEncoder has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private func selectResponseEncoder(_ request: RouterRequest) -> (MediaType, BodyEncoder) {
                    let acceptHeader = request.headers["accept"]
                    if encoders.count == 1 ||
                        acceptHeader == nil ||
                        acceptHeader == "*" ||
            Severity: Minor
            Found in Sources/Kitura/RouterResponse.swift - About 55 mins 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 constructResultHandler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public static func constructResultHandler(response: RouterResponse, completion: @escaping () -> Void) -> ResultClosure {
                    return { error in
                        if let error = error {
                            response.status(httpStatusCode(from: error))
                            do {
            Severity: Minor
            Found in Sources/Kitura/CodableRouter.swift - About 55 mins 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 performServerTest has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                func performServerTest(_ router: ServerDelegate, options: ServerOptions? = nil, sslOption: SSLOption = SSLOption.both, socketTypeOption: SocketTypeOption = SocketTypeOption.both, timeout: TimeInterval = 10,
                                       line: Int = #line, asyncTasks: (XCTestExpectation) -> Void...) {
            Severity: Major
            Found in Tests/KituraTests/KituraTest.swift - About 50 mins to fix

              Function performServerTest has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  func performServerTest(_ router: ServerDelegate, options: ServerOptions? = nil, sslOption: SSLOption = SSLOption.both, socketTypeOption: SocketTypeOption = SocketTypeOption.both, timeout: TimeInterval = 10,
                                         line: Int = #line, asyncTasks: [(XCTestExpectation) -> Void]) {
              Severity: Major
              Found in Tests/KituraTests/KituraTest.swift - About 50 mins to fix

                Function assertParseError has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    func assertParseError(_ size: UInt64, _ headerValue: String, error: RangeHeader.Error, combine: Bool = false , file: StaticString = #file, line: UInt = #line) {
                Severity: Minor
                Found in Tests/KituraTests/TestRangeHeader.swift - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for  part in parts[1..<parts.count] {
                                              let pieces = part.components(separatedBy: "=")
                                              let piece = pieces[0].lowercased()
                                              switch piece {
                                              case "secure", "httponly":
                  Severity: Major
                  Found in Tests/KituraTests/TestCookies.swift - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language