e-mental-health/data-processing

View on GitHub

Showing 166 of 166 total issues

Function main has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

def main(argv):
    inFileName = argv.pop(1)
    inFile = gzip.open(inFileName,"rb")
    inFileContent = inFile.read()
    inFile.close()
Severity: Minor
Found in getQuestions.py - About 1 day 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 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
Severity: Minor
Found in egofy.py - About 7 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

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

            if countMails(emailsIn[currentStart:e-1],CLIENT) >= 2*SETSIZE:
                lastMails = combineData(emailsIn,CLIENT,currentStart,e-1,SETSIZE,getLast=True)
                emailsOut.extend([firstMails, lastMails])
            elif countMails(emailsIn[currentStart:e-1],CLIENT) > 0:
                emailsOut.extend([firstMails])
Severity: Major
Found in ovk2liwc.py and 1 other location - About 7 hrs to fix
ovk2liwc.py on lines 90..94

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 111.

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 countMails(emailsIn[currentStart:e-1],COUNSELOR) >= 2*SETSIZE:
                lastMails = combineData(emailsIn,COUNSELOR,currentStart,e-1,SETSIZE,getLast=True)
                emailsOut.extend([firstMails, lastMails])
            elif countMails(emailsIn[currentStart:e-1],COUNSELOR) > 0:
                emailsOut.extend([firstMails])
Severity: Major
Found in ovk2liwc.py and 1 other location - About 7 hrs to fix
ovk2liwc.py on lines 84..88

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 111.

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

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

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
Severity: Minor
Found in tactusVisualize.py - About 5 hrs to fix

    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]+" "
    Severity: Critical
    Found in egofy.py - About 5 hrs to fix

      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 ]
      Severity: Minor
      Found in tactusVisualize.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

      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 tactusCountCounselors.py and 1 other location - About 4 hrs to fix
      tactus2table.py on lines 289..298

      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

      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 not fields[-1] in ENTITYLABELS: fields[-1] = "O"
          elif UNLOPTION in options: fields[-1] = UNLABELED
          else: fields[-1] = "B-"+fields[-1]
      Severity: Major
      Found in prepare-eval.py and 1 other location - About 4 hrs to fix
      prepare-eval.py on lines 25..27

      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 77.

      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 not fields[0] in ENTITYLABELS: fields[0] = "O"
          elif UNLOPTION in options: fields[0] = UNLABELED
          else: fields[0] = "B-"+fields[0]
      Severity: Major
      Found in prepare-eval.py and 1 other location - About 4 hrs to fix
      prepare-eval.py on lines 28..30

      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 77.

      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

      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

      Function processFile has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      def processFile(client,counselor,lines,options):
          date = ""
          mailText = ""
          nbrOfProcessed = 0
          receiver = ""
      Severity: Minor
      Found in ovkPrepare.py - About 3 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 anonymize has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def anonymize(tokens,pos,ner,options):
          global names
      
          if not isEmailHead(tokens):
              for i in range(0,len(tokens)):
      Severity: Minor
      Found in anonymize-ovk.py - About 3 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 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:
      Severity: Minor
      Found in tactusVisualize.py - About 3 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 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

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

        #!/usr/bin/python3
        """
            tactus2liwc-en.py: convert xml files from tactus to liwc scores per mail csv
            usage: tactus2liwc-en.py file1.xml [file2.xml ...] > file1.csv
            note: based on tactus2table.py and text2liwc.py
        Severity: Minor
        Found in tactus2liwc-en.py - About 3 hrs to fix

          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:
          Severity: Minor
          Found in tactusVisualize.py - About 3 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 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: 
          Severity: Minor
          Found in tactusVisualize.py - About 3 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

          Severity
          Category
          Status
          Source
          Language