saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def _openbsd_remotes_on(port, which_end):
    '''
    OpenBSD specific helper function.
    Returns set of ipv4 host addresses of remote established connections
    on local or remote tcp port.
Severity: Minor
Found in salt/utils/network.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 _aix_remotes_on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def _aix_remotes_on(port, which_end):
    '''
    AIX specific helper function.
    Returns set of ipv4 host addresses of remote established connections
    on local or remote tcp port.
Severity: Minor
Found in salt/utils/network.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.strip().startswith('sl'):
                        continue
                    iret = _parse_tcp_line(line)
Severity: Major
Found in salt/utils/network.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if line.strip().startswith('sl'):
                            continue
                        iret = _parse_tcp_line(line)
    Severity: Major
    Found in salt/utils/network.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if '.' in ip:
                              if 'inet' not in ifaces[iface.Description]:
                                  ifaces[iface.Description]['inet'] = []
                              item = {'address': ip,
                                      'label': iface.Description}
      Severity: Major
      Found in salt/utils/win_network.py - About 45 mins to fix

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

            def construct_scalar(self, node):
                '''
                Verify integers and pass them in correctly is they are declared
                as octal
                '''
        Severity: Minor
        Found in salt/utils/yamlloader.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 mmask.group(1):
                                mmask = _number_of_set_bits_to_ipv4_netmask(
                                    int(mmask.group(1), 16))
                            else:
                                mmask = mmask.group(2)
        Severity: Major
        Found in salt/utils/network.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not isinstance(subnode, MappingNode):
                                      raise ConstructorError("while constructing a mapping",
                                                             node.start_mark,
                                                             "expected a mapping for merging, but found {0}".format(subnode.id),
                                                             subnode.start_mark)
          Severity: Major
          Found in salt/utils/yamlloader.py - About 45 mins to fix

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

            def _windows_remotes_on(port, which_end):
                r'''
                Windows specific helper function.
                Returns set of ipv4 host addresses of remote established connections
                on local or remote tcp port.
            Severity: Minor
            Found in salt/utils/network.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 ':' in ip:
                                    if 'inet6' not in ifaces[iface.Description]:
                                        ifaces[iface.Description]['inet6'] = []
                                    item = {'address': ip}
                                    if iface.DefaultIPGateway:
            Severity: Major
            Found in salt/utils/win_network.py - About 45 mins to fix

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

                  def _filter(self, event):
                      '''
                      Take an event and run it through configured filters.
              
                      Returns True if event should be stored, else False
              Severity: Minor
              Found in salt/utils/event.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 mod_dir.endswith(util_dir) and mod_dir not in sys.path:
                                          sys.path.append(mod_dir)
              
              
              Severity: Major
              Found in salt/utils/extmods.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if load['retcode'].get(fun, 0) and fun in SUB_EVENT:
                                            # Minion fired a bad retcode, fire an event
                                            self._fire_ret_load_specific_fun(load, fun_index)
                            else:
                Severity: Major
                Found in salt/utils/event.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if src_digest != dst_digest:
                                              # The downloaded file differs, replace!
                                              shutil.copyfile(fn_, dest)
                                              ret.append('{0}.{1}'.format(form, relname))
                                      else:
                  Severity: Major
                  Found in salt/utils/extmods.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if not os.path.isdir(dest_dir):
                                                os.makedirs(dest_dir)
                                            shutil.copyfile(fn_, dest)
                    Severity: Major
                    Found in salt/utils/extmods.py - About 45 mins to fix

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

                      def cache_id(service, name, sub_resource=None, resource_id=None,
                                   invalidate=False, region=None, key=None, keyid=None,
                                   profile=None):
                          '''
                          Cache, invalidate, or retrieve an AWS resource id keyed by name.
                      Severity: Minor
                      Found in salt/utils/botomod.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 iret[sl][which_end] == port and iret[sl]['state'] == 1:  # 1 is ESTABLISHED
                                              ret.add(iret[sl]['remote_addr'])
                      
                      
                      Severity: Major
                      Found in salt/utils/network.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if self.opts['master_stats']:
                                                    _data = data['data']
                                                    start = time.time()
                                                try:
                        Severity: Major
                        Found in salt/utils/reactor.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              for chunk in data['hwaddr'].split(':'):
                                                  expand_mac.append('0{0}'.format(chunk) if len(chunk) < 2 else '{0}'.format(chunk))
                                              data['hwaddr'] = ':'.join(expand_mac)
                          Severity: Major
                          Found in salt/utils/network.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if not salt.utils.platform.is_sunos():
                                                    ipv6scope = mmask6.group(3) or mmask6.group(4)
                                                    addr_obj['scope'] = ipv6scope.lower() if ipv6scope is not None else ipv6scope
                                            # SunOS sometimes has ::/0 as inet6 addr when using addrconf
                                            if not salt.utils.platform.is_sunos() \
                            Severity: Major
                            Found in salt/utils/network.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language