IBM-Swift/Kitura

View on GitHub

Showing 850 of 850 total issues

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

    public func patch<T1: TypeSafeMiddleware, T2: TypeSafeMiddleware, Id: Identifier, I: Codable, O: Codable>(
        _ route: String,
        handler: @escaping (T1, T2, Id, I, @escaping CodableResultClosure<O>) -> Void
    ) {
        if !pathSyntaxIsValid(route, identifierExpected: true) {
Severity: Major
Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 1 other location - About 4 hrs to fix
Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 1774..1796

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

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 testMultipleMiddlewareGetSingletonParameters() {
        // Expected user: User(id: 1, name: "Andy")
        guard let user = userStore[1] else {
            XCTFail("no value found for userStore[1]")
            return
Severity: Major
Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 1 other location - About 4 hrs to fix
Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 256..290

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

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 testMultipleMiddlewareGetIdentifier() {
        // Expected user: User(id: 1, name: "Andy")
        guard let user = userStore[1] else {
            XCTFail("no value found for userStore[1]")
            return
Severity: Major
Found in Tests/KituraTests/TestTypeSafeMiddleware.swift and 1 other location - About 4 hrs to fix
Tests/KituraTests/TestTypeSafeMiddleware.swift on lines 375..409

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

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

TestTypeSafeMiddleware has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

final class TestTypeSafeMiddleware: KituraTest, KituraTestSuite {
    static var allTests: [(String, (TestTypeSafeMiddleware) -> () throws -> Void)] {
        return [
            ("testSingleMiddlewareGetSingleton", testSingleMiddlewareGetSingleton),
            ("testMultipleMiddlewareGetSingleton", testMultipleMiddlewareGetSingleton),
Severity: Minor
Found in Tests/KituraTests/TestTypeSafeMiddleware.swift - About 4 hrs to fix

    File TestRequests.swift has 344 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import XCTest
    import Foundation
    import KituraContracts
    
    @testable import Kitura
    Severity: Minor
    Found in Tests/KituraTests/TestRequests.swift - About 4 hrs to fix

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

          public func put<T: TypeSafeMiddleware, Id: Identifier, I: Codable, O: Codable>(
              _ route: String,
              handler: @escaping (T, Id, I, @escaping CodableResultClosure<O>) -> Void
          ) {
              if !pathSyntaxIsValid(route, identifierExpected: true) {
      Severity: Major
      Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 1 other location - About 4 hrs to fix
      Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 1867..1890

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

      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 patch<T: TypeSafeMiddleware, Id: Identifier, I: Codable, O: Codable>(
              _ route: String,
              handler: @escaping (T, Id, I, @escaping CodableResultClosure<O>) -> Void
          ) {
              if !pathSyntaxIsValid(route, identifierExpected: true) {
      Severity: Major
      Found in Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift and 1 other location - About 4 hrs to fix
      Sources/Kitura/CodableRouter+TypeSafeMiddleware.swift on lines 1733..1755

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

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

          func testSend() {
              performServerTest(router) { expectation in
                  self.performRequest("get", path: "/data", 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: Major
      Found in Tests/KituraTests/TestResponse.swift - About 4 hrs to fix

        Function addCookie has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            public func addCookie(name: String, value: String, domain: String, path: String, otherAttributes: [AdditionalCookieAttribute]? = nil ) {
                var cookieProperties = [HTTPCookiePropertyKey: Any]()
                cookieProperties[HTTPCookiePropertyKey.name] = name
                cookieProperties[HTTPCookiePropertyKey.value] = value
                cookieProperties[HTTPCookiePropertyKey.domain] = domain
        Severity: Minor
        Found in Sources/Kitura/RouterResponse.swift - About 4 hrs 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 testFileServer has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func testFileServer() {
                performServerTest(router, asyncTasks: { expectation in
                    self.performRequest("get", path:"/qwer", 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: Major
        Found in Tests/KituraTests/TestStaticFileServer.swift - About 3 hrs to fix

          Function testMultipartFormParsing has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              func testMultipartFormParsing() {
          
                  // ensure NSData.components works just like String.components
                  dataComponentsTest("AxAyAzA", separator: "A")
                  dataComponentsTest("HelloWorld", separator: "World")
          Severity: Major
          Found in Tests/KituraTests/TestResponse.swift - About 3 hrs to fix

            Function WWW has 92 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var WWW = function() {
                    "use strict";
                    var defaultClassNames = {
                        wrapper: "twitter-typeahead",
                        input: "tt-input",

              Function WWW has 92 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var WWW = function() {
                      "use strict";
                      var defaultClassNames = {
                          wrapper: "twitter-typeahead",
                          input: "tt-input",
              Severity: Major
              Found in docs/js/typeahead.jquery.js - About 3 hrs to fix

                Function testSimplePaths has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    func testSimplePaths() {
                        var router = Router()
                
                        router.all("", handler: handler)
                
                
                Severity: Major
                Found in Tests/KituraTests/TestRouteRegex.swift - About 3 hrs to fix

                  Function EventEmitter has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var EventEmitter = function() {
                          "use strict";
                          var splitter = /\s+/, nextTick = getNextTick();
                          return {
                              onSync: onSync,
                  Severity: Major
                  Found in docs/js/typeahead.jquery.js - About 3 hrs to fix

                    Function EventEmitter has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        var EventEmitter = function() {
                            "use strict";
                            var splitter = /\s+/, nextTick = getNextTick();
                            return {
                                onSync: onSync,

                      Function highlight has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          var highlight = function(doc) {
                              "use strict";
                              var defaults = {
                                  node: null,
                                  pattern: null,

                        Function highlight has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            var highlight = function(doc) {
                                "use strict";
                                var defaults = {
                                    node: null,
                                    pattern: null,
                        Severity: Major
                        Found in docs/js/typeahead.jquery.js - About 3 hrs to fix

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

                              func testSimpleSub() {
                                  performServerTest(router, asyncTasks: { expectation in
                                      self.performRequest("get", path:"/sub", 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: Major
                          Found in Tests/KituraTests/TestSubrouter.swift and 1 other location - About 3 hrs to fix
                          Tests/KituraTests/TestSubrouter.swift on lines 107..134

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

                          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 testSubSubs() {
                                  performServerTest(router, asyncTasks: { expectation in
                                      self.performRequest("get", path:"/sub/sub2", 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: Major
                          Found in Tests/KituraTests/TestSubrouter.swift and 1 other location - About 3 hrs to fix
                          Tests/KituraTests/TestSubrouter.swift on lines 47..74

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

                          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