saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if username == salt.utils.stringutils.to_unicode(user).split(',')[0].split('=')[-1]:
                        group_list.append(entry.split(',')[0].split('=')[-1])

Severity: Major
Found in salt/auth/ldap.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        for group in salt.utils.data.decode(entry[_config('groupattribute')]):
                            group_list.append(salt.utils.stringutils.to_unicode(group).split(',')[0].split('=')[-1])
                log.debug('User %s is a member of groups: %s', username, group_list)
    Severity: Major
    Found in salt/auth/ldap.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if this_password == password:
                              return True
                      else:
      Severity: Major
      Found in salt/auth/file.py - About 45 mins to fix

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

        def _config(key, mandatory=True, opts=None):
            '''
            Return a value for 'name' from master config file options or defaults.
            '''
            try:
        Severity: Minor
        Found in salt/auth/ldap.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 'reactor' in item:
                                    rine = True
                                    break
                            if not rine:
        Severity: Major
        Found in salt/master.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for line in f:
                                      line = salt.utils.stringutils.to_unicode(line).strip()
                                      if line.startswith('#'):
                                          continue
                                      if autosign_grains[grain] == line:
          Severity: Major
          Found in salt/daemons/masterapi.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if opts.get('auth.ldap.minion_stripdomains', None):
                                            for domain in opts['auth.ldap.minion_stripdomains']:
                                                if minion_id.endswith(domain):
                                                    minion_id = minion_id[:-len(domain)]
                                                    break
            Severity: Major
            Found in salt/auth/ldap.py - About 45 mins to fix

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

                  def _mine_delete(self, load):
                      '''
                      Allow the minion to delete a specific function from its own mine
                      '''
                      if 'id' not in load or 'fun' not in load:
              Severity: Minor
              Found in salt/daemons/masterapi.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 int(new_info['release']) < int(cur_info['release']):
                                          # This is an old release; don't use it
                                          use_formula = False
                                  elif int(new_info['version']) < int(cur_info['version']):
              Severity: Major
              Found in salt/spm/__init__.py - About 45 mins to fix

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

                def get_jids_filter(count, filter_find_job=True):
                    '''
                    Return a list of all jobs information filtered by the given criteria.
                    :param int count: show not more than the count of most recent jobs
                    :param bool filter_find_jobs: filter out 'saltutil.find_job' jobs
                Severity: Minor
                Found in salt/returners/local_cache.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 package in dl_list:
                                            # Check package version, replace if newer version
                                            if repo_ver == dl_list[package]['version']:
                                                # Version is the same, check release
                                                if repo_rel > dl_list[package]['release']:
                Severity: Major
                Found in salt/spm/__init__.py - About 45 mins to fix

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

                  def get_jid(jid):
                      '''
                      Return the information returned when the specified job id was executed
                      '''
                      jid = _escape_jid(jid)
                  Severity: Minor
                  Found in salt/returners/postgres_local_cache.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 _options_browser has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _options_browser(cfg, ret_config, defaults, virtualname, options):
                      """
                      Iterator generating all duples ```option name -> value```
                  
                      @see :func:`get_returner_options`
                  Severity: Minor
                  Found in salt/returners/__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

                                      if result:
                                          ret['changes'][repo_name] = {
                                              'old': 'Repo {0} is not in team {1}'.format(repo_name, name),
                                              'new': 'Repo {0} is in team {1}'.format(repo_name, name)
                                          }
                  Severity: Major
                  Found in salt/states/github.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if file_.startswith('{0}|'.format(ftype)):
                                                file_ = file_.lstrip('{0}|'.format(ftype))
                                        formula_tar.add(
                    Severity: Major
                    Found in salt/spm/__init__.py - About 45 mins to fix

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

                      def _calculate_runtimes(states):
                          results = {
                              'runtime': 0.00,
                              'num_failed_states': 0,
                              'num_passed_states': 0
                      Severity: Minor
                      Found in salt/returners/appoptics_return.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 repo_absent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def repo_absent(name, profile="github", **kwargs):
                          '''
                          Ensure a repo is absent.
                      
                          Example:
                      Severity: Minor
                      Found in salt/states/github.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_fun has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_fun(fun):
                          '''
                          Return a dict of the last function called for all minions
                          '''
                          query = '''SELECT minion_id, last_fun FROM {keyspace}.minions
                      Severity: Minor
                      Found in salt/returners/cassandra_cql_return.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 dl_package is True:
                                                  # Put together download directory
                                                  cache_path = os.path.join(
                                                      self.opts['spm_cache_dir'],
                                                      repo
                      Severity: Major
                      Found in salt/spm/__init__.py - About 45 mins to fix

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

                        def _calculate_runtimes(states):
                            results = {
                                'runtime': 0.00,
                                'num_failed_states': 0,
                                'num_passed_states': 0
                        Severity: Minor
                        Found in salt/returners/librato_return.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

                        Severity
                        Category
                        Status
                        Source
                        Language