projectcypress/health-data-standards

View on GitHub
lib/hqmf-model/document.rb

Summary

Maintainability
C
1 day
Test Coverage

Method backfill_patient_characteristics_with_codes has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    def backfill_patient_characteristics_with_codes(codes)
      
      [].concat(self.all_data_criteria).concat(self.source_data_criteria).each do |data_criteria|
        if (data_criteria.type == :characteristic and !data_criteria.property.nil?)
          if (codes)
Severity: Minor
Found in lib/hqmf-model/document.rb - 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

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

    def initialize(id, hqmf_id, hqmf_set_id, hqmf_version_number, cms_id, title, description, population_criteria, data_criteria, source_data_criteria, attributes, measure_period, populations=nil)
Severity: Major
Found in lib/hqmf-model/document.rb - About 1 hr to fix

    Method backfill_patient_characteristics_with_codes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def backfill_patient_characteristics_with_codes(codes)
          
          [].concat(self.all_data_criteria).concat(self.source_data_criteria).each do |data_criteria|
            if (data_criteria.type == :characteristic and !data_criteria.property.nil?)
              if (codes)
    Severity: Minor
    Found in lib/hqmf-model/document.rb - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                    if (value_set['LOINC'] and value_set['LOINC'].first == '21112-8')
                      data_criteria.definition = 'patient_characteristic_birthdate'
                    end
      Severity: Major
      Found in lib/hqmf-model/document.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (gender_key and ['M','F'].include? value_set[gender_key].first)
                        data_criteria.definition = 'patient_characteristic_gender'
                        data_criteria.value = HQMF::Coded.new('CD','Gender',value_set[gender_key].first)
                      end
        Severity: Major
        Found in lib/hqmf-model/document.rb - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status