IBM-Swift/Kitura

View on GitHub
Tests/KituraTests/TestServerOptions.swift

Summary

Maintainability
C
1 day
Test Coverage

Function testConnectionRejectionCustomResponse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    func testConnectionRejectionCustomResponse() {
        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 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 testConnectionRejection has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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 testConnectionRejectionCustomResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          func testConnectionRejectionCustomResponse() {
              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 25 mins 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

      TODO found
      Open

                      usleep(1000)  // TODO: properly fix crash when creating ClientRequests concurrently

      TODO found
      Open

                      usleep(1000)  // TODO: properly fix crash when creating ClientRequests concurrently

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

          func testLargePostExceedsLimit() {
              performServerTest(router, options: ServerOptions(requestSizeLimit: 10), timeout: 30) { expectation in
                  // Data that exceeds the request size limit
                  let count = 11
                  let postData = Data(repeating: UInt8.max, count: count)
      Severity: Major
      Found in Tests/KituraTests/TestServerOptions.swift and 1 other location - About 1 hr to fix
      Tests/KituraTests/TestServerOptions.swift on lines 49..63

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

      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 testSmallPostSucceeds() {
              performServerTest(router, options: ServerOptions(requestSizeLimit: 10), timeout: 30) { expectation in
                  // Data that is within request limit
                  let count = 10
                  let postData = Data(repeating: UInt8.max, count: count)
      Severity: Major
      Found in Tests/KituraTests/TestServerOptions.swift and 1 other location - About 1 hr to fix
      Tests/KituraTests/TestServerOptions.swift on lines 67..81

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

      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

          static var allTests: [(String, (TestServerOptions) -> () throws -> Void)] {
              return [
                  ("testSmallPostSucceeds", testSmallPostSucceeds),
                  ("testLargePostExceedsLimit", testLargePostExceedsLimit),
                  ("testRequestSizeLimitCustomResponse", testRequestSizeLimitCustomResponse),
      Severity: Major
      Found in Tests/KituraTests/TestServerOptions.swift and 2 other locations - About 1 hr to fix
      Tests/KituraTests/TestCodablePathParams.swift on lines 24..34
      Tests/KituraTests/TestRouteRegex.swift on lines 52..62

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

      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

              let customResponse: (Int, String) -> (HTTPStatusCode, String)? = { limit, client in
                  return (.badRequest, "Too many connections (more than \(limit))")
              }
      Severity: Minor
      Found in Tests/KituraTests/TestServerOptions.swift and 1 other location - About 45 mins to fix
      Tests/KituraTests/TestServerOptions.swift on lines 86..88

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

      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

              let customResponse: (Int, String) -> (HTTPStatusCode, String)? = { requestLimit, client in
                  return (.badRequest, "Request too large, limit \(requestLimit)")
              }
      Severity: Minor
      Found in Tests/KituraTests/TestServerOptions.swift and 1 other location - About 45 mins to fix
      Tests/KituraTests/TestServerOptions.swift on lines 242..244

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

      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

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

              performServerTest(router, options: ServerOptions(connectionLimit: maxClients, connectionResponseGenerator: customResponse), sslOption: .httpOnly, socketTypeOption: .inet, timeout: 30) { expectation in
                  for i in 0..<numClients {
                      usleep(1000)  // TODO: properly fix crash when creating ClientRequests concurrently
                      self.asyncClientRequest(expectation: clientExpectations[i], status: clientStatus[i])
                  }
      Severity: Minor
      Found in Tests/KituraTests/TestServerOptions.swift and 1 other location - About 40 mins to fix
      Tests/KituraTests/TestServerOptions.swift on lines 207..213

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

      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

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

              performServerTest(router, options: ServerOptions(connectionLimit: maxClients), sslOption: .httpOnly, socketTypeOption: .inet, timeout: 30) { expectation in
                  for i in 0..<numClients {
                      usleep(1000)  // TODO: properly fix crash when creating ClientRequests concurrently
                      self.asyncClientRequest(expectation: clientExpectations[i], status: clientStatus[i])
                  }
      Severity: Minor
      Found in Tests/KituraTests/TestServerOptions.swift and 1 other location - About 40 mins to fix
      Tests/KituraTests/TestServerOptions.swift on lines 248..254

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

      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

      There are no issues that match your filters.

      Category
      Status