e-mental-health/data-processing

View on GitHub

Showing 133 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

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

      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

          Function anonymize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          def anonymize(tokens,pos,ner,interactive):
              global positiveNames,negativeNames
          
              if len(tokens) > 1 and tokens[0] in SKIP and tokens[1] == ":":
                  return(" ".join(tokens))
          Severity: Minor
          Found in anonymize.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 computeStats has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          def computeStats(data):
              stats = { CLIENT:{AVERAGE:0.0,COUNT:0,MAX:-1.0,MIN:1.0,SD:0.0,TOTAL:0.0,TOTALDEV:0.0},
                     COUNSELOR:{AVERAGE:0.0,COUNT:0,MAX:-1.0,MIN:1.0,SD:0.0,TOTAL:0.0,TOTALDEV:0.0} }
              for d in data:
                  if SENDER in d and d[SENDER] in stats:
          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 compressNE has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          def compressNE(tokens):
              i = 0
              while i >= 0 and i < len(tokens):
                  removedTokens = 0
                  if tokens[i] in NETAGS:
          Severity: Minor
          Found in anonymize-ovk.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 printResults has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          def printResults(annotatedText):
              paragraphs = annotatedText.split("\n")
              for par in paragraphs:
                  par = addMissingSpaces(par)
                  tokens = par.split(" ")
          Severity: Minor
          Found in deduce-test.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

          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: 
          Severity: Minor
          Found in egofy.py - About 2 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-en.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

            Severity
            Category
            Status
            Source
            Language