saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def _try_func(conn, func, **args):
    tries = 30
    while True:
        try:
            return getattr(conn, func)(**args)
Severity: Minor
Found in salt/modules/boto_route53.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 __grant_generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def __grant_generate(grant,
                    database,
                    user,
                    host='localhost',
                    grant_option=False,
Severity: Minor
Found in salt/modules/mysql.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 item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def item(*args, **kwargs):
    '''
    Return one or more grains

    CLI Example:
Severity: Minor
Found in salt/modules/grains.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 compression in ('bzip2', 'xz'):
                            data = compressor.compress(buf)
                            if data:
                                out.write(data)
                        else:
Severity: Major
Found in salt/modules/dockermod.py - About 45 mins to fix

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

    def networks(names=None, ids=None):
        '''
        .. versionchanged:: 2017.7.0
            The ``names`` and ``ids`` can be passed as a comma-separated list now,
            as well as a Python list.
    Severity: Minor
    Found in salt/modules/dockermod.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def call(name, function, *args, **kwargs):
        '''
        Executes a Salt function inside a running container
    
        .. versionadded:: 2016.11.0
    Severity: Minor
    Found in salt/modules/dockermod.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 lchown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def lchown(path, user, group):
        '''
        Chown a file, pass the file the desired user and group without following
        symlinks.
    
    
    Severity: Minor
    Found in salt/modules/file.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 _mod_bufsize_linux has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _mod_bufsize_linux(iface, *args, **kwargs):
        '''
        Modify network interface buffer sizes using ethtool
        '''
        ret = {'result': False,
    Severity: Minor
    Found in salt/modules/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 (requested_seuser or requested_serole or requested_serange) and not requested_setype:
                                requested_setype = current_setype
                            result = set_selinux_context(name, user=requested_seuser, role=requested_serole,
    Severity: Major
    Found in salt/modules/file.py - About 45 mins to fix

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

      def chattr(*files, **kwargs):
          '''
          .. versionadded:: 2018.3.0
      
          Change the attributes of files. This function accepts one or more files and
      Severity: Minor
      Found in salt/modules/file.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 senv:
                              senv = saltenv
                          if (path, saltenv) in mfiles or (path, saltenv) in mdirs:
      Severity: Major
      Found in salt/modules/file.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if any(attr for attr in cmp_attrs):
                                ret['result'] = False
                                ret['comment'].append(
                                    'Failed to change attributes to {0}'.format(attrs)
                                )
        Severity: Major
        Found in salt/modules/file.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if insert_before_match:
                                  match_idx += 1
                          block_found = True
          Severity: Major
          Found in salt/modules/file.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if line[source_hash_name_idx] in string.whitespace:
                                        _add_to_matches(found, line, 'source_hash_name',
                                                        source_hash_name, matched)
                                        hash_matched = True
                                except IndexError:
            Severity: Major
            Found in salt/modules/file.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if diff_attrs.removed:
                                      chattr(
                                          name,
                                          operator="remove",
                                          attributes=diff_attrs.removed,
              Severity: Major
              Found in salt/modules/file.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                if cmnt:
                                                    wline = '{0}{1}'.format(char, line)
                                                else:
                                                    wline = line.lstrip(char)
                                            else:
                Severity: Major
                Found in salt/modules/file.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if mode != salt.utils.files.normalize_mode(get_mode(name)):
                                          ret['result'] = False
                                          ret['comment'].append(
                                              'Failed to change mode to {0}'.format(mode)
                                          )
                  Severity: Major
                  Found in salt/modules/file.py - About 45 mins to fix

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

                    def _get_bufsize_linux(iface):
                        '''
                        Return network interface buffer information using ethtool
                        '''
                        ret = {'result': False}
                    Severity: Minor
                    Found in salt/modules/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 'label' in inet:
                                            intfnames.append(inet['label'])
                                        else:
                                            intfnames.append(ifname)
                        return intfnames
                    Severity: Major
                    Found in salt/modules/network.py - About 45 mins to fix

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

                      def show_sls(name, saltenv='base'):
                          r'''
                          .. versionadded:: 2015.8.0
                      
                          Display the rendered software definition from a specific sls file in the
                      Severity: Minor
                      Found in salt/modules/winrepo.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