IBM-Swift/Kitura

View on GitHub

Showing 850 of 850 total issues

Function testBasicDeleteSingle has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func testBasicDeleteSingle() {
        router.delete("/users") { (id: Int, respondWith: (RequestError?) -> Void) in
            print("DELETE on /users/\(id)")
            guard let _ = self.userStore.removeValue(forKey: id) else {
                respondWith(.notFound)
Severity: Minor
Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

    Function testBasicPut has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        func testBasicPut() {
            router.put("/users") { (id: Int, user: User, respondWith: (User?, RequestError?) -> Void) in
                print("PUT on /users/\(id)")
                self.userStore[id] = user
                respondWith(user, nil)
    Severity: Minor
    Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

      Function constructIdentOutResultHandler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static func constructIdentOutResultHandler<IdType: Identifier, OutputType: Codable>(successStatus: HTTPStatusCode = .OK, response: RouterResponse, completion: @escaping () -> Void) -> IdentifierCodableResultClosure<IdType, OutputType> {
              return { id, 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 handleHeaderLine has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private func handleHeaderLine(_ line: String, part: inout Part) {
                if let labelRange = getLabelRange(of: "content-type:", in: line) {
                    part.type = String(line[line.index(after: labelRange.upperBound)...])
                    part.headers[.type] = line
                    return
        Severity: Minor
        Found in Sources/Kitura/bodyParser/MultiPartBodyParser.swift - About 1 hr to fix

          Function performServerTest has 29 lines of code (exceeds 25 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]) {
                  if sslOption != SSLOption.httpsOnly {
                      self.useSSL = false
                      if socketTypeOption != SocketTypeOption.unix {
          Severity: Minor
          Found in Tests/KituraTests/KituraTest.swift - About 1 hr to fix

            Function send has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public func send<T : Encodable>(jsonp: T, callbackParameter: String = "callback") throws -> RouterResponse {
                    guard !state.invokedEnd else {
                        Log.warning("RouterResponse send(jsonp:) invoked after end() for \(self.request.urlURL)")
                        return self
                    }
            Severity: Minor
            Found in Sources/Kitura/RouterResponse.swift - About 1 hr to fix

              Function getFilePath has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      func getFilePath(from request: RouterRequest) -> String? {
                          var filePath = servingFilesPath
                          guard let requestPath = request.parsedURLPath.path else {
                              return nil
                          }
              Severity: Minor
              Found in Sources/Kitura/staticFileServer/FileServer.swift - About 1 hr to fix

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

                        get(route) { request, response, next in
                            Log.verbose("Received GET(Array) typed middleware request")
                            self.handleMiddleware(T.self, request: request, response: response) { typeSafeMiddleware in
                                guard let typeSafeMiddleware = typeSafeMiddleware else {
                                    return next()
                Severity: Major
                Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 3 other locations - About 1 hr to fix
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 57..65
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 405..413
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 965..973

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

                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 4 locations. Consider refactoring.
                Open

                        get(route) { request, response, next in
                            Log.verbose("Received GET(Array) with identifier typed middleware request")
                            self.handleMiddleware(T.self, request: request, response: response) { typeSafeMiddleware in
                                guard let typeSafeMiddleware = typeSafeMiddleware else {
                                    return next()
                Severity: Major
                Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 3 other locations - About 1 hr to fix
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 57..65
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 167..175
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 965..973

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

                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 4 locations. Consider refactoring.
                Open

                        get(route) { request, response, next in
                            Log.verbose("Received GET(Single) typed middleware request")
                            self.handleMiddleware(T.self, request: request, response: response) { typeSafeMiddleware in
                                guard let typeSafeMiddleware = typeSafeMiddleware else {
                                    return next()
                Severity: Major
                Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 3 other locations - About 1 hr to fix
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 167..175
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 405..413
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 965..973

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

                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 4 locations. Consider refactoring.
                Open

                        delete(route) { request, response, next in
                            Log.verbose("Received DELETE (plural with middleware) type-safe request")
                            self.handleMiddleware(T.self, request: request, response: response) { typeSafeMiddleware in
                                guard let typeSafeMiddleware = typeSafeMiddleware else {
                                    return next()
                Severity: Major
                Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 3 other locations - About 1 hr to fix
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 57..65
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 167..175
                Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 405..413

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

                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

                        delete(appendId(path: route)) { request, response, next in
                            Log.verbose("Received DELETE (singular) type-safe request")
                            guard let identifier = CodableHelpers.parseIdOrSetResponseStatus(Id.self, from: request, response: response) else {
                                next()
                                return
                Severity: Major
                Found in Sources/Kitura/CodableRouter.swift and 1 other location - About 1 hr to fix
                Sources/Kitura/CodableRouter.swift on lines 539..546

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

                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

                        get(appendId(path: route)) { request, response, next in
                            Log.verbose("Received GET (singular with identifier) type-safe request")
                            guard let identifier = CodableHelpers.parseIdOrSetResponseStatus(Id.self, from: request, response: response) else {
                                next()
                                return
                Severity: Major
                Found in Sources/Kitura/CodableRouter.swift and 1 other location - About 1 hr to fix
                Sources/Kitura/CodableRouter.swift on lines 567..574

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

                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 4 locations. Consider refactoring.
                Open

                        let stringTuple: [(String, User)] = [("1", User(id: 1, name: "Andy")), ("2", User(id: 2, name: "Dave")), ("3", User(id: 3, name: "Ian"))]
                Severity: Major
                Found in Tests/KituraTests/TestCodableRouter.swift and 3 other locations - About 1 hr to fix
                Tests/KituraTests/TestCodableRouter.swift on lines 297..297
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 293..293
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 316..316

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

                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 4 locations. Consider refactoring.
                Open

                        let intTuple: [(Int, User)] = [(1, User(id: 1, name: "Andy")), (2, User(id: 2, name: "Dave")), (3, User(id: 3, name: "Ian"))]
                Severity: Major
                Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 3 other locations - About 1 hr to fix
                Tests/KituraTests/TestCodableRouter.swift on lines 297..297
                Tests/KituraTests/TestCodableRouter.swift on lines 301..301
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 293..293

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

                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 4 locations. Consider refactoring.
                Open

                        let intTuple: [(Int, User)] = [(1, User(id: 1, name: "Andy")), (2, User(id: 2, name: "Dave")), (3, User(id: 3, name: "Ian"))]
                Severity: Major
                Found in Tests/KituraTests/TestCodableRouter.swift and 3 other locations - About 1 hr to fix
                Tests/KituraTests/TestCodableRouter.swift on lines 301..301
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 293..293
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 316..316

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

                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

                    struct CodableDate: Codable, Equatable {
                        let date: Date
                        
                        init(date: Date) {
                            self.date = date
                Severity: Major
                Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 2 other locations - About 1 hr to fix
                Tests/KituraTests/TestCodableRouter.swift on lines 61..71
                Tests/KituraTests/TestCustomCoders.swift on lines 33..41

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

                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

                    static var allTests: [(String, (TestSubrouter) -> () throws -> Void)] {
                        return [
                            ("testSimpleSub", testSimpleSub),
                            ("testExternSub", testExternSub),
                            ("testSubSubs", testSubSubs),
                Severity: Major
                Found in Tests/KituraTests/TestSubrouter.swift and 1 other location - About 1 hr to fix
                Tests/KituraTests/TestCookies.swift on lines 44..52

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

                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

                    struct CodableDate: Codable, Equatable {
                        let date: Date
                        init(date: Date) {
                            self.date = date
                        }
                Severity: Major
                Found in Tests/KituraTests/TestCustomCoders.swift and 2 other locations - About 1 hr to fix
                Tests/KituraTests/TestCodableRouter.swift on lines 61..71
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 86..95

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

                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

                    struct Conflict: Codable, Equatable {
                        let field: String
                
                        init(on field: String) {
                            self.field = field
                Severity: Major
                Found in Tests/KituraTests/TestCodableRouter.swift and 2 other locations - About 1 hr to fix
                Tests/KituraTests/TestCustomCoders.swift on lines 33..41
                Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 86..95

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

                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

                Severity
                Category
                Status
                Source
                Language