saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

    def _perform_actions(self, fullpath, fstat=None):
        for action in self.actions:
            if fstat is None and action.requires() & _REQUIRES_STAT:
                try:
                    fstat = os.stat(fullpath)
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

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

def read_file(fh_, chunk_size=1048576):
    '''
    Generator that reads chunk_size bytes at a time from a file/filehandle and
    yields it.
    '''
Severity: Minor
Found in salt/utils/itertools.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 list_item in param:
                        if items['type'][1].isupper() and isinstance(list_item, dict):
                            obj_list.append(
                                create_object_model(
                                    module_name,
Severity: Major
Found in salt/utils/azurearm.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

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

      Avoid deeply nested control flow statements.
      Open

                          if name.endswith(('.pyc', '.pyo')):
                              continue
                          if root.startswith('salt') and os.path.join(root, name) not in min_files:
      Severity: Major
      Found in salt/utils/thin.py - About 45 mins to fix

        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

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

          def cache_id(service, name, sub_resource=None, resource_id=None,
                       invalidate=False, region=None, key=None, keyid=None,
                       profile=None):
              '''
              Cache, invalidate, or retrieve an AWS resource id keyed by name.
          Severity: Minor
          Found in salt/utils/boto3mod.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 process_read_exception has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def process_read_exception(exc, path, ignore=None):
              '''
              Common code for raising exceptions when reading a file fails
          
              The ignore argument can be an iterable of integer error codes (or a single
          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

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

          def fpopen(*args, **kwargs):
              '''
              Shortcut for fopen with extra uid, gid, and mode options.
          
              Supported optional Keyword Arguments:
          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 'raid' not in ks_opts.keys():
                                  ks_opts['raid'] = []
                              ks_opts['raid'].append(parse_raid(line))
          Severity: Major
          Found in salt/utils/kickstart.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if stripped:
                                            self.stdout_logger.log(self.stdout_logger_level, stripped)
                            except OSError:
            Severity: Major
            Found in salt/utils/vt.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ':E:' in msg:
                                          err = msg.split(':E:')[-1]
                                          self.log.error(
                                              'Error response from the service publisher at %s: %s',
                                              addr, err
              Severity: Major
              Found in salt/utils/ssdp.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if comment:
                                        svc['desc'] = comment
                                    svc_res[port] = svc
                Severity: Major
                Found in salt/utils/dns.py - About 45 mins to fix

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

                      def to_highstate(self, slsmod):
                          # generate a state that uses the stateconf.set state, which
                          # is a no-op state, to hold a reference to the sls module
                          # containing the DSL statements. This is to prevent the module
                          # from being GC'ed, so that objects defined in it will be
                  Severity: Minor
                  Found in salt/utils/pydsl.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 '_|-' in rstateid:
                                          st = salt.state.split_low_tag(rstateid)
                                      # in case of simple state, try to guess
                                      else:
                                          id_ = rstate.get('__id__', rstateid)
                  Severity: Major
                  Found in salt/utils/state.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if dir_name not in ret and \
                                                base_name.lower() == dir_name.lower():
                                            del sub_dirs[:]
                                            ret.append(dir_name)
                    
                    
                    Severity: Major
                    Found in salt/utils/powershell.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if vi in ('=', ':') and ';' in optval:
                                                  # ';' is a comment delimiter only if it follows
                                                  # a spacing character
                                                  pos = optval.find(';')
                                                  if pos != -1 and optval[pos-1].isspace():
                      Severity: Major
                      Found in salt/utils/configparser.py - About 45 mins to fix

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

                            def get_tree(self, tgt_env):
                                '''
                                Return a tree object for the specified environment
                                '''
                                if not self.env_is_exposed(tgt_env):
                        Severity: Minor
                        Found in salt/utils/gitfs.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 not in addr_infos:
                                                    addr_infos[key] = [None, None]
                                                addr_infos[key][idx] = address
                        Severity: Major
                        Found in salt/utils/ssdp.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if (hport_end - hport_start) != (cport_end - cport_start):
                                                  # Port range is mismatched
                                                  raise SaltInvocationError(
                                                      'Host port range ({0}) does not have the same '
                                                      'number of ports as the container port range '
                          Severity: Major
                          Found in salt/utils/docker/translate/container.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language