dave-shawley/ietfparse

View on GitHub

Showing 9 of 18 total issues

Function select_content_type has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring.
Open

def select_content_type(
    requested: abc.Sequence[datastructures.ContentType],
    available: abc.Sequence[datastructures.ContentType]
) -> tuple[datastructures.ContentType, datastructures.ContentType]:
    """Selects the best content type.
Severity: Minor
Found in ietfparse/algorithms.py - About 3 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_accept has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
Open

def parse_accept(header_value: str,
                 strict: bool = False) -> list[datastructures.ContentType]:
    """Parse an HTTP accept-like header.

    :param header_value: the header value to parse
Severity: Minor
Found in ietfparse/headers.py - 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 parse_link has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

def parse_link(header_value: str,
               strict: bool = True) -> list[datastructures.LinkHeader]:
    """
    Parse a HTTP Link header.

Severity: Minor
Found in ietfparse/headers.py - 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

Avoid deeply nested control flow statements.
Open

                    if extract_quality(pattern) == 0.0:
                        raise errors.NoMatch  # quality of 0 means NO
                    return candidate, pattern
Severity: Major
Found in ietfparse/algorithms.py - About 45 mins to fix

    Function _parse_parameter_list has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
    Open

    def _parse_parameter_list(
            parameter_list: abc.Iterable[str],
            normalize_parameter_names: bool = False,
            normalize_parameter_values: bool = True,
            strip_interior_whitespace: bool = False) -> list[tuple[str, str]]:
    Severity: Minor
    Found in ietfparse/headers.py - 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 1
    Severity: Major
    Found in ietfparse/headers.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return self.content_type < other.content_type
      Severity: Major
      Found in ietfparse/datastructures.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return self.content_subtype < other.content_subtype
        Severity: Major
        Found in ietfparse/datastructures.py - About 30 mins to fix

          Function parse_cache_control has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
          Open

          def parse_cache_control(
                  header_value: str) -> dict[str, str | int | bool | None]:
              """
              Parse a `Cache-Control`_ header, returning a dictionary of key-value pairs.
          
          
          Severity: Minor
          Found in ietfparse/headers.py - 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

          Severity
          Category
          Status
          Source
          Language