saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def _check_pkgin():
    '''
    Looks to see if pkgin is present on the system, return full path
    '''
    ppath = salt.utils.path.which('pkgin')
Severity: Minor
Found in salt/modules/pkgin.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 'enabled' in beacon_config_dict and not beacon_config_dict['enabled']:
                            ret['result'] = True
                            ret['comment'] = 'Disabled beacon {0} on minion.' \
                                             ''.format(name)
                        else:
Severity: Major
Found in salt/modules/beacons.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if name in beacons and beacons[name] == beacon_data:
                                ret['result'] = True
                                ret['comment'] = 'Added beacon: {0}.'.format(name)
                        else:
    Severity: Major
    Found in salt/modules/beacons.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not os.path.isabs(req_file):
                              req_file = os.path.join(cwd, req_file)
      
      
      Severity: Major
      Found in salt/modules/pip.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not line.startswith('#') and mod_name:
                                    mods.add(mod_name)
                    except IOError:
        Severity: Major
        Found in salt/modules/kmod.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if 'enabled' in beacon_config_dict and beacon_config_dict['enabled']:
                                      ret['result'] = True
                                      ret['comment'] = 'Enabled beacon {0} on minion.' \
                                                       ''.format(name)
                                  else:
          Severity: Major
          Found in salt/modules/beacons.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if not s[0] in pkglist:
                                    if len(p) > 1 and p[1] in ('<', '', '='):
                                        pkglist[s[0]] = s[1]
                                    else:
                                        pkglist[s[0]] = ''
            Severity: Major
            Found in salt/modules/pkgin.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if _policydata.policies[p_class]['policies'][policy]['Policy'].upper() == policy_name.upper():
                                      _pol = _policydata.policies[p_class]['policies'][policy]
                                      policy_name = policy
                          if _pol:
              Severity: Major
              Found in salt/modules/win_lgpo.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if proc_exitstatus != 0:
                                            raise SaltInvocationError(
                                                 'Reprepro includedsc for codename {0} and file {1} failed with proc.status {2}'.format(
                                                    codename,
                                                    abs_file,
                Severity: Major
                Found in salt/modules/debuild_pkgbuild.py - About 45 mins to fix

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

                  def list_targets(Rule,
                               region=None, key=None, keyid=None, profile=None):
                      '''
                      Given a rule name list the targets of that rule.
                  
                  
                  Severity: Minor
                  Found in salt/modules/boto_cloudwatch_event.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 six.PY2:
                                          addr = six.text_type(addr)
                                          # Adding this, as ipaddress would complain about valid
                                          # addresses not being valid. #pythonIsFun
                                      ip_values.append(capirca.lib.policy.nacaddr.IP(addr))
                  Severity: Major
                  Found in salt/modules/capirca_acl.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if ((__grains__['os'] in ['Ubuntu'] and __grains__['osmajorrelease'] < 18)
                                             or (__grains__['os'] in ['Debian'] and __grains__['osmajorrelease'] <= 8)):
                                            cmd = 'debsign --re-sign -k {0} {1}'.format(keyid, abs_file)
                                            try:
                                                proc = salt.utils.vt.Terminal(
                    Severity: Major
                    Found in salt/modules/debuild_pkgbuild.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if f not in ['N', 'D', 'H', 'L', 'X']:
                                              logmsg = 'pdbedit.modify - unknown {} flag for account_control, ignored'.format(f)
                                              log.warning(logmsg)
                                          else:
                                              new.append(f)
                      Severity: Major
                      Found in salt/modules/pdbedit.py - About 45 mins to fix

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

                        def lsmod():
                            '''
                            Return a dict containing information about currently loaded modules
                        
                            CLI Example:
                        Severity: Minor
                        Found in salt/modules/kmod.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 'enabled' in beacons and not beacons['enabled']:
                                                    ret['result'] = True
                                                    ret['comment'] = 'Disabled beacons on minion.'
                                                else:
                                                    ret['result'] = False
                        Severity: Major
                        Found in salt/modules/beacons.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if not os.path.exists(target_path):
                                                  logger.debug(
                                                      'Copying %s to %s', req_file, target_path
                                                  )
                                                  __salt__['file.copy'](req_file, target_path)
                          Severity: Major
                          Found in salt/modules/pip.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    while proc.has_unread_data:
                                                        stdout, _ = proc.recv()
                                                        if stdout and REPREPRO_SIGN_PROMPT_RE.search(stdout):
                                                            # have the prompt for inputting the passphrase
                                                            proc.sendline(phrase)
                            Severity: Major
                            Found in salt/modules/debuild_pkgbuild.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if name in beacons and beacons[name] == beacon_data:
                                                          ret['result'] = True
                                                          ret['comment'] = 'Modified beacon: {0}.'.format(name)
                                                  elif event_ret:
                              Severity: Major
                              Found in salt/modules/beacons.py - About 45 mins to fix

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

                                def search(pkg_name, **kwargs):
                                    '''
                                    Searches for an exact match using pkgin ^package$
                                
                                    CLI Example:
                                Severity: Minor
                                Found in salt/modules/pkgin.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 cwd and src.startswith(cwd):
                                                            arc_name = os.path.relpath(src, cwd)
                                                        else:
                                                            arc_name = os.path.relpath(src, rel_root)
                                                        archived_files.append(arc_name)
                                Severity: Major
                                Found in salt/modules/archive.py - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language