saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Consider simplifying this complex logical expression.
Open

            if ( matcher[ expando ] ) {
                // Find the next relative operator (if any) for proper handling
                j = ++i;
                for ( ; j < len; j++ ) {
                    if ( Expr.relative[ tokens[j].type ] ) {
Severity: Major
Found in doc/_themes/saltstack/static/js/vendor/jquery-1.9.1.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

            if ( s.crossDomain == null ) {
                parts = rurl.exec( s.url.toLowerCase() );
                s.crossDomain = !!( parts &&
                    ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
                        ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
    Severity: Major
    Found in doc/_themes/saltstack/static/js/vendor/jquery-1.9.1.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

                          else if (Object(a) === a)
                              for (n in m = function () {
                                  var b = 0,
                                      c;
                                  for (c in a) a.hasOwnProperty(c) && b++;
      Severity: Major
      Found in doc/_themes/saltstack/static/js/vendor/modernizr-2.6.2-respond-1.1.0.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
                return;
            }
        Severity: Major
        Found in doc/_themes/saltstack/static/js/vendor/jquery-1.9.1.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                      if (!o && g(l.readyState) && (u.r = o = 1, !q && h(), l.onload = l.onreadystatechange = null, b)) {
                          "img" != a && m(function () {
                              t.removeChild(l)
                          }, 50);
                          for (var d in y[c]) y[c].hasOwnProperty(d) && y[c][d].onload()
          Severity: Major
          Found in doc/_themes/saltstack/static/js/vendor/modernizr-2.6.2-respond-1.1.0.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if result['success'] or \
                                'Operation failed: Channel closed' in result['stdout'] or \
                                'Communication error: java.util.concurrent.ExecutionException: Operation failed' in result['stdout']:
                    wait_time = 0
                    status = None
            Severity: Major
            Found in salt/states/jboss7.py - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                          if hold == 'minute' and \
                              timestamp_now <= timestamp:
                              continue
                          elif hold == 'hour' and \
                              timestamp_now.replace(**comp_hour) <= timestamp.replace(**comp_hour):
              Severity: Major
              Found in salt/states/zfs.py - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                    if not (present or boolean or integer or string or
                            listing or dictionary):
                        raise SaltInvocationError('Missing required argument text.')
                
                
                Severity: Major
                Found in salt/states/test.py - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (vtype in ['bool', 'boolean']) and ((value in [True, 'TRUE', 'YES'] and current_value == '1') or
                                                             (value in [False, 'FALSE', 'NO'] and current_value == '0')):
                          ret['comment'] += '{0} {1} is already set to {2}'.format(domain, name, value)
                      elif vtype in ['int', 'integer'] and safe_cast(current_value, int) == safe_cast(value, int):
                          ret['comment'] += '{0} {1} is already set to {2}'.format(domain, name, value)
                  Severity: Major
                  Found in salt/states/macdefaults.py - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if is_proxy(opts) and always_alive:
                                # if it is running in a NAPALM Proxy and it's using the default
                                # always alive behaviour, will get the cached copy of the network
                                # device object which should preserve the connection.
                                if force_reconnect:
                    Severity: Major
                    Found in salt/utils/napalm.py - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if salt.utils.platform.is_sunos():
                              on_supported_platform = True
                          elif salt.utils.platform.is_freebsd() and _check_retcode('kldstat -q -m zfs'):
                              on_supported_platform = True
                          elif salt.utils.platform.is_linux() and os.path.exists('/sys/module/zfs'):
                      Severity: Major
                      Found in salt/utils/zfs.py - About 40 mins to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if 'Darwin' in six.text_type(traceroute_version[1]) or \
                                        'FreeBSD' in six.text_type(traceroute_version[1]) or \
                                        __grains__['kernel'] in ('SunOS', 'AIX'):
                                    try:
                                        traceline = re.findall(r'\s*(\d*)\s+(.*)\s+\((.*)\)\s+(.*)$', line)[0]
                        Severity: Major
                        Found in salt/modules/network.py - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                          if proto == 'salt':
                                              path, senv = salt.utils.url.parse(single_src)
                                              if not senv:
                                                  senv = saltenv
                                              if (path, saltenv) in mfiles or (path, saltenv) in mdirs:
                          Severity: Major
                          Found in salt/modules/file.py - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                            if proto == 'file' and (
                                                    os.path.exists(urlparsed_src.netloc) or
                                                    os.path.exists(urlparsed_src.path) or
                                                    os.path.exists(os.path.join(
                                                        urlparsed_src.netloc,
                            Severity: Major
                            Found in salt/modules/file.py - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if archive or hidden or notIndexed or readonly or system or temporary:
                                          raise CommandExecutionError(
                                              'Normal attribute may not be used with any other attributes')
                                      ret = win32file.SetFileAttributes(path, 128)
                              Severity: Major
                              Found in salt/modules/win_file.py - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                            if ((mac and    # pylint: disable=too-many-boolean-expressions
                                                napalm_helpers.convert(napalm_helpers.mac, mac_entry.get('mac', '')) ==
                                                napalm_helpers.convert(napalm_helpers.mac, mac)) or
                                                (interface and interface in mac_entry.get('interface', '')) or
                                               (vlan and six.text_type(mac_entry.get('vlan', '')) == six.text_type(vlan))):
                                Severity: Major
                                Found in salt/runners/net.py - About 40 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                              if ((mac and arp_entry.get('mac', '').lower() == mac.lower()) or  # pylint: disable=too-many-boolean-expressions
                                                  (interface and interface in arp_entry.get('interface', '')) or
                                                  (ip and napalm_helpers.convert(napalm_helpers.ip, arp_entry.get('ip', '')) ==
                                                   napalm_helpers.convert(napalm_helpers.ip, ip))):
                                                  rows.append({
                                  Severity: Major
                                  Found in salt/runners/net.py - About 40 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                                if lost['require'] or lost['watch'] or lost['prereq'] \
                                                            or lost['onfail'] or lost['onchanges'] \
                                                            or lost.get('prerequired'):
                                                    comment = 'The following requisites were not found:\n'
                                                    for requisite, lreqs in six.iteritems(lost):
                                    Severity: Major
                                    Found in salt/state.py - About 40 mins to fix

                                      Consider simplifying this complex logical expression.
                                      Open

                                          if osdata['kernel'] == 'Linux' and os.path.exists('/sys/class/dmi/id'):
                                              # On many Linux distributions basic firmware information is available via sysfs
                                              # requires CONFIG_DMIID to be enabled in the Linux kernel configuration
                                              sysfs_firmware_info = {
                                                  'biosversion': 'bios_version',
                                      Severity: Major
                                      Found in salt/grains/core.py - About 40 mins to fix

                                        Function run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                            def run(self):
                                                if not os.path.exists(SALT_VERSION_HARDCODED) or self.distribution.with_salt_version:
                                                    # Write the version file
                                                    if getattr(self.distribution, 'salt_version_hardcoded_path', None) is None:
                                                        print('This command is not meant to be called on it\'s own')
                                        Severity: Minor
                                        Found in setup.py - About 35 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

                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language