IBM-Swift/Kitura

View on GitHub
Sources/Kitura/staticFileServer/FileServer.swift

Summary

Maintainability
C
1 day
Test Coverage

Function serveNonDirectoryFile has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

        private func serveNonDirectoryFile(_ filePath: String, response: RouterResponse) {
            if  !isValidFilePath(filePath) {
                return
            }

Severity: Minor
Found in Sources/Kitura/staticFileServer/FileServer.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

Function serveNonDirectoryFile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private func serveNonDirectoryFile(_ filePath: String, response: RouterResponse) {
            if  !isValidFilePath(filePath) {
                return
            }

Severity: Minor
Found in Sources/Kitura/staticFileServer/FileServer.swift - About 1 hr to fix

    Function getFilePath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            func getFilePath(from request: RouterRequest) -> String? {
                var filePath = servingFilesPath
                guard let requestPath = request.parsedURLPath.path else {
                    return nil
                }
    Severity: Minor
    Found in Sources/Kitura/staticFileServer/FileServer.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 getFilePath has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            func getFilePath(from request: RouterRequest) -> String? {
                var filePath = servingFilesPath
                guard let requestPath = request.parsedURLPath.path else {
                    return nil
                }
    Severity: Minor
    Found in Sources/Kitura/staticFileServer/FileServer.swift - About 1 hr to fix

      Function serveExistingFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              private func serveExistingFile(_ filePath: String, requestPath: String, queryString: String,
                                             isDirectory: Bool, response: RouterResponse) {
      Severity: Minor
      Found in Sources/Kitura/staticFileServer/FileServer.swift - About 35 mins to fix

        Function serveExistingFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                private func serveExistingFile(_ filePath: String, requestPath: String, queryString: String,
                                               isDirectory: Bool, response: RouterResponse) {
                    if isDirectory {
                        if redirect {
                            do {
        Severity: Minor
        Found in Sources/Kitura/staticFileServer/FileServer.swift - About 35 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

        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

          There are no issues that match your filters.

          Category
          Status