e-mental-health/data-processing

View on GitHub
tactus2table.py

Summary

Maintainability
F
4 days
Test Coverage

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

def getQuestionnaires(root,thisId):
    global exceptions
    qs = []
    number = "0"
    for questionnaires in INTAKEQUESTIONNAIRE,QUESTIONNAIRE:
Severity: Minor
Found in tactus2table.py - About 6 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 cleanupMails has a Cognitive Complexity of 28 (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 tactus2table.py - About 4 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

File tactus2table.py has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/python3
"""
    tactus2table.py: convert xml files from tactus to csv tables
    usage: tactus2table.py file1 [file2 ...]
    note: writes output to ../output/emails.csv
Severity: Minor
Found in tactus2table.py - About 2 hrs to fix

    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 tactus2table.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 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 tactus2table.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 sentenceSplitLocal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def sentenceSplitLocal(text):
        tokens = text.split()
        sentence = []
        sentences = []
        for token in tokens:
    Severity: Minor
    Found in tactus2table.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

    Avoid deeply nested control flow statements.
    Open

                        if numbers != None and len(numbers) > 0:
                            number = cleanupText(numbers[0].text)
                        else:
                            number = str(int(number)+1)
                        for answer in question.findall(ANSWERS):
    Severity: Major
    Found in tactus2table.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for columnName in sortKeys(columns.keys()):
                              try: row.append(countsFilter(questionnaire[columnName],title))
                              except: row.append(EMPTYTOKEN)
                          csvwriter.writerow(row)
      Severity: Major
      Found in tactus2table.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for answer in question.findall(ANSWERS):
                                if ID in answer.attrib.keys(): key = answer.attrib[ID]
                                else: key = NOID
                                answerTexts = answer.findall("./answerText")
                                if len(answerTexts) > 0: value = cleanupText(answerTexts[0].text)
        Severity: Major
        Found in tactus2table.py - About 45 mins to fix

          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["0-title"] == title:
                      for field in questionnaire.keys():
          Severity: Minor
          Found in tactus2table.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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          def readRootFromFile(inFileName):
              if re.search(r"\.gz$",inFileName):
                  inFile = gzip.open(inFileName,"rb")
                  inFileContent = inFile.read()
                  inFile.close()
          Severity: Major
          Found in tactus2table.py and 1 other location - About 4 hrs to fix
          tactusCountCounselors.py on lines 103..112

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 78.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                              if numbers != None and len(numbers) > 0:
                                  number = cleanupText(numbers[0].text)
                              else:
                                  number = str(int(number)+1)
          Severity: Major
          Found in tactus2table.py and 1 other location - About 3 hrs to fix
          getQuestions.py on lines 40..43

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 62.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 4 locations. Consider refactoring.
          Open

          def cleanupText(text):
              text = re.sub(r"\s+"," ",text)
              text = re.sub(r"^ ","",text)
              text = re.sub(r" $","",text)
              return(text)
          Severity: Major
          Found in tactus2table.py and 3 other locations - About 1 hr to fix
          getDiaries.py on lines 26..30
          getQuestions.py on lines 19..23
          tactusCountCounselors.py on lines 51..55

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 48.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  if sender == CLIENT: clientMails.append([thisId,sender,recipient,date,subject,body])
                  else: counselorMails.append([thisId,sender,recipient,date,subject,body])
          Severity: Major
          Found in tactus2table.py and 1 other location - About 1 hr to fix
          tactusCountCounselors.py on lines 83..84

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 43.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 4 locations. Consider refactoring.
          Open

          def makeId(fileName):
              thisId = re.sub(r".*/","",fileName)
              thisId = re.sub(r"\.xml.*$","",thisId)
              return(thisId)
          Severity: Major
          Found in tactus2table.py and 3 other locations - About 45 mins to fix
          getDiaries.py on lines 32..35
          tactusCountCounselors.py on lines 57..60
          wordCount.py on lines 31..34

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 35.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status