projectcypress/health-data-standards

View on GitHub

Showing 318 of 318 total issues

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

    def handle_type(id_generator)
      if @type != 'AGGREGATE'
        # Generate the precondition for this population
        if @preconditions.length > 1 ||
           (@preconditions.length == 1 && @preconditions[0].conjunction != conjunction_code)
Severity: Minor
Found in lib/hqmf-parser/2.0/population_criteria.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

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

    def handle_mapping_template(mapping)
      if mapping
        if mapping[:valueset_path] && @entry.at_xpath(mapping[:valueset_path])
          @code_list_xpath = mapping[:valueset_path]
        end
Severity: Minor
Found in lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.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

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

  def shift_dates(date_diff)
    self.start_time = self.start_time.nil? ? nil : self.start_time + date_diff
    self.end_time = self.end_time.nil? ? nil : self.end_time + date_diff
    self.time = self.time.nil? ? nil : self.time + date_diff
    self.guarantors.each do |g|
Severity: Minor
Found in lib/health-data-standards/models/insurance_provider.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

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

    def to_json
      x = nil
      json = {}
      json[:id] = self.id
      json[:reference] = self.reference.id if self.reference
Severity: Minor
Found in lib/hqmf-model/precondition.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

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

        def get_demographics(patient, doc)
          effective_date = doc.at_xpath('/cda:ClinicalDocument/cda:effectiveTime')['value']
          patient.effective_time = HL7Helper.timestamp_to_integer(effective_date)
          patient_role_element = doc.at_xpath('/cda:ClinicalDocument/cda:recordTarget/cda:patientRole')
          patient_element = patient_role_element.at_xpath('./cda:patient')
Severity: Minor
Found in lib/health-data-standards/import/c32/patient_importer.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

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

  def shift_dates(date_diff)
    self.start_time = self.start_time.nil? ? nil : (self.start_time + date_diff)
    self.end_time = self.end_time.nil? ? nil : (self.end_time + date_diff)
    self.time = self.time.nil? ? nil : (self.time + date_diff)
  end
Severity: Minor
Found in lib/health-data-standards/models/entry.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

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

    def calculate_performance_rates(reported_result)
      #Just in case a measure does not report these populations
      denex = 0
      denexcep = 0
      denom = 0
Severity: Minor
Found in lib/health-data-standards/validate/performance_rate_validator.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

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

        def extract_value(parent_element, value_element, entry)
          if value_element && !value_element['nullFlavor']
            value = value_element['value']
            if value.present?
              unit = value_element['unit']
