avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Similar blocks of code found in 5 locations. Consider refactoring.
Open

            with unittest.mock.patch(
                "builtins.open", return_value=self._get_data_mock("s390x")
            ):
                self.assertEqual(len(cpu.online_list()), 2)
Severity: Major
Found in selftests/unit/utils/cpu.py and 4 other locations - About 1 hr to fix
selftests/unit/utils/cpu.py on lines 29..32
selftests/unit/utils/cpu.py on lines 33..36
selftests/unit/utils/cpu.py on lines 37..40
selftests/unit/utils/cpu.py on lines 43..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

            with unittest.mock.patch(
                "builtins.open", return_value=self._get_data_mock("s390x_4")
            ):
                self.assertEqual(len(cpu.online_list()), 16)
Severity: Major
Found in selftests/unit/utils/cpu.py and 4 other locations - About 1 hr to fix
selftests/unit/utils/cpu.py on lines 25..28
selftests/unit/utils/cpu.py on lines 29..32
selftests/unit/utils/cpu.py on lines 33..36
selftests/unit/utils/cpu.py on lines 43..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

            with unittest.mock.patch(
                "builtins.open", return_value=self._get_data_mock("s390x_3")
            ):
                self.assertEqual(len(cpu.online_list()), 6)
Severity: Major
Found in selftests/unit/utils/cpu.py and 4 other locations - About 1 hr to fix
selftests/unit/utils/cpu.py on lines 25..28
selftests/unit/utils/cpu.py on lines 29..32
selftests/unit/utils/cpu.py on lines 37..40
selftests/unit/utils/cpu.py on lines 43..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def test_master_connection_no_password(self):
        session = ssh.Session("hostname", user="user")
        master_connection = session._master_connection()
        self.assertIn(" -o 'PasswordAuthentication=no'", master_connection)
Severity: Major
Found in selftests/unit/utils/ssh.py and 1 other location - About 1 hr to fix
selftests/unit/utils/ssh.py on lines 32..35

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(self):
        help_msg = (
            "Enable or disable sysinfo collection (like hardware "
            "details, profiles, etc.)"
        )
Severity: Minor
Found in avocado/plugins/sysinfo.py - About 1 hr to fix

    Function getoutput has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def getoutput(
    Severity: Major
    Found in avocado/utils/process.py - About 1 hr to fix

      Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in avocado/utils/process.py - About 1 hr to fix

        Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in avocado/utils/process.py - About 1 hr to fix

          Function getstatusoutput has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def getstatusoutput(
          Severity: Major
          Found in avocado/utils/process.py - About 1 hr to fix

            Function _examine_same_module has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def _examine_same_module(
            Severity: Major
            Found in avocado/core/safeloader/core.py - About 1 hr to fix

              Function from_parameters has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def from_parameters(
              Severity: Major
              Found in avocado/utils/vmimage.py - About 1 hr to fix

                Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(
                Severity: Major
                Found in avocado/utils/vmimage.py - About 1 hr to fix

                  Function _node_content_from_node has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _node_content_from_node(path, node, values, using):
                      """Processes node values into the current node content"""
                      for value in values:
                          if isinstance(value, mux.MuxTreeNode):
                              node.add_child(value)

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

                  def python_resolver(name, reference, find_tests):
                      module_path, tests_filter = reference_split(reference)
                      if tests_filter is not None:
                          tests_filter = re.compile(tests_filter)
                  
                  
                  Severity: Minor
                  Found in avocado/plugins/resolvers.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 test_all_commands has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def test_all_commands(self):
                          command_name = "service"
                          # Test all commands except "set_target" which is tested elsewhere
                          for cmd, _ in (
                              (c, r)
                  Severity: Minor
                  Found in selftests/unit/utils/service.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 end_test has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def end_test(self, result, state):
                          """
                          Create the ResultsDB result, which corresponds to one test from
                          the Avocado Job
                          """
                  Severity: Minor
                  Found in optional_plugins/resultsdb/avocado_resultsdb/resultsdb.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 check_installed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def check_installed(self, name, version=None, arch=None):
                          """
                          Check if package [name] is installed.
                  
                          :param name: Package name.
                  Severity: Minor
                  Found in avocado/utils/software_manager/backends/rpm.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_source has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get_source(self, name, dest_path, build_option=None):
                          """
                          Downloads the source package and prepares it in the given dest_path
                          to be ready to build.
                  
                  
                  Severity: Minor
                  Found in avocado/utils/software_manager/backends/yum.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 vg_ramdisk has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def vg_ramdisk(
                      disk,
                      vg_name,
                      ramdisk_vg_size,
                      ramdisk_basedir,
                  Severity: Minor
                  Found in avocado/utils/lv_utils.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 vg_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def vg_list(vg_name=None):
                      """
                      List all info about available volume groups.
                  
                      :param vg_name: name of the volume group to list or or None to list all
                  Severity: Minor
                  Found in avocado/utils/lv_utils.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

                  Severity
                  Category
                  Status
                  Source
                  Language