saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

    Avoid deeply nested control flow statements.
    Open

                        if __opts__['test']:
                            ret['changes'][team_name] = team_change
                            ret['result'] = None
                        else:
                            result = __salt__['github.add_team_repo'](name, team_name,
    Severity: Major
    Found in salt/states/github.py - About 45 mins to fix

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

      def _preflight_check(desired, fromrepo, **kwargs):
          '''
          Perform platform-specific checks on desired packages
          '''
          if 'pkg.check_db' not in __salt__:
      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 __opts__['test']:
                              ret['comment'] = 'Org {0} user {1} role will be ' \
                                      'updated'.format(name, username)
                              return ret
                          __salt__['grafana4.update_org_user'](
      Severity: Major
      Found in salt/states/grafana4_org.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if result:
                                ret['changes'][repo_name] = {
                                    'old': 'Repo {0} is in team {1}'.format(repo_name, name),
                                    'new': 'Repo {0} is not 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 verify_result:
                                  to_reinstall[package_name] = version_string
                                  altered_files[package_name] = verify_result
                          else:
          Severity: Major
          Found in salt/states/pkg.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if 'heat_template_version' in template_parse:
                                        template_new = salt.utils.yaml.safe_dump(template_parse)
                                    else:
                                        template_new = jsonutils.dumps(template_parse, indent=2, ensure_ascii=False)
                                    salt.utils.files.safe_rm(template_tmp_file)
            Severity: Major
            Found in salt/states/heat.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 remove targets'.format(name)
              Severity: Major
              Found in salt/states/boto_elbv2.py - About 45 mins to fix

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

                def running(name, restart=False, force=True):
                    '''
                    Ensure that the marathon app with the given id is present and restart if set.
                
                    :param name: The app name/id
                Severity: Minor
                Found in salt/states/marathon_app.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 sources:
                                        reinstall_targets.append(reinstall_pkg)
                                    else:
                                        reinstall_targets.append(
                                            _get_desired_pkg(reinstall_pkg, to_reinstall)
                Severity: Major
                Found in salt/states/pkg.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if mode.lower() == 'attach':
                                          res_attach = __salt__['zoneadm.attach'](name, False, brand_opts)
                                          ret['result'] = res_attach['status']
                                          if res_attach['status']:
                                              ret['changes'][name] = 'attached'
                  Severity: Major
                  Found in salt/states/zone.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if zonecfg_res['status']:
                                            ret['changes'][resource_type] = 'removed'
                                            if ret['comment'] == '':
                                                ret['comment'] = 'The {0} resource was removed.'.format(
                                                    resource_type,
                    Severity: Major
                    Found in salt/states/zone.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if zonecfg_res['status']:
                                              ret['changes'][resource_type] = {}
                                              ret['changes'][resource_type][resource_selector_value] = 'removed'
                                              if ret['comment'] == '':
                                                  ret['comment'] = 'The {0} resource {1} was removed.'.format(
                      Severity: Major
                      Found in salt/states/zone.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if replace:
                                                try:
                                                    __salt__['file.move'](cfg_tmp, path)
                                                except CommandExecutionError:
                                                    if __salt__['file.file_exists'](cfg_tmp):
                        Severity: Major
                        Found in salt/states/zone.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if __opts__['test']:
                                                  ret['result'] = None
                                              return ret
                          Severity: Major
                          Found in salt/states/chocolatey.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                for key in kwargs:
                                                    log.debug('zone.resource_preent - key=%s value=%s current_value=%s',
                                                        key,
                                                        resource[key] if key in resource else None,
                                                        _parse_value(kwargs[key]),
                            Severity: Major
                            Found in salt/states/zone.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if ret['result'] is None:
                                                      if __opts__['test']:
                                                          ret['result'] = True
                                                      else:
                                                          ## update resource
                              Severity: Major
                              Found in salt/states/zone.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if res:
                                                        ret['result'] = ret['result'] if res['result'] else False
                                                        ret['comment'].append(res['comment'])
                                                        if res['changes']:
                                                            if 'resource' not in ret['changes']:
                                Severity: Major
                                Found in salt/states/zone.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if 'message' in res_delete:
                                                          ret['comment'].append(res_delete['message'])
                                                      ret['comment'] = "\n".join(ret['comment'])
                                  Severity: Major
                                  Found in salt/states/zone.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if not r.get('updated'):
                                                            ret['result'] = False
                                                            ret['comment'] = 'Failed to update bucket: {0}.'.format(r['error']['message'])
                                                            return ret
                                        if update and __opts__['test']:
                                    Severity: Major
                                    Found in salt/states/boto_s3_bucket.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language