Function egofy
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def egofy(processedText,names,gender):
text = ""
textInitial = True
for paragraph in processedText:
sentenceInitial = 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
Consider simplifying this complex logical expression. Open
if token in names and names[token] == COMPLETE:
if re.search(r"VZ",lastPOS):
text += METOKEN[sentenceInitial]+" "
else:
text += ITOKEN[sentenceInitial]+" "
File egofy.py
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
"""
egofy.py: change Dutch biographic text to autobiographic text
usage: egofy.py [-t file.txt ] [-p file.txt.pos] [-n name] [-s]
notes:
Function nameMatch
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def nameMatch(targetNames,sourceNames,suffix=""):
for targetName in targetNames:
for sourceName in sourceNames:
targetName = targetName.lower()
sourceName = sourceName.lower()
- 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 nameCheckForMinusOneToken
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def nameCheckForMinusOneToken(targetName,sourceName,suffix):
targetNameTokens = targetName.split()
for i in range(0,len(targetNameTokens)):
name = ""
for j in range(0,len(targetNameTokens)):
- 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 savePosFile
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def savePosFile(processedOptions,outFileName):
outFileName += ".pos"
try: outFile = open(outFileName,"w")
except Exception as e: sys.exit(COMMAND+": cannot write file "+outFileName)
for paragraph in processedOptions:
- 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 getGenderDataFromVNW
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def getGenderDataFromVNW(processedText):
genderData = {}
for paragraph in processedText:
for tokenData in paragraph:
if re.match(r"^VNW\(",str(tokenData[POS])):
- 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
Avoid deeply nested control flow statements. Open
if not sentenceInitial:
text += "\n"
sentenceInitial = True
lastPOS = ""
else:
Function main
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def main(argv):
options,files,names = processOptions(argv)
if "-p" in options: processedText = readPosFile(options["-p"])
elif "-t" in options: processedText = processTextWithFrog(options["-t"])
else: sys.exit(USAGE)
- 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 processOptions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def processOptions(argv):
try:
names = {}
optionList, files = getopt.getopt(argv,"n:p:t:s",[])
options = {}
- 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
Avoid deeply nested control flow statements. Open
if token in names and names[token] == COMPLETE:
if re.search(r"VZ",lastPOS):
text += METOKEN[sentenceInitial]+" "
else:
text += ITOKEN[sentenceInitial]+" "
Avoid too many return
statements within this function. Open
return(True)
Avoid too many return
statements within this function. Open
return(False)
Function matchTokenToNames
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def matchTokenToNames(paragraph,start,names):
if not paragraph[start][TOKEN] in names: return(paragraph[start][TOKEN],start,start)
end = start
token = paragraph[start][TOKEN]
while end+1 < len(paragraph) and token+" "+paragraph[end+1][TOKEN] in names:
- 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 readPosFile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def readPosFile(inFileName):
try: inFile = open(inFileName,"r")
except Exception as e: sys.exit(COMMAND+": cannot read from file "+inFileName)
paragraph,processedText = [],[]
for line in inFile:
- 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"