saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not isinstance(val, list):
                        temp = [val]
                        val = temp
                    val.append(xml_to_dict(n))
Severity: Major
Found in salt/utils/namecheap.py - About 45 mins to fix

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

        def image_list(self, name=None):
            '''
            List server images
            '''
            nt_ks = self.compute_conn
    Severity: Minor
    Found in salt/utils/openstack/nova.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 results[-1] == '(' and word in ('and', 'or'):
                                log.error('Invalid beginning operator after "(": %s', word)
                                return {'minions': [], 'missing': []}
                            if word == 'not':
    Severity: Major
    Found in salt/utils/minions.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if isinstance(fun_kwargs, dict) and '__kwarg__' in fun_kwargs:
                                      fun_args = list(fun_args)  # copy on modify
                                      del fun_args[-1]
                                  else:
                                      fun_kwargs = None
      Severity: Major
      Found in salt/utils/minions.py - About 45 mins to fix

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

        def _data2rec_group(schema, recs_data, group_key):
            if not isinstance(recs_data, (list, tuple)):
                recs_data = [recs_data]
        
            res = OrderedDict()
        Severity: Minor
        Found in salt/utils/dns.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 stripped.startswith(os.linesep):
                                        stripped = stripped[len(os.linesep):]
                                    if stripped:
        Severity: Major
        Found in salt/utils/vt.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for result in self._perform_actions(fullpath, fstat=fstat):
                                      yield result
          
          
          Severity: Major
          Found in salt/utils/find.py - About 45 mins to fix

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

            def find_json(raw):
                '''
                Pass in a raw string and load the json when it starts. This allows for a
                string to start with garbage and end with json but be cleanly loaded
                '''
            Severity: Minor
            Found in salt/utils/json.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 name.endswith(('.pyc', '.pyo')):
                                    digest_collector.add(os.path.join(root, name))
                                    arcname = os.path.join(site_pkg_dir, root, name)
                                    if hasattr(tfp, 'getinfo'):
                                        try:
            Severity: Major
            Found in salt/utils/thin.py - About 45 mins to fix

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

                  def _check_criteria(self, dirpath, name, fullpath, fstat=None):
                      match = True
                      for criterion in self.criteria:
                          if fstat is None and criterion.requires() & _REQUIRES_STAT:
                              try:
              Severity: Minor
              Found in salt/utils/find.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 'part' not in ks_opts.keys():
                                      ks_opts['part'] = []
                                  ks_opts['part'].append(parse_partition(line))
              Severity: Major
              Found in salt/utils/kickstart.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if 'no' in interface['onboot']:
                                        sls[device]['enabled'] = False
                                    else:
                                        sls[device]['enabled'] = True
                                    del interface['onboot']
                Severity: Major
                Found in salt/utils/kickstart.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if 'network' not in ks_opts.keys():
                                          ks_opts['network'] = []
                                      ks_opts['network'].append(parse_network(line))
                  Severity: Major
                  Found in salt/utils/kickstart.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        with salt.utils.files.fopen(pyminver) as fh_:
                                            overwrite = fh_.read() != str(sys.version_info[0])  # future lint: disable=blacklisted-function
                                else:
                    Severity: Major
                    Found in salt/utils/thin.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if not name.endswith(('.pyc', '.pyo')):
                                              digest_collector.add(os.path.join(root, name))
                                              arcname = os.path.join(ns, site_pkg_dir, root, name)
                                              if hasattr(tfp, 'getinfo'):
                                                  try:
                      Severity: Major
                      Found in salt/utils/thin.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if type(interface[option]) is bool:
                                                sls[device][option] = {'enabled': [interface[option]]}
                                            else:
                                                sls[device][option] = interface[option]
                                    if 'hostname' in interface:
                        Severity: Major
                        Found in salt/utils/kickstart.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              with salt.utils.files.fopen(pythinver) as fh_:
                                                  overwrite = fh_.read() != str(sys.version_info[0])  # future lint: disable=blacklisted-function
                                      else:
                          Severity: Major
                          Found in salt/utils/thin.py - About 45 mins to fix

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

                            def rename(src, dst):
                                '''
                                On Windows, os.rename() will fail with a WindowsError exception if a file
                                exists at the destination path. This function checks for this error and if
                                found, it deletes the destination path first.
                            Severity: Minor
                            Found in salt/utils/files.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 root.startswith('salt') and os.path.join(root, name) not in min_files:
                                                    continue
                                                tfp.add(os.path.join(root, name),
                            Severity: Major
                            Found in salt/utils/thin.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if stripped:
                                                              self.stderr_logger.log(self.stderr_logger_level, stripped)
                                              except OSError:
                              Severity: Major
                              Found in salt/utils/vt.py - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language