linuxmuster/linuxmuster-base7

View on GitHub

Showing 32 of 69 total issues

File functions.py has 853 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python3
#
# functions.py
#
# thomas@linuxmuster.net
Severity: Major
Found in lib/functions.py - About 2 days to fix

    Function getDevicesArray has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    def getDevicesArray(fieldnrs='', subnet='', pxeflag='', stype=False,
                        school='default-school'):
        devices_array = []
        if school == "default-school":
            infile = open(constants.SOPHOSYSDIR
    Severity: Minor
    Found in lib/functions.py - About 5 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 main has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    def main():
        # get various setup values
        msg = 'Reading setup data '
        printScript(msg, '', False, False, True)
        try:
    Severity: Minor
    Found in lib/setup.d/m_firewall.py - About 4 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 scpTransfer has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def scpTransfer(ip, mode, sourcefile, targetfile, secret='', sshuser='root'):
        if mode == 'get' or mode == 'put':
            printScript(mode + ' ' + ip + ' ' + sourcefile + ' ' + targetfile)
        else:
            print('Usage: scpTransfer(ip, mode, sourcefile, targetfile, secret, sshuser)')
    Severity: Minor
    Found in lib/functions.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 getStartconfOsValues has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def getStartconfOsValues(startconf):
        rc, content = readStartconf(startconf)
        if not rc:
            return None
        try:
    Severity: Minor
    Found in lib/functions.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 getSubnetArray has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def getSubnetArray(fieldnrs=''):
        infile = open(constants.SUBNETSCSV, newline='')
        content = csv.reader(infile, delimiter=';', quoting=csv.QUOTE_NONE)
        subnet_array = []
        for row in content:
    Severity: Minor
    Found in lib/functions.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 printScript has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def printScript(msg='', header='', lf=True, noleft=False, noright=False,
                    offset=0):
        linelen = 78
        borderlen = 4
        border = '#' * borderlen
    Severity: Minor
    Found in lib/functions.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 main has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main():
        # get various setup values
        msg = 'Reading setup data '
        printScript(msg, '', False, False, True)
        try:
    Severity: Minor
    Found in lib/setup.d/m_firewall.py - About 1 hr to fix

      Function enterPassword has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def enterPassword(pwtype='the', validate=True, repeat=True):
          msg = '#### Enter ' + pwtype + ' password: '
          re_msg = '#### Please re-enter ' + pwtype + ' password: '
          while True:
              password = getpass.getpass(msg)
      Severity: Minor
      Found in lib/functions.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 subProc has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def subProc(cmd, logfile=None, hideopts=False):
          try:
              rc = True
              p = Popen(cmd, shell=True, universal_newlines=True,
                        stdout=PIPE, stderr=PIPE)
      Severity: Minor
      Found in lib/functions.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 getMacFromArp has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def getMacFromArp(ip):
          mac = ''
          c = 0
          max = 10
          while not isValidMac(mac):
      Severity: Minor
      Found in lib/setup.d/l_add-server.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 ipMatchSubnet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def ipMatchSubnet(ip, subnet):
          if ip == 'DHCP' and subnet == 'all':
              return True
          if ip == 'DHCP':
              return False
      Severity: Minor
      Found in lib/functions.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 isValidHostIpv4 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def isValidHostIpv4(ip):
          try:
              ipv4 = IP(ip)
              if not ipv4.version() == 4:
                  return False
      Severity: Minor
      Found in lib/functions.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 addServerDevice has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def addServerDevice(hostname, mac, ip, devices):
          if mac == '':
              return devices
          # server is type addc
          if ip == serverip:
      Severity: Minor
      Found in lib/setup.d/l_add-server.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 scpTransfer has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def scpTransfer(ip, mode, sourcefile, targetfile, secret='', sshuser='root'):
      Severity: Minor
      Found in lib/functions.py - About 45 mins to fix

        Function printScript has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def printScript(msg='', header='', lf=True, noleft=False, noright=False,
        Severity: Minor
        Found in lib/functions.py - About 45 mins to fix

          Function getSftp has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def getSftp(ip, remotefile, localfile, secret='', sshuser='root'):
          Severity: Minor
          Found in lib/functions.py - About 35 mins to fix

            Function getDevicesArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def getDevicesArray(fieldnrs='', subnet='', pxeflag='', stype=False,
            Severity: Minor
            Found in lib/functions.py - About 35 mins to fix

              Function putSftp has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def putSftp(ip, localfile, remotefile, secret='', sshuser='root'):
              Severity: Minor
              Found in lib/functions.py - About 35 mins to fix

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

                def firewallApi(request, path, data=''):
                    domainname = getSetupValue('domainname')
                    fwapi = configparser.RawConfigParser(
                        delimiters=('='), inline_comment_prefixes=('#', ';'))
                    fwapi.read(constants.FWAPIKEYS)
                Severity: Minor
                Found in lib/functions.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