CIMAC-CIDC/cidc-schemas

View on GitHub
cidc_schemas/prism/extra_metadata.py

Summary

Maintainability
C
1 day
Test Coverage
A
96%

Function parse_clinical has a Cognitive Complexity of 46 (exceeds 10 allowed). Consider refactoring.
Open

def parse_clinical(file: BinaryIO) -> dict:
    """
    Parses the given clinical file to extract a list of participant IDs.
    By convention the first column should be "cimac_part_id" for files containing
    clinical data keyed to a specific participant. All tabs in each XLSX need to be checked
Severity: Minor
Found in cidc_schemas/prism/extra_metadata.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 parse_npx has a Cognitive Complexity of 29 (exceeds 10 allowed). Consider refactoring.
Open

def parse_npx(xlsx: BinaryIO) -> dict:
    """
    Parses the given NPX file from olink to extract a list of sample IDs.
    If the file is not valid NPX but still xlsx the function will
    return a dict containing an empty list. Sample IDs not conforming to the CIMAC ID
Severity: Minor
Found in cidc_schemas/prism/extra_metadata.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

Avoid deeply nested control flow statements.
Open

                        if cell.value == "" or not cell.value:
                            continue

                        # get the identifier
                        # check that it is a CIMAC PART ID
Severity: Major
Found in cidc_schemas/prism/extra_metadata.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if cimac_partid_regex.match(str(cell.value)):
                                ids.add(cell.value)
    
    
    Severity: Major
    Found in cidc_schemas/prism/extra_metadata.py - About 45 mins to fix

      Function parse_elisa has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
      Open

      def parse_elisa(xlsx: BinaryIO) -> dict:
          """
          Parses the given ELISA grand serology results file to extract a list of sample IDs.
          If the file is not valid NPX but still xlsx the function will
          return a dict containing an empty list. Sample IDs not conforming to the CIMAC ID
      Severity: Minor
      Found in cidc_schemas/prism/extra_metadata.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

      There are no issues that match your filters.

      Category
      Status