e-mental-health/data-processing

View on GitHub
tactus2liwc-nl.py

Summary

Maintainability
D
2 days
Test Coverage

File tactus2liwc-nl.py has 313 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python3
"""
    tactus2liwc-nl.py: convert xml files from tactus to percentages of liwc categories
    usage: tactus2liwc-nl.py file1 [file2 ...]
    note: based on tactus2text.py, tactus2liwc-en.py and text2liwc.py
Severity: Minor
Found in tactus2liwc-nl.py - About 3 hrs to fix

    Function cleanupMails has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def cleanupMails(clientMails, counselorMails):
        clientSentenceDates = {}
        counselorSentenceDates = {}
        for i in range(0,len(clientMails)):
            date = clientMails[i][MAILDATEID]
    Severity: Minor
    Found in tactus2liwc-nl.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

    Function storeDictTitles has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def storeDictTitles(questionnaires):
        titles = getTitles(questionnaires)
        for title in titles.keys():
            columns = getColumns(questionnaires,title)
            outFileName = OUTPUTDIR+"/"+title+".csv"
    Severity: Minor
    Found in tactus2liwc-nl.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

    Function getQuestionnaires has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def getQuestionnaires(root,thisId):
        qs = []
        for questionnaires in INTAKEQUESTIONNAIRE,QUESTIONNAIRE:
            for questionnaire in root.findall(questionnaires):
                title = cleanupText(questionnaire.findall("./Title")[0].text)
    Severity: Minor
    Found in tactus2liwc-nl.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 readWords has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def readWords(inFile):
        words = {}
        prefixes = {}
        for line in inFile:
            line = line.strip()
    Severity: Minor
    Found in tactus2liwc-nl.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 getEmailData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def getEmailData(root,thisId):
        clientMails = []
        counselorMails = []
        for message in root.findall(MESSAGES):
            body = ""
    Severity: Minor
    Found in tactus2liwc-nl.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 text2liwc has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def text2liwc(words,prefixes,tokens):
        global numberId
    
        counts = { NBROFMATCHES:0 }
        for token in tokens:
    Severity: Minor
    Found in tactus2liwc-nl.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

    Avoid deeply nested control flow statements.
    Open

                        for columnName in sorted(columns.keys()): 
                            try: row.append(questionnaire[columnName])
                            except: row.append("")
                        csvwriter.writerow(row)
    Severity: Major
    Found in tactus2liwc-nl.py - About 45 mins to fix

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

      def printResults(featureNames,results):
          first = True
          for featureName in featureNames:
              if not first: print(",",end="")
              else: first = False
      Severity: Minor
      Found in tactus2liwc-nl.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 getColumns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def getColumns(questionnaires,title):
          columns = {}
          for questionnaire in questionnaires:
              if questionnaire["title"] == title:
                  for field in questionnaire.keys():
      Severity: Minor
      Found in tactus2liwc-nl.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