Severity: Minor
Found in lib/health-data-standards/import/cda/section_importer.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

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

    def extract_cv_value(node, id, msrpopl, strata = nil)
        xpath_observation = %{ cda:component/cda:observation[./cda:value[@code = "MSRPOPL"] and ./cda:reference/cda:externalObservation/cda:id[#{translate("@root")}='#{msrpopl.upcase}']]}
        cv = node.at_xpath(xpath_observation)
        return nil unless cv
        val = nil
Severity: Minor
Found in lib/health-data-standards/validate/reported_result_extractor.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

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

    def self.from_json(json)
      preconditions = []
      id = json["id"] if json["id"]
      preconditions = json["preconditions"].map {|precondition| HQMF::Precondition.from_json(precondition)} if json["preconditions"]
      reference = Reference.new(json["reference"]) if json["reference"] 
Severity: Minor
Found in lib/hqmf-model/precondition.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

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

      def json_array(elements) 
        return nil if elements.nil?
        array = []
        elements.each do |element| 
          if (element.is_a? OpenStruct)
Severity: Minor
Found in lib/hqmf-model/utilities.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

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

    def check_performance_rates(reported_result, population_ids, measure_id, data = {})
      expected = calculate_performance_rates(reported_result)
      _ids = population_ids
      if expected == "NA"
        if reported_result['PR']['nullFlavor'] != "NA"
Severity: Minor
Found in lib/health-data-standards/validate/performance_rate_validator.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

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

        def create_entries(doc, nrh = NarrativeReferenceHandler.new)
          entry_list = []
          entry_elements = @entry_finder.entries(doc)
          entry_elements.each do |entry_element|
            entry = create_entry(entry_element, nrh)
Severity: Minor
Found in lib/health-data-standards/import/cda/section_importer.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                if (entry.transferFrom)
                  entry.transferFrom.codes[entry.transferFrom.code_system] = [entry.transferFrom.code]
                  tfc = entry.transferFrom.codes_in_code_set(codes).values.first
                  tfc && !tfc.empty?
                end
Severity: Minor
Found in lib/health-data-standards/export/helper/scooped_view_helper.rb and 1 other location - About 20 mins to fix
lib/health-data-standards/export/helper/scooped_view_helper.rb on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def setup
      path = File.expand_path("../../../../fixtures/1.0/precondition_nesting.xml", __FILE__)
      doc = Nokogiri::XML(File.open(path).read)
      doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
      @precondition = HQMF1::Precondition.new(doc.root(), nil, nil)
Severity: Minor
Found in test/unit/hqmf/1.0/nesting_test.rb and 1 other location - About 20 mins to fix
test/unit/hqmf/1.0/inter_restrictions_test.rb on lines 6..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                if (entry.transferTo)
                  entry.transferTo.codes[entry.transferTo.code_system] = [entry.transferTo.code]
                  ttc = entry.transferTo.codes_in_code_set(codes).values.first
                  ttc && !ttc.empty?
                end
Severity: Minor
Found in lib/health-data-standards/export/helper/scooped_view_helper.rb and 1 other location - About 20 mins to fix
lib/health-data-standards/export/helper/scooped_view_helper.rb on lines 158..162

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def setup
      path = File.expand_path("../../../../fixtures/1.0/inter_comparison_restrictions.xml", __FILE__)
      doc = Nokogiri::XML(File.open(path).read)
      doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
      @precondition = HQMF1::Precondition.new(doc.root(), nil, nil)
Severity: Minor
Found in test/unit/hqmf/1.0/inter_restrictions_test.rb and 1 other location - About 20 mins to fix
test/unit/hqmf/1.0/nesting_test.rb on lines 5..9

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 27.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_comm_patient_to_prov
    patient = build_record_from_xml('test/fixtures/cat1_fragments/comm_patient_to_provider_fragment.xml')
    communication = patient.communications.first
    expected_start = HealthDataStandards::Util::HL7Helper.timestamp_to_integer('20101027165345')
    assert communication.codes['SNOMED-CT'].include?('315640000')
Severity: Minor
Found in test/unit/import/cat1/patient_importer_test.rb and 6 other locations - About 15 mins to fix
test/unit/import/cat1/patient_importer_test.rb on lines 66..71
test/unit/import/cat1/patient_importer_test.rb on lines 82..87
test/unit/import/cat1/patient_importer_test.rb on lines 120..125
test/unit/import/cat1/patient_importer_test.rb on lines 138..143
test/unit/import/cat1/patient_importer_test.rb on lines 146..151
test/unit/import/cat1/patient_importer_test.rb on lines 154..159

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

    def test_medication_adverse
    patient = build_record_from_xml('test/fixtures/cat1_fragments/medication_adverse_fragment.xml')
    med_adverse = patient.allergies.first
    expected_start = HealthDataStandards::Util::HL7Helper.timestamp_to_integer('20070520173120')
    assert med_adverse.codes['RxNorm'].include?('998695')
Severity: Minor
Found in test/unit/import/cat1/patient_importer_test.rb and 6 other locations - About 15 mins to fix
test/unit/import/cat1/patient_importer_test.rb on lines 66..71
test/unit/import/cat1/patient_importer_test.rb on lines 74..79
test/unit/import/cat1/patient_importer_test.rb on lines 82..87
test/unit/import/cat1/patient_importer_test.rb on lines 120..125
test/unit/import/cat1/patient_importer_test.rb on lines 138..143
test/unit/import/cat1/patient_importer_test.rb on lines 146..151

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 7 locations. Consider refactoring.
Open

  def test_medication_allergy
    patient = build_record_from_xml('test/fixtures/cat1_fragments/medication_allergy_fragment.xml')
    med_allergy = patient.allergies.first
    expected_start = HealthDataStandards::Util::HL7Helper.timestamp_to_integer('19790809140056')
    assert med_allergy.codes['RxNorm'].include?('996994')
Severity: Minor
Found in test/unit/import/cat1/patient_importer_test.rb and 6 other locations - About 15 mins to fix
test/unit/import/cat1/patient_importer_test.rb on lines 66..71
test/unit/import/cat1/patient_importer_test.rb on lines 74..79
test/unit/import/cat1/patient_importer_test.rb on lines 82..87
test/unit/import/cat1/patient_importer_test.rb on lines 120..125
test/unit/import/cat1/patient_importer_test.rb on lines 138..143
test/unit/import/cat1/patient_importer_test.rb on lines 154..159

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language