IBM-Swift/Kitura

View on GitHub

Showing 850 of 850 total issues

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

        router.put("/fruit/") { (id: Int, fruit: Fruit, respondWith: (Fruit?, RequestError?) -> Void) in
            respondWith(Fruit(name: fruit.name, id: id), nil)
        }
Severity: Major
Found in Tests/KituraTests/TestCodablePathParams.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestCodablePathParams.swift on lines 73..75

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

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

        router.patch("/fruit/") { (id: Int, fruit: Fruit, respondWith: (Fruit?, RequestError?) -> Void) in
            respondWith(Fruit(name: fruit.name, id: id), nil)
        }
Severity: Major
Found in Tests/KituraTests/TestCodablePathParams.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestCodablePathParams.swift on lines 70..72

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

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

    func testRenderWithExtensionAndWithoutDefaultTemplateEngine() {
        let router = Router()
        router.add(templateEngine: MockTemplateEngine())

        do {
Severity: Major
Found in Tests/KituraTests/TestTemplateEngine.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestTemplateEngine.swift on lines 111..121

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

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

    func testMissingExtensionCodable() {
        let router = Router()
        router.setDefault(templateEngine: MockTemplateEngine())
        
        do {
Severity: Major
Found in Tests/KituraTests/TestTemplateEngine.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestTemplateEngine.swift on lines 296..307

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

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

        router.post("/error/users") { (user: User, respondWith: (Int?, User?, RequestError?) -> Void) in
            print("POST on /error/users for user \(user)")
            respondWith(nil, nil, .conflict)
        }
Severity: Major
Found in Tests/KituraTests/TestCodableRouter.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestCodableRouter.swift on lines 501..504

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

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

    func testRender() {
        let router = Router()
        router.setDefault(templateEngine: MockTemplateEngine())

        do {
Severity: Major
Found in Tests/KituraTests/TestTemplateEngine.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestTemplateEngine.swift on lines 216..226

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

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

        router.post("/noBody") { (data: User, respondWith: (Int?, User?, RequestError?) -> Void) in
            print("POST on /noBody")
            respondWith(1, nil, .noContent)
        }
Severity: Major
Found in Tests/KituraTests/TestCodableRouter.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestCodableRouter.swift on lines 203..206

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

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

    func testEmptyTemplateNameCodable() {
        let router = Router()
        router.setDefault(templateEngine: MockTemplateEngine())
        
        do {
Severity: Major
Found in Tests/KituraTests/TestTemplateEngine.swift and 1 other location - About 1 hr to fix
Tests/KituraTests/TestTemplateEngine.swift on lines 309..320

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

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

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

    func testExternSub() {
        router.all("/extern", middleware: ExternSubrouter.getRouter())

        performServerTest(router, asyncTasks: { expectation in
            self.performRequest("get", path:"/extern", callback: {response in
Severity: Minor
Found in Tests/KituraTests/TestSubrouter.swift - About 1 hr to fix

    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 testBasicDelete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func testBasicDelete() {
              router.delete("/users") { (respondWith: (RequestError?) -> Void) in
                  print("DELETE on /users")
                  self.userStore.removeAll()
                  respondWith(nil)
      Severity: Minor
      Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

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

            func testConnectionRejection() {
                let numClients = 5  // Number of clients to connect
                let maxClients = 2  // Maximum number of concurrent clients
        
                // Create client status objects and expectations
        Severity: Minor
        Found in Tests/KituraTests/TestServerOptions.swift - About 1 hr to fix

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

              func testMultipleMiddlewareDeleteOptionalParameters() {
                  var userArray1 = [User(id: 1, name: "Andy"), User(id: 2, name: "Dave"), User(id: 3, name: "Ian")]
                  var userArray2 = [User(id: 1, name: "Andy"), User(id: 2, name: "Dave"), User(id: 3, name: "Ian")]
                  
                  router.delete("/userMultiMiddleware") { (middleware: UserMiddleware, middleware2: UserMiddleware2, middleware3: UserMiddleware3, query: MyQuery?, respondWith: (RequestError?) -> Void) in
          Severity: Minor
          Found in Tests/KituraTests/TestTypeSafeMiddleware.swift - About 1 hr to fix

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

                func testRawDataPost() {
                    performServerTest(router) { expectation in
                        self.performRequest("post",
                                            path: "/bodytest",
                                            callback: { response in
            Severity: Minor
            Found in Tests/KituraTests/TestResponse.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

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

                              router.get("/fruit") { (id: Int, respondWith: (Fruit?, RequestError?) -> Void) in
                                  print("GET on /fruit (implicit :id)")
                                  respondWith(Fruit(name: "banana", id: id), nil)
                              }
                      Severity: Major
                      Found in Tests/KituraTests/TestCodablePathParams.swift and 1 other location - About 1 hr to fix
                      Tests/KituraTests/TestCodablePathParams.swift on lines 189..192

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

                      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

                              router.get("/fruit/:id") { (id: Int, respondWith: (Fruit?, RequestError?) -> Void) in
                                  print("GET on /fruit/:id")
                                  respondWith(Fruit(name: "banana", id: id), nil)
                              }
                      Severity: Major
                      Found in Tests/KituraTests/TestCodablePathParams.swift and 1 other location - About 1 hr to fix
                      Tests/KituraTests/TestCodablePathParams.swift on lines 164..167

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

                      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