brennobemoura/request-dl

View on GitHub

Showing 7 of 56 total issues

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

            mutating func next() -> NIOCore.ByteBuffer? {
                guard chunkSize > .zero else {
                    return nil
                }

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

            mutating func next() -> NIOCore.ByteBuffer? {
                guard chunkSize > .zero else {
                    return nil
                }

    Function encode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        func encode(_ string: String) throws -> Data {
            switch self {
            case .utf8:
                return try encode(string, using: .utf8)
            case .isoLatin1:

    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 freeSpace has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        mutating func freeSpace(_ maximumCapacity: UInt64) {
            var accumulatedSize: UInt64 = 0
            var deleteOnly = maximumCapacity == .zero
    
            for key in identifiers.reversed() {

    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 log has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            _ items: Any...,
            level: Level,
            separator: String,
            line: UInt,
            file: StaticString
    Severity: Minor
    Found in Sources/RequestDL/Internals/Sources/Log/Log/Internals.Log.swift - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

                      return next()

        Function freeSpace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            func freeSpace(_ maximumCapacity: UInt64) {
                let entries = records(including: [.fileSizeKey]).sorted {
                    $0.date > $1.date
                }
        
        

        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

        Severity
        Category
        Status
        Source
        Language