saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    with salt.utils.files.fopen(file_path) as fh_:
                        for line in fh_:
                            line = salt.utils.stringutils.to_unicode(line).strip()
                            if line and not line.startswith('#'):
                                append_to_package_conf(
Severity: Major
Found in salt/modules/portage_config.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if 'source' not in adapters:
                            adapters['source'] = salt.utils.odict.OrderedDict()
    
                        # Create item in dict, if not already there
                        if 'data' not in adapters['source']:
    Severity: Major
    Found in salt/modules/debian_ip.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if opt in adapters[iface_name]['data'][inet]:
                              opt_keys = sorted(adapters[iface_name]['data'][inet][opt].keys())
                              adapters[iface_name]['data'][inet][opt + '_keys'] = opt_keys
      
      
      Severity: Major
      Found in salt/modules/debian_ip.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if not _temp_tpl_file_exists:
                                _loaded['result'] = False
                                _loaded['comment'] += 'Error while rendering the template.'
                                return _loaded
                            _rendered += __salt__['file.read'](_temp_tpl_file)
        Severity: Major
        Found in salt/modules/napalm_network.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if conf == 'accept_keywords':
                                      if not old_flags:
                                          new_contents += l
                                          if not new_flags:
                                              added = True
          Severity: Major
          Found in salt/modules/portage_config.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if not committed['result']:
                                    # If unable to commit, dicard the config (which is
                                    # already done by the _safe_commit_config function), and
                                    # return with the command and other details.
                                    return loaded_result
            Severity: Major
            Found in salt/modules/napalm_network.py - About 45 mins to fix

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

              def upgrade(*names, **kwargs):
                  '''
                  Upgrade named or all packages (run a ``pkg upgrade``). If <package name> is
                  omitted, the operation is executed on all packages.
              
              
              Severity: Minor
              Found in salt/modules/pkgng.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 bond['arp_ip_target']:
                                      bond['arp_ip_target'] = bond['arp_ip_target'] + ',' + ip
                                  else:
                                      bond['arp_ip_target'] = ip
                          else:
              Severity: Major
              Found in salt/modules/debian_ip.py - About 45 mins to fix

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

                def _uninstall(action='remove', name=None, pkgs=None, **kwargs):
                    '''
                    remove and purge do identical things but with different pacman commands,
                    this function performs the common logic.
                    '''
                Severity: Minor
                Found in salt/modules/pacmanpkg.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 force:
                                        continue
                                    else:
                                        return ret
                                data[k] = encoded
                Severity: Major
                Found in salt/modules/k8s.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if addrfam not in adapters[iface_name]['data']:
                                          adapters[iface_name]['data'][addrfam] = salt.utils.odict.OrderedDict()
                  
                  
                  Severity: Major
                  Found in salt/modules/debian_ip.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if not HAS_JXMLEASE:
                                            loaded_result['comment'] = ('This feature requires the library jxmlease to be installed.\n'
                                                    'To install, please execute: ``pip install jxmlease``.')
                                            loaded_result['result'] = False
                                            return loaded_result
                    Severity: Major
                    Found in salt/modules/napalm_network.py - About 45 mins to fix

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

                      def apply_network_settings(**settings):
                          '''
                          Apply global network configuration.
                      
                          CLI Example:
                      Severity: Minor
                      Found in salt/modules/debian_ip.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 file_dict has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def file_dict(*packages, **kwargs):
                          '''
                          List the files that belong to a package, grouped by package. Not
                          specifying any packages will return a list of _every_ file on the system's
                          package database (not generally recommended).
                      Severity: Minor
                      Found in salt/modules/pacmanpkg.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 bond['arp_ip_target']:
                                              bond['arp_ip_target'] = bond['arp_ip_target'] + ',' + ip
                                          else:
                                              bond['arp_ip_target'] = ip
                                  else:
                      Severity: Major
                      Found in salt/modules/debian_ip.py - About 45 mins to fix

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

                        def group_diff(name):
                        
                            '''
                            .. versionadded:: 2016.11.0
                        
                        
                        Severity: Minor
                        Found in salt/modules/pacmanpkg.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

                                            for word in line.split()[1:]:
                                                if word not in adapters:
                                                    adapters[word] = salt.utils.odict.OrderedDict()
                                                adapters[word]['hotplug'] = True
                        
                        
                        Severity: Major
                        Found in salt/modules/debian_ip.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if 'data' not in adapters['source']:
                                                  adapters['source']['data'] = salt.utils.odict.OrderedDict()
                                                  adapters['source']['data']['sources'] = []
                                              adapters['source']['data']['sources'].append(line.split()[1])
                          Severity: Major
                          Found in salt/modules/debian_ip.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                with salt.utils.files.fopen(file_path) as fp_:
                                                    rearrange.extend(salt.utils.data.decode(fp_.readlines()))
                                                os.remove(file_path)
                            Severity: Major
                            Found in salt/modules/portage_config.py - About 45 mins to fix

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

                              def mkpart(device, part_type, fs_type=None, start=None, end=None):
                                  '''
                                  Make a part_type partition for filesystem fs_type, beginning at start and
                                  ending at end (by default in megabytes).  part_type should be one of
                                  "primary", "logical", or "extended".
                              Severity: Minor
                              Found in salt/modules/parted_partition.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

                              Severity
                              Category
                              Status
                              Source
                              Language