saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if six.text_type(opt) == six.text_type(data[key]):
                            break
                    else:
Severity: Major
Found in salt/engines/junos_syslog.py - About 45 mins to fix

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

    def config(conf_path='/etc/rsyncd.conf'):
        '''
        .. versionchanged:: 2016.3.0
            Return data now contains just the contents of the rsyncd.conf as a
            string, instead of a dictionary as returned from :py:func:`cmd.run_all
    Severity: Minor
    Found in salt/modules/rsync.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 procs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def procs():
        '''
        Return the process data
    
        .. versionchanged:: 2016.11.4
    Severity: Minor
    Found in salt/modules/status.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 pid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def pid(sig):
        '''
        Return the PID or an empty string if the process is running or not.
        Pass a signature to use to find the process via ps.  Note you can pass
        a Python-compatible regular expression to return all pids of
    Severity: Minor
    Found in salt/modules/status.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 list_team_repos has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_team_repos(team_name, profile="github", ignore_cache=False):
        '''
        Gets the repo details for a given team as a dict from repo_name to repo details.
        Note that repo names are always in lower case.
    
    
    Severity: Minor
    Found in salt/modules/github.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 regex.match(fstype):
                            selected.add(mntpt)
    
        # query the filesystems disk usage
        ret = {}
    Severity: Major
    Found in salt/modules/status.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if stop_check(stack_status):
                              return stack_status, msg
      
      
      Severity: Major
      Found in salt/modules/heat.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if regex.match(fstype):
                                selected.add(mntpt)
                    else:
        Severity: Major
        Found in salt/modules/status.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  for line in fp_:
                                      line = salt.utils.stringutils.to_unicode(line)
                                      if line.startswith('clock='):
                                          line = line.rstrip('\n')
                                          line = line.split('=')[-1].strip('\'"')
          Severity: Major
          Found in salt/modules/timezone.py - About 45 mins to fix

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

            def zone_compare(timezone):
                '''
                Compares the given timezone name with the system timezone name.
                Checks the hash sum between the given timezone, and the one set in
                /etc/localtime. Returns True if names and hash sums match, and False if not.
            Severity: Minor
            Found in salt/modules/timezone.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 re.match(r'^\s*#', line):
                                        continue
                                    if 'UTC=' in line:
            Severity: Major
            Found in salt/modules/timezone.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if 'comment' in line[key]:
                                      out_line = ' # '.join((out_line, line[key]['comment']))
                              if out_line:
              Severity: Major
              Found in salt/modules/lxc.py - About 45 mins to fix

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

                def wait_started(name, path=None, timeout=300):
                    '''
                    Check that the system has fully inited
                
                    This is actually very important for systemD based containers
                Severity: Minor
                Found in salt/modules/lxc.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 key in kw:
                                        found = True
                                        data.append({key: kw[key]})
                                        del kw[key]
                                if not found:
                Severity: Major
                Found in salt/modules/lxc.py - About 45 mins to fix

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

                  def _output_to_dict(cmdoutput, values_mapper=None):
                      '''
                      Convert rabbitmqctl output to a dict of data
                      cmdoutput: string output of rabbitmqctl commands
                      values_mapper: function object to process the values part of each line
                  Severity: Minor
                  Found in salt/modules/rabbitmq.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 match:
                                              self.data.append((match[0][0], match[0][-1]))
                                          match = self.non_interpretable_pattern.findall(
                  Severity: Major
                  Found in salt/modules/lxc.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if line.startswith('TZ=UTC'):
                                                return 'UTC'
                                        return 'localtime'
                    Severity: Major
                    Found in salt/modules/timezone.py - About 45 mins to fix

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

                      def fs_extend(name, size):
                          '''
                      
                          Resize an existing filesystem on a Pure Storage FlashBlade.
                      
                      
                      Severity: Minor
                      Found in salt/modules/purefb.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 (
                                              not line[0].startswith(opt) and
                                              line not in dest_lxc_conf
                                          ):
                                              dest_lxc_conf.append(line)
                      Severity: Major
                      Found in salt/modules/lxc.py - About 45 mins to fix

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

                        def _check_load_paths(load_path):
                            '''
                            Checks the validity of the load_path, returns a sanitized version
                            with invalid paths removed.
                            '''
                        Severity: Minor
                        Found in salt/modules/augeas_cfg.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