saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def get_jids():
    '''
    Return a list of all job ids
    '''
    query = '''SELECT jid, load FROM {keyspace}.jids;'''.format(keyspace=_get_keyspace())
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

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

def _get_conn(ret):
    '''
    Return a mongodb connection object
    '''
    _options = _get_options(ret)
Severity: Minor
Found in salt/returners/mongo_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 get_minions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_minions():
    '''
    Return a list of minions
    '''
    query = '''SELECT DISTINCT minion_id
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 hours_difference > __opts__['keep_jobs'] and os.path.exists(t_path):
                        # Remove the entire f_path from the original JID dir
                        try:
                            shutil.rmtree(f_path)
                        except OSError as err:
Severity: Major
Found in salt/returners/local_cache.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            with salt.utils.files.fopen(outp, 'rb') as rfh:
                                ret[fn_]['out'] = serial.load(rfh)
                    except Exception as exc:
    Severity: Major
    Found in salt/returners/local_cache.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not results[-1] in ('and', 'or', '('):
                              results.append('and')
                      results.append(word)
      Severity: Major
      Found in salt/matchers/compound_match.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if len(comments) > 1:
                                    comments.append('')
                                return {'name': name,
        Severity: Major
        Found in salt/states/pkg.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if state:
                                  changes = True
                                  ret['result'] = True
                              else:
                                  ret['comment'] = 'Target Group {0} failed to add targets'.format(name)
          Severity: Major
          Found in salt/states/boto_elbv2.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if __opts__['test']:
                                    ret['comment'] = 'Org {0} user {1} will be ' \
                                            'deleted'.format(name, username)
                                    return ret
                                __salt__['grafana4.delete_org_user'](
            Severity: Major
            Found in salt/states/grafana4_org.py - About 45 mins to fix

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

              def activate(name):
                  '''
                  Install and activate the given product key
              
                  name
              Severity: Minor
              Found in salt/states/win_license.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 'pkgs' in chunk:
                                      pkgs.extend(chunk['pkgs'])
                                      chunk['__agg__'] = True
                                  elif 'name' in chunk:
                                      version = chunk.pop('version', None)
              Severity: Major
              Found in salt/states/pkg.py - About 45 mins to fix

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

                def _fulfills_version_spec(versions, oper, desired_version,
                                           ignore_epoch=False):
                    '''
                    Returns True if any of the installed versions match the specified version,
                    otherwise returns False
                Severity: Minor
                Found in salt/states/pkg.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 pkgname, suggestions in \
                                                six.iteritems(problems['suggest']):
                                            comments.append(
                                                'Package \'{0}\' not found (possible matches: '
                                                '{1})'.format(pkgname, ', '.join(suggestions))
                Severity: Major
                Found in salt/states/pkg.py - About 45 mins to fix

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

                  def _find_advisory_targets(name=None,
                                             advisory_ids=None,
                                             **kwargs):
                      '''
                      Inspect the arguments to pkg.patch_installed and discover what advisory
                  Severity: Minor
                  Found in salt/states/pkg.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 verify_result:
                                          to_reinstall[package_name] = version_string
                                          altered_files[package_name] = verify_result
                                  continue
                  Severity: Major
                  Found in salt/states/pkg.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if sources:
                                            pkgstr = reinstall_pkg
                                        else:
                                            pkgstr = _get_desired_pkg(reinstall_pkg, to_reinstall)
                                        comment.append(
                    Severity: Major
                    Found in salt/states/pkg.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if resource_selector_property:
                                              ret['comment'] = 'the {0} resource {1} is up to date.'.format(
                                                  resource_type,
                                                  resource_selector_value,
                                              )
                      Severity: Major
                      Found in salt/states/zone.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if 'resource_prune' in resource_cfg:
                                                resource_prune = resource_cfg['resource_prune']
                                                del resource_cfg['resource_prune']
                                            if 'resource_selector_property' in resource_cfg:
                        Severity: Major
                        Found in salt/states/zone.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

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

                            Avoid deeply nested control flow statements.
                            Open

                                                if result:
                                                    ret['changes'][team_name] = team_change
                                                else:
                                                    ret['result'] = False
                                                    ret['comment'] = ('Failed to remove repo {0} from team {1}.'
                            Severity: Major
                            Found in salt/states/github.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language