e-mental-health/data-processing

View on GitHub
ovk2table.py

Summary

Maintainability
C
1 day
Test Coverage

Function findDate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def findDate(line,inFileName):
    match = re.search(r"([0-9]+)-([0-9]+)-([0-9]+)(\s+([0-9]+):([0-9]+)(:([0-9]+))?)?",line)
    if not match: 
        sys.exit(COMMAND+": error: no date in file "+inFileName+" on line: "+line)
    else:
Severity: Minor
Found in ovk2table.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

Consider simplifying this complex logical expression.
Open

        if re.search(DATEPATTERN1,line) or \
           re.search(DATEPATTERN2,line) or \
           re.search(DATEPATTERN3,line) or \
           re.search(DATEPATTERN4,line): 
            date = findDate(line,inFileName)
Severity: Critical
Found in ovk2table.py - About 2 hrs to fix

    Function findSender has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def findSender(line,inFileName):
        match = re.search(SENDERPATTERN1+r" *(.*)",line)
        if match: sender = match.group(1)
        else:
            match = re.search(SENDERPATTERN2+r" *(.*)",line)
    Severity: Minor
    Found in ovk2table.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 findReceiver has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def findReceiver(line,inFileName):
        match = re.search(RECEIVERPATTERN1+r" *(.*)",line)
        if match: receiver = match.group(1)
        else:
            match = re.search(RECEIVERPATTERN2+r" *(.*)",line)
    Severity: Minor
    Found in ovk2table.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 processMailHeader has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def processMailHeader(mailText,inFileName):
        date, receiver, receiverName, sender, senderName, subject = ("","","","","","")
        mailLines = mailText.split("\n")
        skipLines = 0
        for line in mailLines:
    Severity: Minor
    Found in ovk2table.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 findSubject has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def findSubject(line,inFileName):
        match = re.search(SUBJECTPATTERN1+r" *(.*)",line)
        if match: subject = match.group(1)
        else:
            match = re.search(SUBJECTPATTERN2+r" *(.*)",line)
    Severity: Minor
    Found in ovk2table.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 fixCounselor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def fixCounselor(mails):
        counselor = ""
        for mail in mails:
            if mail[COUNSELORID] != "": 
                counselor = mail[COUNSELORID]
    Severity: Minor
    Found in ovk2table.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 analyzeText has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def analyzeText(text):
        tokens = text.split()
        nbrOfWords = 0
        nbrOfCharsInWords = 0
        nbrOfSents = 0
    Severity: Minor
    Found in ovk2table.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 anonymizeCounselor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def anonymizeCounselor(name):
        global counselorIds;
    
        if not name in counselorIds.keys(): 
            thisId = random.randrange(COUNSELORIDMIN,COUNSELORIDMAX)
    Severity: Minor
    Found in ovk2table.py - About 25 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

    There are no issues that match your filters.

    Category
    Status