avocado-framework/avocado

View on GitHub

Showing 490 of 907 total issues

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

    def render(self, result, job):
        json_output = job.config.get("job.run.result.json.output")
        json_enabled = job.config.get("job.run.result.json.enabled")

        if not (json_enabled or json_output):
Severity: Minor
Found in avocado/plugins/jsonresult.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 isinstance(metadata, dict):
                        if metadata.get("type", None) == "vmimage":
                            provider = None
                            for p in vmimage.IMAGE_PROVIDERS:
                                if p.name == metadata["name"]:
Severity: Major
Found in avocado/plugins/vmimage.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if candidate not in candidates:
                                candidates.append(candidate)
    
    
    Severity: Major
    Found in avocado/plugins/assets.py - About 45 mins to fix

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

          def _run_unittest(cls, module_path, module_class_method, queue):
              sys.path.insert(0, module_path)
              stream = io.StringIO()
      
              try:
      Severity: Minor
      Found in avocado/plugins/runners/python_unittest.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

                          with open(
                              os.path.join(root, metadata_file), "r", encoding="utf-8"
                          ) as data:
                              metadata = json.loads(data.read())
                          if isinstance(metadata, dict):
      Severity: Major
      Found in avocado/plugins/vmimage.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if len(c) < len(constraint_array):
                                    if set(c) < set(constraint_array):
                                        has_subset = True
                                        break
                                if len(c) > len(constraint_array):
        Severity: Major
        Found in optional_plugins/varianter_cit/avocado_varianter_cit/Solver.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if regexp.match(child.name):
                                      remove.append(child)
                              for child in remove:

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

            def load_from_tree(name, version, release, arch, package_type, path):
            Severity: Minor
            Found in avocado/plugins/distro.py - About 45 mins to fix

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

                  def change_one_value(self, matrix, row_index=None, column_index=None):
                      """
                      Change one cell inside the matrix
              
                      :param matrix: matrix to be changed
              Severity: Minor
              Found in optional_plugins/varianter_cit/avocado_varianter_cit/Cit.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 value == constraint[counter][self.CON_NAME]:
                                          value_array.append([constraint[counter][self.CON_VAL]])
                                          if (counter + 1) != len(constraint):
                                              counter += 1
                                      else:
              Severity: Major
              Found in optional_plugins/varianter_cit/avocado_varianter_cit/Solver.py - About 45 mins to fix

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

                    def test_kill_process_tree_timeout_3s(
                Severity: Minor
                Found in selftests/unit/utils/process.py - About 45 mins to fix

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

                      def _fetch_asset(name, asset_hash, algorithm, locations, cache_dirs, expire, queue):
                  Severity: Minor
                  Found in avocado/plugins/runners/asset.py - About 45 mins to fix

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

                        def run(self, runnable):
                            # pylint: disable=W0201
                            self.runnable = runnable
                            yield self.prepare_status("started")
                    
                    
                    Severity: Minor
                    Found in avocado/plugins/runners/asset.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(self, config):
                            subcommand = config.get("subcommand")
                            self.variants = None  # pylint: disable=W0201
                            order = config.get(f"{subcommand}.cit.combination_order")
                            if order and order > 6:
                    Severity: Minor
                    Found in optional_plugins/varianter_cit/avocado_varianter_cit/varianter_cit.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 len(c) > len(constraint_array):
                                                if set(c) > set(constraint_array):
                                                    remove.add(c)
                                        if not has_subset:
                    Severity: Major
                    Found in optional_plugins/varianter_cit/avocado_varianter_cit/Solver.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if set(copy[i]).issubset(set(copy[j])):
                                                  items_to_remove.add(copy[j])
                              for item in items_to_remove:
                      Severity: Major
                      Found in optional_plugins/varianter_cit/avocado_varianter_cit/Solver.py - About 45 mins to fix

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

                            DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {

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

                              def run(self, config):
                                  name = config.get("distro.distro_def_name")
                                  version = config.get("distro.distro_def_version")
                                  release = config.get("distro.distro_def_release")
                                  arch = config.get("distro.distro_def_arch")
                          Severity: Minor
                          Found in avocado/plugins/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 test_all_commands has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def test_all_commands(self):
                                  # Test all commands except "set_target" which is tested elsewhere
                                  for cmd, _ in (
                                      (c, r)
                                      for (c, r) in self.service_command_generator.commands
                          Severity: Minor
                          Found in selftests/unit/utils/service.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

                                                  for pair in range(len(constraint[c])):
                                                      constraint_array.add(constraint[c][pair])
                                              constraint_array = sorted(
                          Severity: Major
                          Found in optional_plugins/varianter_cit/avocado_varianter_cit/Solver.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language