avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Function computeNull has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def computeNull(self):
        self.nullable = {}  # pylint: disable=W0201
        tbd = []

        for rulelist in self.rules.values():
Severity: Minor
Found in avocado/utils/external/spark.py - About 4 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

File tags.py has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import stat
import unittest

from avocado.core import resolver, tags
Severity: Minor
Found in selftests/unit/tags.py - About 4 hrs to fix

    File runtime.py has 330 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import itertools
    import os
    from enum import Enum
    
    from avocado.core.dispatcher import TestPostDispatcher, TestPreDispatcher
    Severity: Minor
    Found in avocado/core/task/runtime.py - About 3 hrs to fix

      Function _skip_method_decorator has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      def _skip_method_decorator(function, message, condition, negate):
          """Creates a skip decorator for a method."""
      
          @wraps(function)
          def wrapper(obj, *args, **kwargs):  # pylint: disable=W0613
      Severity: Minor
      Found in avocado/core/decorators.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 install_distro_packages has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def install_distro_packages(distro_pkg_map, interactive=False):
          """
          Installs packages for the currently running distribution
      
          This utility function checks if the currently running distro is a
      Severity: Minor
      Found in avocado/utils/software_manager/distro_packages.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 loaded_module_info has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def loaded_module_info(module_name):
          """
          Get loaded module details: Size and Submodules.
      
          :param module_name: Name of module to search for
      Severity: Minor
      Found in avocado/utils/linux_modules.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 _run_test has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def _run_test(self):
              """
              Auxiliary method to run setup and test method.
              """
              self._tag_start()
      Severity: Minor
      Found in avocado/core/test.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

      File safeloader_core.py has 321 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import os
      import sys
      import unittest
      import unittest.mock
      from collections import OrderedDict
      Severity: Minor
      Found in selftests/unit/safeloader_core.py - About 3 hrs to fix

        File runner_nrunner.py has 321 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/plugins/runner_nrunner.py - About 3 hrs to fix

          Cpu has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Cpu(Test):
              @staticmethod
              def _get_file_mock(content):
                  file_mock = unittest.mock.Mock()
                  file_mock.__enter__ = unittest.mock.Mock(return_value=io.BytesIO(content))
          Severity: Minor
          Found in selftests/unit/utils/cpu.py - About 3 hrs to fix

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

                def test_loggables_not_equal(self):
                    cmd1 = sysinfo_collectible.Command("ls -l")
                    cmd2 = sysinfo_collectible.Command("ls -la")
                    self.assertNotEqual(cmd1, cmd2)
                    file1 = sysinfo_collectible.Logfile("/proc/cpuinfo")
            Severity: Major
            Found in selftests/unit/sysinfo.py and 1 other location - About 3 hrs to fix
            selftests/unit/sysinfo.py on lines 15..21

            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 70.

            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

            Runnable has 30 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Runnable:
                """
                Describes an entity that be executed in the context of a task
            
                A instance of :class:`BaseRunner` is the entity that will actually
            Severity: Minor
            Found in avocado/core/nrunner/runnable.py - About 3 hrs to fix

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

                  def test_loggables_equal(self):
                      cmd1 = sysinfo_collectible.Command("ls -l")
                      cmd2 = sysinfo_collectible.Command("ls -l")
                      self.assertEqual(cmd1, cmd2)
                      file1 = sysinfo_collectible.Logfile("/proc/cpuinfo")
              Severity: Major
              Found in selftests/unit/sysinfo.py and 1 other location - About 3 hrs to fix
              selftests/unit/sysinfo.py on lines 23..29

              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 70.

              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

              File mux.py has 317 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.
              #

                Function _valid_variant has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                    def _valid_variant(variant):
                        """
                        Check the variant for validity of internal filters
                
                        :return: whether the variant is valid or should be ignored/filtered

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

                def resolve(references, hint=None, ignore_missing=True, config=None):
                    resolutions = []
                    hint_references = {}
                
                    if hint:
                Severity: Minor
                Found in avocado/core/resolver.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 get_family has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_family():
                    """Get family name of the cpu like Broadwell, Haswell, power8, power9."""
                    family = None
                    arch = get_arch()
                    if arch == "x86_64" or arch == "i386":
                Severity: Minor
                Found in avocado/utils/cpu.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

                File sysinfo.py has 315 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/sysinfo.py - About 3 hrs to fix

                  GenericParser has 29 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class GenericParser:
                      #
                      #  An Earley parser, as per J. Earley, "An Efficient Context-Free
                      #  Parsing Algorithm", CACM 13(2), pp. 94-102.  Also J. C. Earley,
                      #  "An Efficient Context-Free Parsing Algorithm", Ph.D. thesis,
                  Severity: Minor
                  Found in avocado/utils/external/spark.py - About 3 hrs to fix

                    Function to_str has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def to_str(self, summary, variants, **kwargs):
                            """
                            Return human readable representation
                    
                            The summary/variants accepts verbosity where 0 means silent and
                    Severity: Minor
                    Found in avocado/plugins/json_variants.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

                    Severity
                    Category
                    Status
                    Source
                    Language