albertyw/req-update

View on GitHub
req_update/python.py

Summary

Maintainability
C
7 hrs
Test Coverage
A
99%

Function install_updates has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def install_updates(self) -> None:
        """Install requirements updates"""
        for updated_file in self.updated_files:
            if updated_file in REQUIREMENTS_FILES:
                command = ['pip', 'install', '-r', updated_file]
Severity: Minor
Found in req_update/python.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 write_dependency_update_lines has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def write_dependency_update_lines(
        self, dependency: str, version: str, lines: list[str], file_type: str,
    ) -> bool:
        """
        Given a dependency and some lines, update the lines.  Return a
Severity: Minor
Found in req_update/python.py - 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 check_applicable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def check_applicable(self) -> bool:
        # Make sure pip is recent enough
        command = ['pip', '--version']
        try:
            result = self.util.execute_shell(
Severity: Minor
Found in req_update/python.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 True
Severity: Major
Found in req_update/python.py - About 30 mins to fix

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

        def write_dependency_update(self, dependency: str, version: str) -> bool:
            """Given a dependency, update it to a given version"""
            updated = False
            for reqfile in REQUIREMENTS_FILES:
                with Python.edit_requirements(reqfile, self.util.dry_run) as lines:
    Severity: Minor
    Found in req_update/python.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