avocado-framework/avocado

View on GitHub

Showing 494 of 703 total issues

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

    def _save_to_json(matrix, filename, verbose=False):
        result = []
        type_label_mapping = {}

        for line in matrix:
Severity: Minor
Found in avocado/plugins/list.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 nsid == ns_id and paths["Name"] == controller_name:
                        stat.extend([paths["State"], paths["ANAState"]])
    return stat
Severity: Major
Found in avocado/utils/nvme.py - About 45 mins to fix

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

        def read_gdb_response(self, timeout=0.01, max_tries=100):
            """
            Read raw responses from GDB
    
            :param timeout: the amount of time to way between read attempts
    Severity: Minor
    Found in avocado/utils/gdb.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 result.exit_status != 0:
                            errs.append("remove loop device")
                            LOGGER.error(
                                "Unexpected failure when removing loop"
                                "device %s, check the log",
    Severity: Major
    Found in avocado/utils/lv_utils.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if not isinstance(old, list):
                                  node.value[n] = [node.value[n]]
                              node.value[n].append(v)
      Severity: Major
      Found in avocado/utils/external/gdbmi_parser.py - About 45 mins to fix

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

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

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

          def hash_file(filename, size=None, algorithm="md5"):
              """
              Calculate the hash value of filename.
          
              If size is not None, limit to first size bytes.
          Severity: Minor
          Found in avocado/utils/crypto.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

                                    for prule in rules[nextSym]:
                                        ppos = self.skip(prule)
                                        new = (prule, ppos)
                                        NK.items.append(new)
                        #
            Severity: Major
            Found in avocado/utils/external/spark.py - About 45 mins to fix

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

                  def find_rpm_packages(self, rpm_dir):
                      """
                      Extract product dependencies from a defined RPM directory and all its subdirectories.
              
                      :param str rpm_dir: directory to search in
              Severity: Minor
              Found in avocado/utils/software_manager/backends/rpm.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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __init__(
                      self,
                      path=None,
                      port=None,
                      wait_until_running=True,
              Severity: Minor
              Found in avocado/utils/gdb.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 nk is not None:
                                          # self.add(cur, (nk, i))
                                          # INLINED --v
                                          new = (nk, i)
                                          if new not in cur:
              Severity: Major
              Found in avocado/utils/external/spark.py - About 45 mins to fix

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

                    def provides(self, name):
                        """
                        Searches for what provides a given file.
                
                        :param name: File path.
                Severity: Minor
                Found in avocado/utils/software_manager/backends/zypper.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_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 _namelist has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def _namelist(instance):
                    namelist, namedict, classlist = [], {}, [instance.__class__]
                    for c in classlist:
                        for b in c.__bases__:
                            classlist.append(b)  # pylint: disable=W4701
                Severity: Minor
                Found in avocado/utils/external/spark.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 tokenize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def tokenize(self, s):
                        pos = 0
                        n = len(s)
                        while pos < n:
                            m = self.re.match(s, pos)
                Severity: Minor
                Found in avocado/utils/external/spark.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 new not in cur:
                                            self.links[key] = []
                                            cur.append(new)
                                        self.links[key].append((pptr, why))
                Severity: Major
                Found in avocado/utils/external/spark.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if param_type is not None:
                                          param_dic["type"] = param_type.group(1)
                                      param_list.append(param_dic)
                  Severity: Major
                  Found in avocado/utils/linux_modules.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if nk is not None:
                                                self.add(cur, (nk, i))
                    
                    
                    Severity: Major
                    Found in avocado/utils/external/spark.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if new not in next_item:
                                                  next_item.append(new)
                                              # INLINED --^
                                  else:
                      Severity: Major
                      Found in avocado/utils/external/spark.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language