avocado-framework/avocado

View on GitHub

Showing 685 of 703 total issues

Avoid deeply nested control flow statements.
Open

                        async with self._state_machine.lock:
                            self._state_machine.triaging.append(runtime_task)
                            runtime_task.status = RuntimeTaskStatus.WAIT
                            await asyncio.sleep(0.1)
                        return
Severity: Major
Found in avocado/core/task/statemachine.py - About 45 mins to fix

    Function find_free_port has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def find_free_port(
    Severity: Minor
    Found in avocado/utils/network/ports.py - About 45 mins to fix

      Function discover has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def discover(self):
              resolutions = []
              for ext in self.extensions:
                  try:
                      results = ext.obj.discover()
      Severity: Minor
      Found in avocado/core/resolver.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 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Minor
      Found in avocado/core/task/statemachine.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if m.group(2).upper().startswith("SKIP"):
                                    if count > 0:
                                        yield self.Error("invalid SKIP directive for plan")
                                    skipped = True
                                else:
        Severity: Major
        Found in avocado/core/tapparser.py - About 45 mins to fix

          Function __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, uid, name, variant=None, no_digits=None):
                  """
                  Constructs a TestID instance
          
                  :param uid: unique test id (within the job)
          Severity: Minor
          Found in avocado/core/test_id.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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def start(self):
                  """Log all collectibles at the start of the event."""
                  os.environ["AVOCADO_SYSINFODIR"] = self.pre_dir
                  for log_hook in self.start_collectibles:
                      # log daemons in profile directory
          Severity: Minor
          Found in avocado/core/sysinfo.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 cleanup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def cleanup(self):
                  """
                  Cleanup the temporary job handlers (dirs, global setting, ...)
                  """
                  self.__stop_job_logging()
          Severity: Minor
          Found in avocado/core/job.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 handle_starttag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle_starttag(self, tag, attrs):
                  if tag != "a":
                      return
                  for attr in attrs:
                      if attr[0] == "href" and re.match(self.pattern, attr[1]):
          Severity: Minor
          Found in avocado/utils/vmimage.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 get_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def get_file(
          Severity: Minor
          Found in avocado/utils/download.py - About 45 mins to fix

            Function check_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def check_file(
                path,
                reference,
                suffix=".py",
                type_check=os.path.isfile,
            Severity: Minor
            Found in avocado/core/resolver.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 _set_collectibles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def _set_collectibles(self):
                    timeout = self.config.get("sysinfo.collect.commands_timeout")
                    locale = self.config.get("sysinfo.collect.locale")
                    if self.profiler:
                        for cmd in self.sysinfo_files["profilers"]:
            Severity: Minor
            Found in avocado/core/sysinfo.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 config_filename has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def config_filename(self):
                    current_distro = distro_detect()
                    if current_distro.name in ["rhel", "fedora"]:
                        if self.distro_is_rhel9_or_later:
                            path = "/etc/NetworkManager/system-connections"
            Severity: Minor
            Found in avocado/utils/network/interfaces.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

            Avoid deeply nested control flow statements.
            Open

                                if key in result:
                                    result[key].add(val)
                                else:
                                    result[key] = {val}
                            else:
            Severity: Major
            Found in avocado/core/safeloader/docstring.py - About 45 mins to fix

              Function _examine_class has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def _examine_class(
              Severity: Minor
              Found in avocado/core/safeloader/core.py - About 45 mins to fix

                Function _extend_test_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _extend_test_list(current, new):
                    for test in new:
                        test_method_name = test[0]
                        found = False
                        for current_test in current:
                Severity: Minor
                Found in avocado/core/safeloader/core.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

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

                test = Runnable(
                    "avocado-instrumented",
                    "examples/tests/sleeptest.py:SleepTest.test",
                    variant={
                        "paths": ["/"],
                Severity: Minor
                Found in examples/jobs/sleepjob_parameters.py and 1 other location - About 45 mins to fix
                selftests/functional/job_api_features.py on lines 41..47

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

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

                    def identifier(self):
                        """Runnable identifier respecting user's format string.
                
                        This is still experimental and we have room for improvements.
                
                
                Severity: Minor
                Found in avocado/core/nrunner/runnable.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

                Avoid deeply nested control flow statements.
                Open

                                    if not _must_key_val_matches(
                                        must_key_val, test_tags, include_empty_key
                                    ):
                                        continue
                
                
                Severity: Major
                Found in avocado/core/tags.py - About 45 mins to fix

                  Function merge_with_arguments has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def merge_with_arguments(self, arg_parse_config):
                          """Merge the current settings with the command-line args.
                  
                          After parsing argument options this method should be executed to have
                          an unified settings.
                  Severity: Minor
                  Found in avocado/core/settings.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

                  Severity
                  Category
                  Status
                  Source
                  Language