saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def tablespace_alter(name, user=None, host=None, port=None, maintenance_db=None,
                     password=None, new_name=None, new_owner=None,
                     set_option=None, reset_option=None, runas=None):
    '''
    Change tablespace name, owner, or options.
Severity: Minor
Found in salt/modules/postgres.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 reboot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def reboot(name, kill=False):
    '''
    Reboot the container by sending a SIGINT to its init process. Equivalent
    to running ``machinectl reboot`` on the named container.

Severity: Minor
Found in salt/modules/nspawn.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 _root has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def _root(name='', all_roots=False):
    '''
    Return the container root directory. Starting with systemd 219, new
    images go into /var/lib/machines.
    '''
Severity: Minor
Found in salt/modules/nspawn.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 get_loginclass has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_loginclass(name):
    '''
    Get the login class of the user

    name
Severity: Minor
Found in salt/modules/useradd.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 times_looped > number_retries:
                            raise SaltInvocationError(
                                'Attemping to sign file {0} failed, timed out after {1} seconds'
                                .format(abs_file, int(times_looped * interval))
                            )
Severity: Major
Found in salt/modules/rpmbuild_pkgbuild.py - About 45 mins to fix

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

    def _make_privileges_list_query(name, object_type, prepend):
        '''
        Generate the SQL required for specific object type
        '''
        if object_type == 'table':
    Severity: Minor
    Found in salt/modules/postgres.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 _process_defpriv_part has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _process_defpriv_part(defperms):
        '''
        Process part
        '''
        _tmp = {}
    Severity: Minor
    Found in salt/modules/postgres.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 include not in ret['include files']:
                            ret['include files'][include] = []
    
    
    Severity: Major
    Found in salt/modules/logrotate.py - About 45 mins to fix

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

      def __load_compose_definitions(path, definition):
          '''
          Will load the compose file located at path
          Then determines the format/contents of the sent definition
      
      
      Severity: Minor
      Found in salt/modules/dockercompose.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 get_ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_(*keyname):
          '''
          Get metadata
      
          keyname : string
      Severity: Minor
      Found in salt/modules/mdata.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 line.startswith('lib/'):
                              files.append(line.replace('lib/', ins_path).strip())
      
      
      Severity: Major
      Found in salt/modules/cpan.py - About 45 mins to fix

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

        def remove(name, stop=False):
            '''
            Remove the named container
        
            .. warning::
        Severity: Minor
        Found in salt/modules/nspawn.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 stdout and SIGN_PROMPT_RE.search(stdout):
                                    # have the prompt for inputting the passphrase
                                    proc.sendline(phrase)
                                else:
                                    times_looped += 1
        Severity: Major
        Found in salt/modules/rpmbuild_pkgbuild.py - About 45 mins to fix

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

          def list_tags(DomainName=None, ARN=None,
                     region=None, key=None, keyid=None, profile=None):
              '''
              List tags of a trail
          
          
          Severity: Minor
          Found in salt/modules/boto_elasticsearch_domain.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 file_key in include_conf:
                                  ret[file_key] = include_conf[file_key]
                                  ret['include files'][include].append(file_key)
          
          
          Severity: Major
          Found in salt/modules/logrotate.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if 'yes' in line:
                                        cmd.extend([
                                            '-g', __salt__['file.group_to_gid'](name)
                                        ])
            
            
            Severity: Major
            Found in salt/modules/useradd.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if 'group' not in line[:5]:
                                          continue
              
              
              Severity: Major
              Found in salt/modules/useradd.py - About 45 mins to fix

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

                def drop_extension(name,
                                   if_exists=None,
                                   restrict=None,
                                   cascade=None,
                                   user=None,
                Severity: Minor
                Found in salt/modules/postgres.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 run_stdout(name, cmd):
                                        log.error('tmpdir %s creation failed (%s)', dest_dir, cmd)
                                        return False
                                copy_to(name,
                Severity: Major
                Found in salt/modules/nspawn.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if 'USERGROUPS_ENAB' not in line[:15]:
                                              continue
                  
                  
                  Severity: Major
                  Found in salt/modules/useradd.py - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language