projectcypress/health-data-standards

View on GitHub
lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method handle_stratifications has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_stratifications(population_def, number_of_populations, population, id_def, population_index)
      # handle stratifications (EP137, EP155)
      stratifier_criteria_xpath = "cda:component/cda:stratifierCriteria[not(cda:component/cda:measureAttribute/cda:code[@code  = 'SDE'])]/.."
      population_def.xpath(stratifier_criteria_xpath, HQMF2::Document::NAMESPACES)
        .each_with_index do |criteria_def, criteria_def_index|
Severity: Minor
Found in lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb - 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

Method extract_populations_and_criteria has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_populations_and_criteria
      has_observation = extract_observations
      document_populations = @doc.xpath('cda:QualityMeasureDocument/cda:component/cda:populationCriteriaSection',
                                        HQMF2::Document::NAMESPACES)
      # Sort the populations based on the id/extension, since the populations may be out of order; there doesn't seem to
Severity: Minor
Found in lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb - About 45 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

Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(entry, doc, document, id_generator, reference_ids = {})
Severity: Minor
Found in lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb - About 35 mins to fix

    Method handle_stratifications has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def handle_stratifications(population_def, number_of_populations, population, id_def, population_index)
    Severity: Minor
    Found in lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb - About 35 mins to fix

      Method extract_observations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def extract_observations
            has_observation = false
            # look for observation data in separate section but create a population for it if it exists
            observation_section = @doc.xpath('/cda:QualityMeasureDocument/cda:component/cda:measureObservationSection',
                                             HQMF2::Document::NAMESPACES)
      Severity: Minor
      Found in lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb - 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