File tactusVisualize.py
has 405 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
"""
tactus-visualize.py: support functions for tactus-visualize.ipynb
usage: import tactus-visualize
20190108 erikt(at)xs4all.nl
Function makeTableDAAP
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def makeTableDAAP(fileName,data,index=-1,user="",average=False):
if user == "CLIENT" or user == "COUNSELOR":
values = [ x for x in data if x[SENDER] == user ]
else:
values = [ x for x in data if x[MAILID] == index ]
- 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 visualizeDAAP
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def visualizeDAAP(file,user="",mail=-1,average=False,linemax=LINEMAX,equalwidth=False,table=False):
data = readData(file)
if len(data) == 0: sys.exit("no data found!")
if table:
if user == CLIENT or user == COUNSELOR:
- 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 summarizeData
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def summarizeData(data,target):
summary = {}
for row in data:
if target == None or row[SENDER] == target:
for featureName in row:
- 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 makePlotDAAP
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def makePlotDAAP(fileName,data,index=-1,user="",average=False,linemax=LINEMAX,equalwidth=False):
plt.figure(figsize=(PLOTWIDTH,PLOTHEIGHT))
if user == "CLIENT" or user == "COUNSELOR":
values = [ x for x in data if x[SENDER] == user ]
else:
- 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 computeStats
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def computeStats(data):
stats = { CLIENT:{AVERAGE:0.0,COUNT:0,MAX:-1.0,MIN:1.0,SD:0.0,TOTAL:0.0,TOTALDEV:0.0},
COUNSELOR:{AVERAGE:0.0,COUNT:0,MAX:-1.0,MIN:1.0,SD:0.0,TOTAL:0.0,TOTALDEV:0.0} }
for d in data:
if SENDER in d and d[SENDER] in stats:
- 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 convertToAverages
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def convertToAverages(valuesIn,equalwidth=False):
startI = 0
startId = int(valuesIn[0][MAILID])
totalDAAP = 0.0
valuesOut = []
- 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 printSummary
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def printSummary(data,summary,type=DATA):
if NBROFTOKENS in summary: print("tokens:",int(summary[NBROFTOKENS]))
if NBROFMATCHES in summary: print("number of matches:",summary[NBROFMATCHES])
for element in sorted(summary.items(), \
key=operator.itemgetter(1),reverse=True):
- 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 makeBottomValues
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def makeBottomValues(fieldDataList,index,format):
bottomValues = []
for i in range(0,len(fieldDataList)):
for j in range(0,len(fieldDataList[i])):
while len(bottomValues) < j+1: bottomValues.append(0)
- 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 eraseOtherSenders
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def eraseOtherSenders(fieldDataList,senders,target):
outList = []
nbrOfMails = 0
for i in range(0,len(fieldDataList)):
outSubList = []
- 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 summarizeDataMail
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def summarizeDataMail(data,mailId):
summary = {}
if mailId >= 0 and mailId < len(data):
row = data[mailId]
for featureName in row:
- 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 makePlotDatesPart
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def makePlotDatesPart(fieldDataList,fieldNames,format,barwidth,dates,senders,target):
Function visualizeDAAP
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def visualizeDAAP(file,user="",mail=-1,average=False,linemax=LINEMAX,equalwidth=False,table=False):
Function makePlotDAAP
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def makePlotDAAP(fileName,data,index=-1,user="",average=False,linemax=LINEMAX,equalwidth=False):
Avoid deeply nested control flow statements. Open
if featureName in summary:
summary[featureName] += 1
else:
summary[featureName] = 1
return(summary)
Function makePlotDates
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def makePlotDates(fieldDataList,fieldNames,format,barwidth,dates,senders):
Function visualize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def visualize(file,features,format="",barwidth=BARWIDTH,target=CLIENT,diaries=True):
Avoid deeply nested control flow statements. Open
if featureName in summary:
summary[featureName] += int(row[featureName])
else:
summary[featureName] = int(row[featureName])
else:
Function makeTableDAAP
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def makeTableDAAP(fileName,data,index=-1,user="",average=False):
Function makePlotIndexPart
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def makePlotIndexPart(fieldDataList,fieldNames,format,senders,target):