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
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
- Read upRead up
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:
- Read upRead up
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)')
- Read upRead up
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:
- Read upRead up
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:
- Read upRead up
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
- Read upRead up
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:
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)
- Read upRead up
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)
- Read upRead up
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):
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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:
- Read upRead up
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'):
Function printScript
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def printScript(msg='', header='', lf=True, noleft=False, noright=False,
Function getSftp
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def getSftp(ip, remotefile, localfile, secret='', sshuser='root'):
Function getDevicesArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def getDevicesArray(fieldnrs='', subnet='', pxeflag='', stype=False,
Function putSftp
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def putSftp(ip, localfile, remotefile, secret='', sshuser='root'):
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)
- Read upRead up
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"