IBM-Swift/Kitura

View on GitHub
Sources/Kitura/Router.swift

Summary

Maintainability
B
6 hrs
Test Coverage

Function handle has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public func handle(request: ServerRequest, response: ServerResponse) {
        var decoder: (() -> BodyDecoder)?
        if let contentType = request.headers["Content-Type"]?[0], let mediaType = MediaType(contentTypeHeader: contentType) {
            decoder = decoders[mediaType]
        }
Severity: Minor
Found in Sources/Kitura/Router.swift - About 2 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

File Router.swift has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import KituraNet
import LoggerAPI
import Foundation
import KituraTemplateEngine
import KituraContracts
Severity: Minor
Found in Sources/Kitura/Router.swift - About 2 hrs to fix

    Function handle has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public func handle(request: ServerRequest, response: ServerResponse) {
            var decoder: (() -> BodyDecoder)?
            if let contentType = request.headers["Content-Type"]?[0], let mediaType = MediaType(contentTypeHeader: contentType) {
                decoder = decoders[mediaType]
            }
    Severity: Minor
    Found in Sources/Kitura/Router.swift - About 1 hr to fix

      TODO found
      Open

              //TODO fix the stack
      Severity: Minor
      Found in Sources/Kitura/Router.swift by fixme

      TODO comments should be formatted either as <todo: description> or <todo description></todo></todo:>
      Open

              //TODO fix the stack
      Severity: Minor
      Found in Sources/Kitura/Router.swift by tailor

      todo-syntax

      TODO comments should be defined separately using non-nested single line comments. They should adhere to the <TODO: description> or <TODO(developer-name): description> syntax. Empty TODO comments will be flagged.

      Preferred

      // TODO: <insert mandatory todo comment>
      // TODO(dev-name): <insert mandatory todo comment></insert></insert>

      Not Preferred

      // TODO:
      
      /// TODO: Documentation comments should not have TODOs
      
      //// TODO: Nested comments should not have TODOs
      
      // //TODO: Nested comments should not have TODOs
      
      // TODO: Nested comments should not have TODOs // some comment
      
      //// TODO: Nested comments should not have TODOs

      There are no issues that match your filters.

      Category
      Status