saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if 'mask' in _config['files'][path]:
                        if not isinstance(_config['files'][path]['mask'], list):
                            return False, ('Configuration for inotify beacon '
                                           'mask must be list.')
                        for mask in _config['files'][path]['mask']:
Severity: Major
Found in salt/beacons/inotify.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if re.match('state.*', job['fun']):
                                is_running = True
                        if is_running:
    Severity: Major
    Found in salt/beacons/__init__.py - About 45 mins to fix

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

          def __init__(self, opts):
              super(MasterKeys, self).__init__()
              self.opts = opts
              self.pub_path = os.path.join(self.opts['pki_dir'], 'master.pub')
              self.rsa_path = os.path.join(self.opts['pki_dir'], 'master.pem')
      Severity: Minor
      Found in salt/crypt.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 verify_pubkey_sig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def verify_pubkey_sig(self, message, sig):
              '''
              Wraps the verify_signature method so we have
              additional checks.
      
      
      Severity: Minor
      Found in salt/crypt.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_s3_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def _get_s3_key():
          '''
          Get AWS keys from pillar or config
          '''
      
      
      Severity: Minor
      Found in salt/fileserver/s3fs.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 is_file_ignored(opts, file_path):
                                  continue
                              file_map[file_path] = os.path.getmtime(file_path)
      Severity: Major
      Found in salt/fileserver/__init__.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if bucket_name in bucket:
                                bucket[bucket_name] += list(dirpaths)
                                bucket[bucket_name] = list(set(bucket[bucket_name]))
                                break
            return ret
        Severity: Major
        Found in salt/fileserver/s3fs.py - About 45 mins to fix

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

          def _file_lists(load, form):
              '''
              Return a dict containing the file lists for files and dirs
              '''
              if 'env' in load:
          Severity: Minor
          Found in salt/fileserver/hgfs.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 k in s3_meta:
                                  if 'Code' in k or 'Message' in k:
                                      # assumes no duplicate keys, consisdent with current erro response.
                                      meta_response.update(k)
                              # attempt use of human readable output first.
          Severity: Major
          Found in salt/fileserver/s3fs.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if relpath != '.':
                                    # Don't add files outside the hgfs_root
                                    if not relpath.startswith('../'):
                                        ret.add(os.path.join(repo['mountpoint'], relpath))
                                split = split[0].rsplit('/', 1)
            Severity: Major
            Found in salt/fileserver/hgfs.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if ret is not None:
                                      for header_name, header_value in ret['headers'].items():
                                          name = header_name.strip()
                                          value = header_value.strip()
                                          if six.text_type(name).lower() == 'last-modified':
              Severity: Major
              Found in salt/fileserver/s3fs.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if 'Code' in k or 'Message' in k:
                                        # assumes no duplicate keys, consisdent with current erro response.
                                        meta_response.update(k)
                                # attempt use of human readable output first.
                                try:
                Severity: Major
                Found in salt/fileserver/s3fs.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if bucket_name in bucket:
                                          bucket[bucket_name] += filepaths
                                          break
                      return ret
                  Severity: Major
                  Found in salt/fileserver/s3fs.py - About 45 mins to fix

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

                        def envs(self, back=None, sources=False):
                            '''
                            Return the environments for the named backend or all backends
                            '''
                            back = self.backends(back)
                    Severity: Minor
                    Found in salt/fileserver/__init__.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 file_path in files:
                                            cached_file_path = _get_cached_file_name(bucket, saltenv, file_path)
                                            log.info('%s - %s : %s', bucket, saltenv, file_path)
                    
                                            # load the file from S3 if it's not in the cache or it's old
                    Severity: Major
                    Found in salt/fileserver/s3fs.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if 'Code' in meta_response:
                                                  log.warning(
                                                      "'%s' response for bucket '%s'",
                                                      meta_response['Code'], bucket_name
                                                  )
                      Severity: Major
                      Found in salt/fileserver/s3fs.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if bucket_name in bucket_files:
                                                bucket_files[bucket_name] += env_files
                                                found = True
                                                break
                                        if not found:
                        Severity: Major
                        Found in salt/fileserver/s3fs.py - About 45 mins to fix

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

                          def __virtual__():
                              '''
                              Only load if subversion is available
                              '''
                              if __virtualname__ not in __opts__['fileserver_backend']:
                          Severity: Minor
                          Found in salt/fileserver/svnfs.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 dirs and not files:
                                                  ret['empty_dirs'].add(dir_rel_fn)
                                          for fname in files:
                          Severity: Major
                          Found in salt/fileserver/svnfs.py - About 45 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                            if ( !jQuery.support.opacity ) {
                                jQuery.cssHooks.opacity = {
                                    get: function( elem, computed ) {
                                        // IE uses filters for opacity
                                        return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
                            Severity: Major
                            Found in doc/_themes/saltstack/static/js/vendor/jquery-1.9.1.js - About 40 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language