IBM-Swift/Kitura

View on GitHub

Showing 279 of 850 total issues

Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public func get<T1: TypeSafeMiddleware, T2: TypeSafeMiddleware, Q: QueryParams, O: Codable>(
        _ route: String,
        handler: @escaping (T1, T2, Q, @escaping CodableResultClosure<O>) -> Void
    ) {
        registerGetRoute(route: route, queryParams: Q.self, optionalQParam: false, outputType: O.self)
Severity: Minor
Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift - About 35 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 post has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public func post<T: TypeSafeMiddleware, I: Codable, O: Codable>(
        _ route: String,
        handler: @escaping (T, I, @escaping CodableResultClosure<O>) -> Void
    ) {
        registerPostRoute(route: route, inputType: I.self, outputType: O.self)
Severity: Minor
Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift - About 35 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 parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    fileprivate static func parse(headers: HeadersContainer) -> [String: HTTPCookie] {
        var cookies = [String: HTTPCookie]()
        guard let cookieHeaders = headers["cookie"] else {
            return cookies
        }
Severity: Minor
Found in Sources/Kitura/RouterRequest.swift - About 35 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 delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public func delete<T: TypeSafeMiddleware, Q: QueryParams>(
        _ route: String,
        handler: @escaping (T, Q, @escaping ResultClosure) -> Void
    ) {
        registerDeleteRoute(route: route, queryParams: Q.self, optionalQParam: false)
Severity: Minor
Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift - About 35 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 post has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public func post<T1: TypeSafeMiddleware, T2: TypeSafeMiddleware, T3: TypeSafeMiddleware, I: Codable, Id: Identifier, O: Codable>(
        _ route: String,
        handler: @escaping (T1, T2, T3, 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 - About 35 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

Avoid too many return statements within this function.
Open

                return XCTFail()
Severity: Major
Found in Tests/KituraTests/TestResponse.swift - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return router
    Severity: Major
    Found in Tests/KituraTests/TestResponse.swift - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return
      Severity: Major
      Found in Sources/Kitura/RouterElement.swift - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return (bestMediaType, bestEncoder())
        Severity: Major
        Found in Sources/Kitura/RouterResponse.swift - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                              return
          Severity: Major
          Found in Tests/KituraTests/TestRequests.swift - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return false
            Severity: Major
            Found in Sources/Kitura/staticFileServer/FileServer.swift - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return originalRepositoryPath + separator + path
              Severity: Major
              Found in Sources/Kitura/staticFileServer/ResourcePathHandler.swift - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return server?.unixDomainSocketPath
                Severity: Major
                Found in Tests/KituraTests/KituraTest.swift - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return server.unixDomainSocketPath
                  Severity: Major
                  Found in Tests/KituraTests/KituraTest.swift - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return false
                    Severity: Major
                    Found in Sources/Kitura/contentType/ContentType.swift - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return nil
                      Severity: Major
                      Found in Sources/Kitura/MimeTypeAcceptor.swift - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return combined
                        Severity: Major
                        Found in Sources/Kitura/staticFileServer/RangeHeader.swift - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return RawBodyParser()
                          Severity: Major
                          Found in Sources/Kitura/bodyParser/BodyParser.swift - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return ""
                            Severity: Major
                            Found in Sources/Kitura/staticFileServer/StaticFileServer.swift - About 30 mins to fix

                              Function testRouteFunc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

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

                              Severity
                              Category
                              Status
                              Source
                              Language