IBM-Swift/Kitura

View on GitHub

Showing 850 of 850 total issues

Function cookieToServer has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private func cookieToServer(separator: String, quoteValue: Bool) {
        performServerTest(router, asyncTasks: { expectation in
            let cookieMap = [" Plover ": " value with spaces ",
                           "Zxcv": "(E = mc^2)",
                           "value with one quote": "\"",
Severity: Minor
Found in Tests/KituraTests/TestCookies.swift - About 1 hr to fix

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

            if sslOption != SSLOption.httpOnly {
                self.useSSL = true
                if socketTypeOption != SocketTypeOption.unix {
                    self.useUnixSocket = false
                    doPerformServerTest(router: router, options: options, timeout: timeout, line: line, asyncTasks: asyncTasks)
    Severity: Major
    Found in Tests/KituraTests/KituraTest.swift and 1 other location - About 1 hr to fix
    Tests/KituraTests/KituraTest.swift on lines 119..132

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

    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

            if sslOption != SSLOption.httpsOnly {
                self.useSSL = false
                if socketTypeOption != SocketTypeOption.unix {
                    self.useUnixSocket = false
                    doPerformServerTest(router: router, options: options, timeout: timeout, line: line, asyncTasks: asyncTasks)
    Severity: Major
    Found in Tests/KituraTests/KituraTest.swift and 1 other location - About 1 hr to fix
    Tests/KituraTests/KituraTest.swift on lines 137..150

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

    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

    /**
     * Copyright IBM Corporation 2016
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
    Severity: Major
    Found in Tests/KituraTests/TestResponse.swift and 2 other locations - About 1 hr to fix
    Tests/KituraTests/TestStaticFileServer.swift on lines 1..710
    Tests/KituraTests/TestStaticFileServer.swift on lines 1..710

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

    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 testRangeRequestWithIfRangeHeaderWithOldETag() {
            performServerTest(router) { expectation in
                // if ETag is NOT the same then the entire file (200) should be served
                self.performRequest("get", path: "/qwer/index.html", callback: { response in
                    XCTAssertNotNil(response)
    Severity: Major
    Found in Tests/KituraTests/TestStaticFileServer.swift and 1 other location - About 1 hr to fix
    Tests/KituraTests/TestStaticFileServer.swift on lines 616..627

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

    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 testRangeRequestWithIfRangeHeaderAsOldLastModified() {
            // Range request with If-Range with etag
            performServerTest(router) { expectation in
                // if Last-Modified is NOT the same then the entire file (200) should be served
                self.performRequest("get", path: "/qwer/index.html", callback: { response in
    Severity: Major
    Found in Tests/KituraTests/TestStaticFileServer.swift and 1 other location - About 1 hr to fix
    Tests/KituraTests/TestStaticFileServer.swift on lines 578..589

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

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

        func testCodableGetArrayQueryParameters() {
            /// Currently the milliseconds are cut off by our date formatter
            /// This synchronizes it for testing with the codable route
            let date: Date = Coder.defaultDateFormatter.date(from: Coder.defaultDateFormatter.string(from: Date()))!
    
    
    Severity: Minor
    Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

      Function testBasicGetIdentifiersArray has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          func testBasicGetIdentifiersArray() {
              let intTuple: [(Int, User)] = [(1, User(id: 1, name: "Andy")), (2, User(id: 2, name: "Dave")), (3, User(id: 3, name: "Ian"))]
              // expectedIntData = [["1": User(id: 1, name: "Andy")], ["2": User(id: 2, name: "Dave")], ["3": User(id: 3, name: "Ian")]]
              let expectedIntData: [[String: User]] = intTuple.map({ [$0.value: $1] })
              
      Severity: Minor
      Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

        Function testCodableGetSingleQueryParameters has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            func testCodableGetSingleQueryParameters() {
                let date: Date = Coder.defaultDateFormatter.date(from: Coder.defaultDateFormatter.string(from: Date()))!
        
                let expectedQuery = MyQuery(intField: 23, optionalIntField: 282, stringField: "a string", intArray: [1, 2, 3], dateField: date, optionalDateField: date, nested: Nested(nestedIntField: 333, nestedStringField: "nested string"))
        
        
        Severity: Minor
        Found in Tests/KituraTests/TestCodableRouter.swift - About 1 hr to fix

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

                  buildServerTest(router, timeout: 30)
                      .request("get", path: "/query\(queryStr)")
                      .hasStatus(.OK)
                      .hasContentType(withPrefix: "application/json")
                      .hasData(expectedQuery)
          Severity: Major
          Found in Tests/KituraTests/TestCodableRouter.swift and 1 other location - About 1 hr to fix
          Tests/KituraTests/TestCodableRouter.swift on lines 371..384

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

          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

                  buildServerTest(router, timeout: 30)
                      .request("get", path: "/users/1")
                      .hasStatus(.OK)
                      .hasContentType(withPrefix: "application/json")
                      .hasData(user)
          Severity: Major
          Found in Tests/KituraTests/TestCodableRouter.swift and 1 other location - About 1 hr to fix
          Tests/KituraTests/TestCodableRouter.swift on lines 689..702

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

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

              func testAcceptEncodingTypes() {
                  router.get("/customPage") { request, response, next in
                      XCTAssertEqual(request.accepts(header: "Accept-Encoding", type: "gzip"), "gzip", "Accepts did not return expected value")
                      XCTAssertEqual(request.accepts(header: "Accept-Encoding", types: "compress"), "compress", "Accepts did not return expected value")
                      XCTAssertEqual(request.accepts(header: "Accept-Encoding", types: ["compress", "gzip"]), "gzip", "Accepts did not return expected value")
          Severity: Minor
          Found in Tests/KituraTests/TestResponse.swift - About 1 hr to fix

            Function testMultipartFormParsing has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                func testMultipartFormParsing() {
            
                    // ensure NSData.components works just like String.components
                    dataComponentsTest("AxAyAzA", separator: "A")
                    dataComponentsTest("HelloWorld", separator: "World")
            Severity: Minor
            Found in Tests/KituraTests/TestResponse.swift - About 1 hr 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 testPostJSONRequest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                func testPostJSONRequest() {
                    let jsonToTest = SomeJSON()
            
                    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

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

                    function Typeahead(o, www) {
                        var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged;
                        o = o || {};
                        if (!o.input) {
                            $.error("missing input");
            Severity: Minor
            Found in docs/js/typeahead.jquery.js - About 1 hr to fix

              Function testNoCookies has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  func testNoCookies() {
                      performServerTest(router, asyncTasks: { expectation in
                          self.performRequest("get", path: "/1/cookiedump", callback: {response in
                              XCTAssertEqual(response?.statusCode, HTTPStatusCode.OK, "cookiedump route did not match single path request")
                              do {
              Severity: Minor
              Found in Tests/KituraTests/TestCookies.swift - About 1 hr to fix

                Function EventBus has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    var EventBus = function() {
                        "use strict";
                        var namespace, deprecationMap;
                        namespace = "typeahead:";
                        deprecationMap = {
                Severity: Minor
                Found in docs/js/typeahead.jquery.js - About 1 hr to fix

                  Function EventBus has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var EventBus = function() {
                          "use strict";
                          var namespace, deprecationMap;
                          namespace = "typeahead:";
                          deprecationMap = {

                    Function Typeahead has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function Typeahead(o, www) {
                                var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged;
                                o = o || {};
                                if (!o.input) {
                                    $.error("missing input");

                      Function testCustomCoder has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          func testCustomCoder() {
                              let jsonEncoder: () -> BodyEncoder = {
                                  let encoder = JSONEncoder()
                                  encoder.dateEncodingStrategy = .secondsSince1970
                                  return encoder
                      Severity: Minor
                      Found in Tests/KituraTests/TestCustomCoders.swift - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language