linuxmuster/linuxmuster-base7

View on GitHub

Showing 69 of 69 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    subProc('samba-tool domain provision --use-rfc2307 --server-role=dc --domain=' + sambadomain + ' --realm=' + realm + ' --adminpass=' + adadminpw, logfile)
Severity: Major
Found in lib/setup.d/j_samba-provisioning.py and 1 other location - About 1 hr to fix
lib/setup.d/k_samba-users.py on lines 61..62

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 38.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    subProc('net conf addshare ' + schoolname + ' '
            + defaultpath + ' ' + shareopts, logfile)
Severity: Major
Found in lib/setup.d/k_samba-users.py and 1 other location - About 1 hr to fix
lib/setup.d/j_samba-provisioning.py on lines 77..77

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 38.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      printScript(' ' + dhcprange1 + '-' + dhcprange2,
                  '', True, True, False, len(msg))
      Severity: Minor
      Found in lib/setup.d/a_ini.py and 1 other location - About 40 mins to fix
      lib/setup.d/l_add-server.py on lines 130..134

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 34.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if rc == False:
              printScript(' Failed!', '', True, True, False, len(msg))
              sys.exit(1)
          else:
              printScript(' ' + ip + ' ' + mac, '', True, True, False, len(msg))
      Severity: Minor
      Found in lib/setup.d/l_add-server.py and 1 other location - About 40 mins to fix
      lib/setup.d/a_ini.py on lines 143..144

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 34.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

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

            def sshExec(ip, cmd, secret=''):
                printScript('Executing ssh command on ' + ip + ':')
                printScript('* -> "' + cmd + '"')
                sshcmd = 'ssh -q -oNumberOfPasswordPrompts=0 -oStrictHostkeyChecking=no -l root ' + ip
                # first test connection
            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

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

            def getHostname(devices, search):
                try:
                    hostname = None
                    hostrow = None
                    f = open(devices, newline='')
            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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                subProc('sophomorix-admin --create-school-admin pgmadmin --school '
                        + schoolname + ' --password "' + adminpw + '"', logfile)
            Severity: Minor
            Found in lib/setup.d/k_samba-users.py and 2 other locations - About 30 mins to fix
            lib/setup.d/k_samba-users.py on lines 138..139
            share/examples/create-testusers.py on lines 137..138

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 32.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Avoid too many return statements within this function.
            Open

                    return False
            Severity: Major
            Found in lib/functions.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return True
              Severity: Major
              Found in lib/functions.py - About 30 mins to fix

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                        subProc('sophomorix-passwd --user ' + user
                                + ' --pass "' + pw + '"', logfile)
                Severity: Minor
                Found in share/examples/create-testusers.py and 2 other locations - About 30 mins to fix
                lib/setup.d/k_samba-users.py on lines 123..124
                lib/setup.d/k_samba-users.py on lines 138..139

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language