e-mental-health/data-processing

View on GitHub
anonymize-ovk.py

Summary

Maintainability
C
1 day
Test Coverage

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

Consider simplifying this complex logical expression.
Open

            if tokens[i] in [MONTH,DATE,DAY]:
                if i < len(tokens)-1 and tokens[i+1] in [NUM,MONTH,DATE,DAY]: 
                    removeFromList(tokens,i+1)
                    removedTokens += 1
                tokens[i] = DATE
Severity: Critical
Found in anonymize-ovk.py - About 1 hr to fix

    Function readSentence has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def readSentence():
        tokens,pos,ner = [[],[],[]]
        for line in sys.stdin:
            try:
                line = line.rstrip()
    Severity: Minor
    Found in anonymize-ovk.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

    Consider simplifying this complex logical expression.
    Open

                if tokens[i] in names.keys():
                    if names[tokens[i]] != NEOTHER: 
                        tokens[i] = names[tokens[i]]
                elif pos[i] == TAGNUM or re.search(r"^\d",tokens[i]) or re.search(r"^-\d",tokens[i]): 
                    tokens[i] = NUM
    Severity: Major
    Found in anonymize-ovk.py - About 40 mins to fix

      Function processOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def processOptions(argv):
          try:
              optionList, files = getopt.getopt(argv,"ln",[])
              options = {}
              for option, arg in optionList:
      Severity: Minor
      Found in anonymize-ovk.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