saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if current_environ.get(_norm_key(key), None) != '':
                        # This key value will change to ''
                        ret['changes'].update({key: ''})
                else:
Severity: Major
Found in salt/states/environ.py - About 45 mins to fix

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

    def logging_levels(name, remote=None, local=None):
        '''
        Ensures that the logging levels are set on the device. The logging levels
        must match the following options: emergency, alert, critical, error, warning,
        notice, informational, debug.
    Severity: Minor
    Found in salt/states/cimc.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 __salt__['win_dns_client.rm_dns'](server, interface):
                            ret['comment'] = (
                                    'Failed to remove {0} from DNS server list').format(server)
                            ret['result'] = False
                            return ret
    Severity: Major
    Found in salt/states/win_dns_client.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for k, v in record.items():
                              if v != rec_set[record_str].get(k):
                                  ret['changes'] = {'new': {record_str: record}}
                      elif record_str[-1] == 's':
      Severity: Major
      Found in salt/states/azurearm_dns.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if tags[existing_tag] != sg['tags'][existing_tag]:
                                tags_to_update[existing_tag] = tags[existing_tag]
                            tags_to_add.pop(existing_tag)
        Severity: Major
        Found in salt/states/boto_secgroup.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if existing_vhost == '' and perms == ['', '', '']:
                                  continue
                              perm_need_change = True
          Severity: Major
          Found in salt/states/rabbitmq_user.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if not isinstance(record, dict):
                                    ret['comment'] = '{0} record information must be specified as a dictionary!'.format(record_str)
                                    return ret
                                for k, v in record.items():
            Severity: Major
            Found in salt/states/azurearm_dns.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if existing_tag not in tags_to_remove:
                                      tags_to_remove.append(existing_tag)
                              else:
              Severity: Major
              Found in salt/states/boto_secgroup.py - About 45 mins to fix

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

                def updated(name=None, cyg_arch='x86_64', mirrors=None):
                    '''
                    Make sure all packages are up to date.
                
                    name : None
                Severity: Minor
                Found in salt/states/cyg.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 isinstance(record, list):
                                        ret['comment'] = '{0} record information must be specified as a list of dictionaries!'.format(
                                            record_str
                                        )
                                        return ret
                Severity: Major
                Found in salt/states/azurearm_dns.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if 'tags' in sg:
                                          if sg['tags']:
                                              if tag in sg['tags']:
                                                  ret['changes']['old']['tags'][tag] = sg['tags'][tag]
                          if not tags_to_update and not tags_to_remove and not tags_to_add:
                  Severity: Major
                  Found in salt/states/boto_secgroup.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if ret['changes'].get('perms') is None:
                                            ret['changes'].update({'perms':
                                                                  {'old': {},
                                                                   'new': {}}})
                                        ret['changes']['perms']['old'].update(existing_perms)
                    Severity: Major
                    Found in salt/states/rabbitmq_user.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if len(to_start) == len(matches):
                                              ret['comment'] = (
                                                  'All services in group \'{0}\' will be started'
                                                  .format(name)
                                              )
                      Severity: Major
                      Found in salt/states/supervisord.py - About 45 mins to fix

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

                        def _get_dict_result(node):
                            ret = True
                            for key, val in six.iteritems(node):
                                if key == 'result' and val is False:
                                    ret = False
                        Severity: Minor
                        Found in salt/states/module.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 new_value['ProjectionType'] != current_value['ProjectionType']:
                                                raise GsiNotUpdatableError('GSI projection types do not match')
                                            elif set(new_value.get('NonKeyAttributes', [])) != set(current_value.get('NonKeyAttributes', [])):
                                                raise GsiNotUpdatableError('NonKeyAttributes do not match for GSI projection')
                                        elif new_value != current_value:
                        Severity: Major
                        Found in salt/states/boto_dynamodb.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if spost['lstchg'] != date:
                                                  ret['comment'] = 'User {0} created but failed to set' \
                                                                   ' last change date to' \
                                                                   ' {1}'.format(name, date)
                                                  ret['result'] = False
                          Severity: Major
                          Found in salt/states/user.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if spost['expire'] != expire:
                                                    ret['comment'] = 'User {0} created but failed to set' \
                                                                     ' expire days to' \
                                                                     ' {1}'.format(name, expire)
                                                    ret['result'] = False
                            Severity: Major
                            Found in salt/states/user.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if not __salt__['user.setpassword'](name, password):
                                                      ret['comment'] = 'User {0} created but failed to set' \
                                                                       ' password to' \
                                                                       ' {1}'.format(name, 'XXX-REDACTED-XXX')
                                                      ret['result'] = False
                              Severity: Major
                              Found in salt/states/user.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if spost['passwd'] != '':
                                                        ret['comment'] = 'User {0} created but failed to ' \
                                                                         'empty password'.format(name)
                                                        ret['result'] = False
                                                    ret['changes']['password'] = ''
                                Severity: Major
                                Found in salt/states/user.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if spost['passwd'] != password:
                                                          ret['comment'] = 'User {0} created but failed to set' \
                                                                           ' password to' \
                                                                           ' {1}'.format(name, 'XXX-REDACTED-XXX')
                                                          ret['result'] = False
                                  Severity: Major
                                  Found in salt/states/user.py - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language