linuxmuster/linuxmuster-linuxclient7

View on GitHub

Showing 53 of 55 total issues

Function _processPrintersPolicy has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def _processPrintersPolicy(policyBasepath):
    logging.info("== Parsing a printer policy! ==")
    policyFile = "{}/User/Preferences/Printers/Printers.xml".format(policyBasepath)
    printerList = []
    # test
Severity: Minor
Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/gpo.py - About 3 hrs 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 _processDrivesPolicy has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def _processDrivesPolicy(policyBasepath):
    logging.info("== Parsing a drive policy! ==")
    policyFile = "{}/User/Preferences/Drives/Drives.xml".format(policyBasepath)
    shareList = []

Severity: Minor
Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/gpo.py - About 3 hrs 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 searchOne has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def searchOne(filter):
    """Searches the LDAP with a filter and returns the first found object

    :param filter: A valid ldap filter
    :type filter: str
Severity: Minor
Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/ldapHelper.py - About 2 hrs 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

File __init__.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import binascii

class Krb5KeytabUtil:
    """
    A class to parse and create krb5keytab content.
Severity: Minor
Found in usr/lib/python3/dist-packages/krb5KeytabUtil/__init__.py - About 2 hrs to fix

    Function _processFilters has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def _processFilters(policies):
        filteredPolicies = []
    
        for policy in policies:
            if  not len(policy["filters"]) > 0:
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/gpo.py - About 2 hrs 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 patchKeytab has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def patchKeytab():
        """
        Patches the `/etc/krb5.keytab` file. It inserts the correct hostname of the current computer.
    
        :return: True on success, False otherwise
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/keytab.py - About 2 hrs 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 printLogs has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def printLogs(compact=False,anonymize=False):
        """
        Print logs of linuxmuster-linuxclient7 from `/var/log/syslog`.
    
        :param compact: If set to True, some stuff like time and date will be removed. Defaults to False
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/logging.py - About 1 hr 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 setup has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def setup(domain=None, user=None):
        """
        Sets up the client to be able to act in a linuxmuster environment
    
        :param domain: The domain to join, defaults to the first discovered domain
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/setup.py - About 1 hr 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 unmountAllSharesOfUser has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def unmountAllSharesOfUser(username):
        """
        Unmount all shares of a given user and safely delete the mountpoints and the parent directory.
    
        :param username: The username of the user
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/shares.py - About 1 hr 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 _clearUserHomes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _clearUserHomes(unattended=False):
        print("\nCAUTION! This will delete all userhomes of AD users!")
        if not unattended and not _askStep("clear all user homes now", False):
            return True
    
    

    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 _mountShare has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _mountShare(username, networkPath, shareName, hiddenShare, useCruidOfExecutingUser=False):
    
        mountpoint = _getShareMountpoint(networkPath, username, hiddenShare, shareName)
    
        mountCommandOptions = f"file_mode=0700,dir_mode=0700,sec=krb5,nodev,nosuid,mfsymlinks,nobrl,vers=3.0,user={username}"
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/shares.py - About 1 hr 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 _getRemoteHookScripts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _getRemoteHookScripts(hookType):
        if not hookType in remoteScriptNames:
            return False, None
    
        rc, networkConfig = config.network()
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/hooks.py - About 1 hr 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 prepareForImage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def prepareForImage(unattended=False):
        """Prepare the computer for creating an image
    
        :param unattended: If set to True, all questions will be answered with yes, defaults to False
        :type unattended: bool, optional
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/imageHelper.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 removeLinesInFileContainingString has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def removeLinesInFileContainingString(filePath, forbiddenStrings):
        """
        Remove all lines containing a given string form a file.
    
        :param filePath: The path to the file
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/fileHelper.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 deleteAllInDirectory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def deleteAllInDirectory(directory):
        """
        Delete all files in a given directory
    
        :param directory: The path of the directory
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/fileHelper.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 _stripComment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def _stripComment(fileData):
        filedata_stripped = ''
        for line in fileData.split('\n'):
            if line[:1] == '#':
                continue
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/templates.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 deleteFilesWithExtension has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def deleteFilesWithExtension(directory, extension):
        """
        Delete all files with a given extension in a given directory.
    
        :param directory: The path of the directory
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/fileHelper.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 _mountShare has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _mountShare(username, networkPath, shareName, hiddenShare, useCruidOfExecutingUser=False):
    Severity: Minor
    Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/shares.py - About 35 mins to fix

      Function upgrade has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def upgrade():
          """
          Performs an upgrade of the linuxmuster-linuxclient7. This is executed after the package is updated.
      
          :return: True on success, False otherwise
      Severity: Minor
      Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/setup.py - About 35 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 _unmountShare has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def _unmountShare(mountpoint):
          # check if mountpoint exists
          if (not os.path.exists(mountpoint)) or (not os.path.isdir(mountpoint)):
              logging.warning(f"* Could not unmount {mountpoint}, it does not exist.")
      
      
      Severity: Minor
      Found in usr/lib/python3/dist-packages/linuxmusterLinuxclient7/shares.py - About 35 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