projectcypress/health-data-standards

View on GitHub
lib/hqmf-parser/converter/pass1/population_criteria_converter.rb

Summary

Maintainability
D
1 day
Test Coverage

Method build_sub_measures has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    def build_sub_measures()
      @sub_measures = []
      ipps = @population_criteria_by_id.select {|key, value| value.type == HQMF::PopulationCriteria::IPP}
      denoms = @population_criteria_by_id.select {|key, value| value.type == HQMF::PopulationCriteria::DENOM}
      nums = @population_criteria_by_id.select {|key, value| value.type == HQMF::PopulationCriteria::NUMER}
Severity: Minor
Found in lib/hqmf-parser/converter/pass1/population_criteria_converter.rb - 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

Method build_sub_measures has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build_sub_measures()
      @sub_measures = []
      ipps = @population_criteria_by_id.select {|key, value| value.type == HQMF::PopulationCriteria::IPP}
      denoms = @population_criteria_by_id.select {|key, value| value.type == HQMF::PopulationCriteria::DENOM}
      nums = @population_criteria_by_id.select {|key, value| value.type == HQMF::PopulationCriteria::NUMER}
Severity: Major
Found in lib/hqmf-parser/converter/pass1/population_criteria_converter.rb - About 2 hrs to fix

    Method apply_to_submeasures has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def apply_to_submeasures(subs, type, values, unpaired_type=nil, unpaired_keys=[])
          new_subs = []
          subs.each do |sub|
            # this unless prevents us from forcing an exclusion or excepion onto a measure that has a submeasure without
            # an exclusion or exception, but other populations with an exclusion or excepion.
    Severity: Minor
    Found in lib/hqmf-parser/converter/pass1/population_criteria_converter.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

    Consider simplifying this complex logical expression.
    Open

          if (ipps.size<=1 and denoms.size<=1 and nums.size<=1 and numexs.size<=1 and excls.size<=1 and denexcs.size<=1 and msrpopls.size<=1 and msrpoplexs.size<=1 and observs.size<=1)
            sub_measure = {}
    
            sub_measure[HQMF::PopulationCriteria::IPP] = HQMF::PopulationCriteria::IPP if ipps.size > 0
            sub_measure[HQMF::PopulationCriteria::DENOM] = HQMF::PopulationCriteria::DENOM if denoms.size > 0
    Severity: Critical
    Found in lib/hqmf-parser/converter/pass1/population_criteria_converter.rb - About 1 hr to fix

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

          def apply_to_submeasures(subs, type, values, unpaired_type=nil, unpaired_keys=[])
      Severity: Minor
      Found in lib/hqmf-parser/converter/pass1/population_criteria_converter.rb - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status