IBM-Swift/Kitura

View on GitHub

Showing 850 of 850 total issues

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

        do {
            _ = try JSONDecoder().decode(TestCodable.self, from: testJSON.data(using: .utf8)!)
            XCTFail("We should have had a decoding error.")
        } catch  {
            if let decodingError = error as? DecodingError {
Severity: Major
Found in Tests/KituraTests/TestDecodingErrorExtension.swift and 3 other locations - About 30 mins to fix
Tests/KituraTests/TestDecodingErrorExtension.swift on lines 45..57
Tests/KituraTests/TestDecodingErrorExtension.swift on lines 95..104
Tests/KituraTests/TestDecodingErrorExtension.swift on lines 120..135

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

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

    public func setOnEndInvoked(_ newOnEndInvoked: @escaping LifecycleHandler) -> LifecycleHandler {
        let oldOnEndInvoked = lifecycle.onEndInvoked
        lifecycle.onEndInvoked = newOnEndInvoked
        return oldOnEndInvoked
    }
Severity: Minor
Found in Sources/Kitura/RouterResponse.swift and 1 other location - About 30 mins to fix
Sources/Kitura/RouterResponse.swift on lines 465..469

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

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

    public func setWrittenDataFilter(_ newWrittenDataFilter: @escaping WrittenDataFilter) -> WrittenDataFilter {
        let oldWrittenDataFilter = lifecycle.writtenDataFilter
        lifecycle.writtenDataFilter = newWrittenDataFilter
        return oldWrittenDataFilter
    }
Severity: Minor
Found in Sources/Kitura/RouterResponse.swift and 1 other location - About 30 mins to fix
Sources/Kitura/RouterResponse.swift on lines 455..459

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

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("/userMultiMiddleware") { (middleware: UserMiddleware, middleware2: UserMiddleware2, middleware3: UserMiddleware3, query: MyQuery, respondWith: ([User]?, RequestError?) -> Void) in
            print("GET array with parameters on /userMultiMiddleware - received headers \(middleware.header), \(middleware2.header), \(middleware3.header)")
            let matchedUsers = userArray.filter { $0.id <=  query.id }
            respondWith(matchedUsers, nil)
        }
Severity: Minor
Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 1 other location - About 30 mins to fix
Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 415..419

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

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

/**
 * Copyright IBM Corporation 2015
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
Severity: Minor
Found in Tests/KituraTests/MiscellaneousTests.swift and 1 other location - About 30 mins to fix
Tests/KituraTests/MiscellaneousTests.swift on lines 1..104

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

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

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 XCTFail()
    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 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 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 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 (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 nil
                  Severity: Major
                  Found in Sources/Kitura/MimeTypeAcceptor.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 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 ""
                        Severity: Major
                        Found in Sources/Kitura/staticFileServer/StaticFileServer.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 RawBodyParser()
                            Severity: Major
                            Found in Sources/Kitura/bodyParser/BodyParser.swift - About 30 mins to fix

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

                                      get(route) { request, response, next in
                                          Log.verbose("Received GET (single no-identifier) type-safe request")
                                          handler(CodableHelpers.constructOutResultHandler(response: response, completion: next))
                                      }
                              Severity: Major
                              Found in Sources/Kitura/CodableRouter.swift and 3 other locations - About 30 mins to fix
                              Sources/Kitura/CodableRouter.swift on lines 438..441
                              Sources/Kitura/CodableRouter.swift on lines 450..453
                              Sources/Kitura/CodableRouter.swift on lines 555..558

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

                              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