saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if len(_new) == 3 and len(_old) == 3:
                        log.debug('_new[0] == _old[0]: %s',
                                  six.text_type(_new[0]) == six.text_type(_old[0]))
                        log.debug('_new[2] == _old[2]: %s',
                                  six.text_type(_new[2]) == six.text_type(_old[2]))
Severity: Major
Found in salt/states/chronos_job.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if not value:
                            res = property_absent(name, key)
                        elif value:
                            res = property_present(name, key, value)
                        if res:
    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 'property' 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_uninstall:
                                ret['comment'].append(res_uninstall['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 resource_selector_property:
                                  ret['changes'][resource_type][resource_selector_value][key] = _parse_value(kwargs[key])
                              else:
                                  ret['changes'][resource_type][key] = _parse_value(kwargs[key])
                          if ret['comment'] == '':
          Severity: Major
          Found in salt/states/zone.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

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

              Avoid deeply nested control flow statements.
              Open

                                  if proto_name in d_rule:
                                      d_rule_components[proto_name] = d_rule[proto_name]
                                      del d_rule[proto_name]
              
              
              Severity: Major
              Found in salt/states/zabbix_template.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

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

                  Avoid deeply nested control flow statements.
                  Open

                                      if isinstance(value, list):
                                          for respv in value:
                                              resource_cfg.update(dict(respv))
                  
                  
                  Severity: Major
                  Found in salt/states/zone.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if __salt__['file.file_exists'](cfg_tmp):
                                            __salt__['file.remove'](cfg_tmp)
                                    else:
                    Severity: Major
                    Found in salt/states/zone.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if 'message' in res_detach:
                                              ret['comment'].append(res_detach['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('deleted'):
                                                ret['result'] = False
                                                ret['comment'] = 'Failed to update bucket: {0}.'.format(r['error']['message'])
                                                return ret
                                        else:
                        Severity: Major
                        Found in salt/states/boto_s3_bucket.py - About 45 mins to fix

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

                          def create(name,
                                     endpoint='incidents',
                                     api_url=None,
                                     page_id=None,
                                     api_key=None,
                          Severity: Minor
                          Found in salt/states/statuspage.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 uninstalled has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def uninstalled(name, version=None, uninstall_args=None, override_args=False):
                              '''
                              Uninstalls a package
                          
                              name
                          Severity: Minor
                          Found in salt/states/chocolatey.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 resource_selector_property and key in _zonecfg_resource_default_selectors:
                                                  resource_selector_property = _zonecfg_resource_default_selectors[key]
                          
                          
                          Severity: Major
                          Found in salt/states/zone.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if resource_prune:
                                                    res = resource_absent(
                                                        name,
                                                        resource_cfg['resource_type'],
                                                        resource_selector_property=resource_selector_property,
                            Severity: Major
                            Found in salt/states/zone.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if role not in tenant_roles:
                                                      if __opts__.get('test'):
                                                          ret['result'] = None
                                                          ret['comment'] = 'User roles "{0}" will been updated'.format(name)
                                                          return ret
                              Severity: Major
                              Found in salt/states/keystone.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if not __salt__['boto_ec2.create_tags'](resource_ids=instance_id, tags=add,
                                                                                            region=region, key=key, keyid=keyid,
                                                                                            profile=profile):
                                                        msg = "Error while creating tags on instance {0}".format(instance_name if
                                                                                                                instance_name else name)
                                Severity: Major
                                Found in salt/states/boto_ec2.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if not vals:
                                                          # clean out empty attribute lists
                                                          to_delete.add(attr)
                                                  for attr in to_delete:
                                  Severity: Major
                                  Found in salt/states/ldap.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if 'error' in reshard_response:
                                                            ret['result'] = False
                                                            comments.append('Encountered error while resharding {0}: {1}'
                                                                            .format(name, reshard_response['error']))
                                                            _add_changes(ret, changes_old, changes_new, comments)
                                    Severity: Major
                                    Found in salt/states/boto_kinesis.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language