IBM-Swift/Kitura

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

Summary

Maintainability
B
6 hrs
Test Coverage

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

    static func parse(size: UInt64, headerValue: String, shouldCombine: Bool = true) throws -> RangeHeader {

        guard let index = headerValue.range(of: "=")?.lowerBound else {
            // malformed
            throw RangeHeader.Error.malformed
Severity: Minor
Found in Sources/Kitura/staticFileServer/RangeHeader.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 parse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static func parse(size: UInt64, headerValue: String, shouldCombine: Bool = true) throws -> RangeHeader {

        guard let index = headerValue.range(of: "=")?.lowerBound else {
            // malformed
            throw RangeHeader.Error.malformed
Severity: Major
Found in Sources/Kitura/staticFileServer/RangeHeader.swift - About 2 hrs to fix

    Function combinedRanges has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static func combinedRanges(ranges: [Range<UInt64>]) -> [Range<UInt64>] {
    
            // map [Range]s to [IndexedRange]s and sort them by range.lowerBound
            var index = 0
            var ordered = ranges.map { range in
    Severity: Minor
    Found in Sources/Kitura/staticFileServer/RangeHeader.swift - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

              return combined
      Severity: Major
      Found in Sources/Kitura/staticFileServer/RangeHeader.swift - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status