saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if line_key.lower() == test_key:
                        keys_match = True
                else:
Severity: Major
Found in salt/states/file.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (d['VPCId'] == vpc_id
                                and d['VPCRegion'] == vpc_region):
                            create = False
                            break
                        else:
    Severity: Major
    Found in salt/states/boto_route53.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for perm in win_perms[user]['perms']:
                              if not salt.utils.win_dacl.has_permission(
                                      name, user, perm, exact=False):
                                  grant_perms.append(win_perms[user]['perms'])
                      if grant_perms:
      Severity: Major
      Found in salt/states/file.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if 'grant_perms' not in changes:
                                changes['grant_perms'] = {}
                            if user not in changes['grant_perms']:
        Severity: Major
        Found in salt/states/file.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if value_ignore_case:
                                  line_value = line_value.lower()
                                  test_value = test_value.lower()
          
                              # values match if they are equal at this point
          Severity: Major
          Found in salt/states/file.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if not salt.utils.win_dacl.has_permission(
                                        name, user, win_deny_perms[user]['perms'], 'deny'):
                                    deny_perms = win_deny_perms[user]['perms']
                            else:
            Severity: Major
            Found in salt/states/file.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if group is not None and group != stats.get('group'):
                                      fchange['group'] = group
                                  if mode is not None and mode != stats.get('mode'):
              Severity: Major
              Found in salt/states/file.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if 'deleted' not in ret['changes'].keys():
                                        ret['changes'] = {'deleted': []}
                                    ret['changes']['deleted'].append(val)
                Severity: Major
                Found in salt/states/grains.py - About 45 mins to fix

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

                  def _compute_diff(configured, expected):
                  
                      '''Computes the differences between the actual config and the expected config'''
                  
                      diff = {
                  Severity: Minor
                  Found in salt/states/netusers.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 'deny' in perms[user_name] and not perms[user_name]['deny']['inherited']:
                                          if 'remove_perms' not in changes:
                                              changes['remove_perms'] = {}
                                          changes['remove_perms'].update({user_name: perms[user_name]})
                  
                  
                  Severity: Major
                  Found in salt/states/file.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if salt.utils.platform.is_windows():
                                                ret = __salt__['file.check_perms'](
                                                    path=full,
                                                    ret=ret,
                                                    owner=win_owner,
                    Severity: Major
                    Found in salt/states/file.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if 'grant' in perms[user]:
                                              if not perms[user]['grant']['applies to'] == applies_to_text:
                                                  if 'grant_perms' not in changes:
                                                      changes['grant_perms'] = {}
                                                  if user not in changes['grant_perms']:
                      Severity: Major
                      Found in salt/states/file.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if 'deny' in perms[user]:
                                                if not perms[user]['deny']['applies to'] == applies_to_text:
                                                    if 'deny_perms' not in changes:
                                                        changes['deny_perms'] = {}
                                                    if user not in changes['deny_perms']:
                        Severity: Major
                        Found in salt/states/file.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if 'deleted' not in ret['changes'].keys():
                                                  ret['changes'] = {'deleted': []}
                                              ret['changes']['deleted'].append(val)
                          Severity: Major
                          Found in salt/states/grains.py - About 45 mins to fix

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

                            def not_cached(name, saltenv='base'):
                                '''
                                .. versionadded:: 2017.7.3
                            
                                Ensures that a file is not present in the minion's cache, deleting it
                            Severity: Minor
                            Found in salt/states/file.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 user not in changes['grant_perms']:
                                                    changes['grant_perms'][user] = {}
                                                changes['grant_perms'][user]['perms'] = grant_perms
                            Severity: Major
                            Found in salt/states/file.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if mode is not None and mode != stats.get('mode'):
                                                      fchange['mode'] = mode
                                                  if fchange:
                              Severity: Major
                              Found in salt/states/file.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if salt.utils.platform.is_windows():
                                                        ret['comment'] += (
                                                            'Failed to set ownership of symlink '
                                                            '{0} to {1}'.format(name, win_owner))
                                                    else:
                                Severity: Major
                                Found in salt/states/file.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if fchange:
                                                          changes[path] = fchange
                                              if check_dirs:
                                  Severity: Major
                                  Found in salt/states/file.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if diff_count[key] > 0:
                                                            diff_count[key] -= 1
                                                        # at this point a continue saves going through the rest of
                                                        # the keys to see if they match since this line already
                                                        #matched the current key
                                    Severity: Major
                                    Found in salt/states/file.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language