avocado-framework/avocado

View on GitHub
avocado/utils/distro.py

Summary

Maintainability
C
1 day
Test Coverage
B
82%

File distro.py has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
Severity: Minor
Found in avocado/utils/distro.py - About 5 hrs to fix

    Function name_for_file_contains has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def name_for_file_contains(self):
            """
            Get the distro if the :attr:`CHECK_FILE` is set and has content
            """
            if self.check_name_for_file_contains():
    Severity: Minor
    Found in avocado/utils/distro.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 _get_version_match has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_version_match(self):
            """
            Returns the match result for the version regex on the file content
            """
            if self.check_version():
    Severity: Minor
    Found in avocado/utils/distro.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 get_distro has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_distro(self):
            """
            :param session: ssh connection between another machine
    
            Returns the :class:`LinuxDistro` this probe detected
    Severity: Minor
    Found in avocado/utils/distro.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, name, min_version=None, min_release=None, arch=None):
    Severity: Minor
    Found in avocado/utils/distro.py - About 35 mins to fix

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

          def get_distro(self):
              distro = super().get_distro()
      
              # if the default methods find SUSE, detect version
              if not distro.name == self.CHECK_FILE_DISTRO_NAME:
      Severity: Minor
      Found in avocado/utils/distro.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 release has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def release(self):
              """
              Returns the release of the distro
              """
              release = UNKNOWN_DISTRO_RELEASE
      Severity: Minor
      Found in avocado/utils/distro.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