saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Function sls_id has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def sls_id(id_, mods, test=None, queue=False, **kwargs):
    '''
    Call a single ID from the named module(s) and handle all requisites

    The state ID comes *before* the module ID(s) on the command line.
Severity: Minor
Found in salt/modules/state.py - About 1 hr to fix

    Function restartcheck has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def restartcheck(ignorelist=None, blacklist=None, excludepid=None, **kwargs):
        '''
        Analyzes files openeded by running processes and seeks for packages which need to be restarted.
    
        Args:
    Severity: Minor
    Found in salt/modules/restartcheck.py - About 1 hr to fix

      Function show_pricing has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def show_pricing(kwargs=None, call=None):
          '''
          Show pricing for a particular profile. This is only an estimate, based on
          unofficial pricing sources.
      
      
      Severity: Minor
      Found in salt/cloud/clouds/ec2.py - About 1 hr to fix

        Function request_instance has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def request_instance(vm_=None, call=None):
            '''
            Put together all of the information necessary to request an instance
            through Novaclient and then fire off the request the instance.
        
        
        Severity: Minor
        Found in salt/cloud/clouds/nova.py - About 1 hr to fix

          Function create_network_interface has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def create_network_interface(call=None, kwargs=None):
              '''
              Create a network interface.
              '''
              if call != 'action':
          Severity: Minor
          Found in salt/cloud/clouds/azurearm.py - About 1 hr to fix

            Function gen_csr has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def gen_csr(
                    minion_id,
                    dns_name,
                    zone='default',
                    country=None,
            Severity: Minor
            Found in salt/runners/venafiapi.py - About 1 hr to fix

              Function apply_minion_config has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def apply_minion_config(overrides=None,
                                      defaults=None,
                                      cache_minion_id=False,
                                      minion_id=None):
                  '''
              Severity: Minor
              Found in salt/config/__init__.py - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                if ( jQuery.expr && jQuery.expr.filters ) {
                    jQuery.expr.filters.hidden = function( elem ) {
                        // Support: Opera <= 12.12
                        // Opera reports offsetWidths and offsetHeights less than zero on some elements
                        return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
                Severity: Major
                Found in doc/_themes/saltstack/static/js/vendor/jquery-1.9.1.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                                  if ( unit !== "px" && start ) {
                                      // Iteratively approximate from a nonzero starting point
                                      // Prefer the current property, because this process will be trivial if it uses the same units
                                      // Fallback to end or a simple constant
                                      start = jQuery.css( tween.elem, prop, true ) || end || 1;
                  Severity: Major
                  Found in doc/_themes/saltstack/static/js/vendor/jquery-1.9.1.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if version and version in cver \
                                        and not reinstall \
                                        and not pkg_verify:
                                    # The package is installed and is the correct version
                                    return {'name': name,
                    Severity: Major
                    Found in salt/states/pkg.py - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if not cleanup_temp and (not exists or (exists and start)) \
                                  or (start and cleanup_temp and pre_state != 'running'):
                              if __opts__['test']:
                                  ret['result'] = None
                                  comments.append('Container would be started')
                      Severity: Major
                      Found in salt/states/docker_container.py - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                                if ((ip or netmask or gateway) and not dhcp and (ip != current_nic['Network']['IP Address'] or
                                                                                         netmask != current_nic['Network']['Subnet Mask'] or
                                                                                         gateway != current_nic['Network']['Gateway'])):
                                    ret['changes'].update({'IP': {'Old': current_nic['Network'],
                                                                  'New': {'IP Address': ip,
                        Severity: Major
                        Found in salt/states/dellchassis.py - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  if (salt.utils.platform.is_windows() and
                                          user_to_uid(user) != user_to_uid(
                                              get_user(name, follow_symlinks=follow_symlinks)) and
                                          user != ''
                                      ) or (
                          Severity: Major
                          Found in salt/modules/file.py - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if (salt.utils.platform.is_windows() and
                                            group_to_gid(group) != group_to_gid(
                                                get_group(name, follow_symlinks=follow_symlinks)) and
                                            user != '') or (
                                        not salt.utils.platform.is_windows() and
                            Severity: Major
                            Found in salt/modules/file.py - About 1 hr to fix

                              Consider simplifying this complex logical expression.
                              Open

                                          if template_hash and isinstance(template_hash, six.string_types) and not\
                                                  (template_hash.startswith('salt://') or template_hash.startswith('file://')):
                                              # If the template hash is passed as string, and it's not a file
                                              # (starts with the salt:// or file:// URI), then make it a list
                                              # of 1 element (for the iteration below)
                              Severity: Major
                              Found in salt/modules/napalm_network.py - About 1 hr to fix

                                Consider simplifying this complex logical expression.
                                Open

                                                    if vm_name not in names:
                                                        continue
                                
                                                    elif driver == 'ec2' and 'aws' in handled_drivers and \
                                                            'aws' in matches[handled_drivers['aws']] and \
                                Severity: Major
                                Found in salt/cloud/__init__.py - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                          if self.selected_query_option is not None:
                                              if self.selected_query_option == 'list_providers':
                                                  try:
                                                      ret = mapper.provider_list()
                                                  except (SaltCloudException, Exception) as exc:
                                  Severity: Major
                                  Found in salt/cloud/cli.py - About 1 hr to fix

                                    Function factory has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def factory(cls, opts, **kwargs):
                                            # Default to ZeroMQ for now
                                            ttype = 'zeromq'
                                    
                                            # determine the ttype
                                    Severity: Minor
                                    Found in salt/transport/client.py - About 55 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 main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    def main(argv):
                                        target = ''
                                        search = os.path.dirname(sys.executable)
                                        replace = '..'
                                        try:
                                    Severity: Minor
                                    Found in pkg/windows/portable.py - About 55 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 connect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def connect(self):
                                            try:
                                                self.auth = salt.crypt.AsyncAuth(self.opts, io_loop=self.io_loop)
                                                self.tok = self.auth.gen_token(b'salt')
                                                if not self.auth.authenticated:
                                    Severity: Minor
                                    Found in salt/transport/tcp.py - About 55 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