albertyw/req-update

View on GitHub

Showing 13 of 13 total issues

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

    def main(self) -> bool:
        """
        Update all dependencies
        Return if updates were made
        """
Severity: Minor
Found in req_update/req_update.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 find_updated_version has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def find_updated_version(self, dependency: str, original_version: str) -> str:
        if original_version == 'latest':
            self.util.warn('Cannot update docker image when using "latest"')
            return ''
        if dependency.count('/') == 1:
Severity: Minor
Found in req_update/docker.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 update_submodule has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_submodule(self, submodule: Submodule) -> Optional[str]:
        if not submodule.remote_tag and not submodule.remote_commit:
            return None
        version = ''
        if submodule.remote_tag and submodule.remote_commit:
Severity: Minor
Found in req_update/gitsubmodule.py - About 45 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 execute_shell has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def execute_shell(
        self,
        command: list[str],
        readonly: bool,
        cwd: Optional[Path] = None,
Severity: Minor
Found in req_update/util.py - About 45 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 execute_shell has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def execute_shell(
Severity: Minor
Found in req_update/util.py - About 35 mins to fix

    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

      Avoid too many return statements within this function.
      Open

              return True
      Severity: Major
      Found in req_update/util.py - About 30 mins to fix

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

            def compare_versions(self, current: str, proposed: str) -> bool:
                """
                Take the current version and a proposed new version and return a bool
                for whether the new version is a valid upgrade.  The new version is a
                valid upgrade if the version structure matches and the version numbers
        Severity: Minor
        Found in req_update/util.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 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

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

            def update_dependencies(self) -> bool:
                submodules = self.get_submodule_info()
                clean = True
                for submodule in submodules:
                    self.util.log('Checking dependency: %s' % submodule.path)
        Severity: Minor
        Found in req_update/gitsubmodule.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