ARMmbed/mbed-tools

View on GitHub
src/mbed_tools/devices/_internal/file_parser.py

Summary

Maintainability
A
35 mins
Test Coverage

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

def _read_details_txt(file_contents: str) -> dict:
    """Parse the contents of a daplink-compatible device's details.txt.

    Args:
        file_contents: The contents of the details.txt file.
Severity: Minor
Found in src/mbed_tools/devices/_internal/file_parser.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

Function _read_htm_file_contents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

def _read_htm_file_contents(all_files: Iterable[pathlib.Path]) -> List[str]:
    htm_files_contents = []
    for file in all_files:
        if _is_htm_file(file):
            contents = _try_read_file_text(file)
Severity: Minor
Found in src/mbed_tools/devices/_internal/file_parser.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

Function _read_first_details_txt_contents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

def _read_first_details_txt_contents(file_paths: Iterable[pathlib.Path]) -> dict:
    for path in file_paths:
        if _is_details_txt(path):
            contents = _try_read_file_text(path)
            if contents:
Severity: Minor
Found in src/mbed_tools/devices/_internal/file_parser.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

There are no issues that match your filters.

Category
Status