projectcypress/health-data-standards

View on GitHub

Showing 318 of 318 total issues

Method import_archive has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def self.import_archive(file, failed_dir=nil)
        begin
        failed_dir ||=File.join(File.dirname(file))

        patient_id_list = nil
Severity: Minor
Found in lib/health-data-standards/import/bulk_record_importer.rb - About 2 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

Class Document has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Document
    include HQMF2::Utilities, HQMF2::DocumentUtilities
    NAMESPACES = { 'cda' => 'urn:hl7-org:v3',
                   'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
                   'qdm' => 'urn:hhs-qdm:hqmf-r2-extensions:v1' }
Severity: Minor
Found in lib/hqmf-parser/2.0/document.rb - About 2 hrs to fix

    Method initialize has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def initialize
              # This differs from other HDS patient importers in that sections can have multiple importers
              @section_importers = {}
              @section_importers[:care_goals] = [generate_importer(CDA::SectionImporter, "./cda:entry/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.1']", '2.16.840.1.113883.3.560.1.9')] #care goal
              
    Severity: Major
    Found in lib/health-data-standards/import/cat1/patient_importer.rb - About 2 hrs to fix

      Method base_json has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def base_json
            x = nil
            json = build_hash(self, [:title,:display_name,:description,:code_list_id,:children_criteria, :derivation_operator, :property, :type, :definition, :status, :hard_status, :negation, :negation_code_list_id,:specific_occurrence,:specific_occurrence_const,:source_data_criteria,:variable])
            json[:children_criteria] = @children_criteria unless @children_criteria.nil? || @children_criteria.empty?
            json[:value] = ((@value.is_a? String) ? @value : @value.to_json) if @value
      Severity: Minor
      Found in lib/hqmf-model/data_criteria.rb - About 2 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 preferred_code has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def preferred_code(preferred_code_sets, codes_attribute=:codes, value_set_map=nil)
          codes_value = send(codes_attribute)
          preferred_code_sets = value_set_map ? (preferred_code_sets & value_set_map.collect{|cs| cs["set"]}) : preferred_code_sets
          matching_code_sets = preferred_code_sets & codes_value.keys 
          if matching_code_sets.present?
      Severity: Minor
      Found in lib/health-data-standards/models/thing_with_codes.rb - About 2 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 walk_up_tree has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def walk_up_tree(preconditions)
            preconditions.each do |precondition|
              if (has_child_comparison(precondition))
                walk_up_tree(precondition.preconditions)
              end
      Severity: Major
      Found in lib/hqmf-parser/converter/pass2/comparison_converter.rb - About 2 hrs to fix

        File hqmf_vs_simple_test.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'fileutils'
        require 'digest'
        require 'simplexml_parser'
        require_relative '../../../test_helper'
        
        
        Severity: Minor
        Found in test/unit/hqmf/2.0/hqmf_vs_simple_test.rb - About 2 hrs to fix

          Method initialize has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(entry, parent, doc)
                @doc = doc
                @entry = entry
                @restrictions = []
                
          Severity: Major
          Found in lib/hqmf-parser/1.0/restriction.rb - About 2 hrs to fix

            Method remap_arbitrary_dc_v2_diff has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def remap_arbitrary_dc_v2_diff(model)
                (model.all_data_criteria + model.source_data_criteria).each do |dc|
                  # title and description for all are technically arbitrary values
                  dc.instance_variable_set(:@title, '')
                  dc.instance_variable_set(:@description, '')
            Severity: Minor
            Found in test/unit/hqmf/2.0/hqmf_vs_simple_test.rb - About 2 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 handle_specific_and_source has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root,
                                               specific_occurrence_const, specific_occurrence)
                  source_data_criteria = "#{source_data_criteria_extension}_#{source_data_criteria_root}_source"
                  if !occurrence_identifier.blank?
                    # if it doesn't exist, add extracted occurrence to the map

            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 a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(entry, occurrence_counters)
                  @entry = entry
                  
                  template_map = HQMF::DataCriteria.get_template_id_map()
                  oid_xpath_file = File.expand_path('../data_criteria_oid_xpath.json', __FILE__)
            Severity: Minor
            Found in lib/hqmf-parser/1.0/data_criteria.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 statuses_by_definition has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.statuses_by_definition
                  settings_file = File.expand_path('../data_criteria.json', __FILE__)
                  settings_map = JSON.parse(File.read(settings_file))
                  all_defs = (settings_map.map {|key, value| {category: value['category'],definition:value['definition'],status:(value['status'].empty? ? nil : value['status']), sub_category: value['sub_category'],title:value['title']} unless value['not_supported']}).compact
                  by_categories = {}
            Severity: Minor
            Found in lib/hqmf-model/data_criteria.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

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

              def test_medication_dispensed_act_importing
                doc = Nokogiri::XML(File.new('test/fixtures/cat1_fragments/medication_dispensed_act_fragment.xml'))
                doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
                nrh = HealthDataStandards::Import::CDA::NarrativeReferenceHandler.new
                nrh.build_id_map(doc)
            Severity: Major
            Found in test/unit/import/cat1/medication_dispensed_test.rb and 1 other location - About 1 hr to fix
            test/unit/import/cat1/medication_dispensed_test.rb on lines 4..16

            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 72.

            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 test_medication_dispensed_importing
                doc = Nokogiri::XML(File.new('test/fixtures/cat1_fragments/medication_dispensed_fragment.xml'))
                doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
                nrh = HealthDataStandards::Import::CDA::NarrativeReferenceHandler.new
                nrh.build_id_map(doc)
            Severity: Major
            Found in test/unit/import/cat1/medication_dispensed_test.rb and 1 other location - About 1 hr to fix
            test/unit/import/cat1/medication_dispensed_test.rb on lines 19..31

            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 72.

            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

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

                def self.merge_precondtion_conjunction_groups(preconditions_by_conjunction)
                  joined = []
                  preconditions_by_conjunction.each do |conjunction_code, preconditions|
                    sub_conditions = []
                    negated_conditions = []
            Severity: Minor
            Found in lib/hqmf-parser/converter/pass1/precondition_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

            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

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

                def self.from_json(json)
                  json = json.with_indifferent_access
            
                  id = json["id"] if json["id"]
                  code = json["code"] if json["code"]
            Severity: Minor
            Found in lib/hqmf-model/attribute.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

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

                def test_transfer_from_importing
                  doc = Nokogiri::XML(File.new('test/fixtures/cat1_fragments/transfer_from_fragment.xml'))
                  doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
                  nrh = HealthDataStandards::Import::CDA::NarrativeReferenceHandler.new
                  nrh.build_id_map(doc)
              Severity: Major
              Found in test/unit/import/cat1/transfer_to_from_importer_test.rb and 1 other location - About 1 hr to fix
              test/unit/import/cat1/transfer_to_from_importer_test.rb on lines 4..15

              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 67.

              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 test_transfer_to_importing
                  doc = Nokogiri::XML(File.new('test/fixtures/cat1_fragments/transfer_to_fragment.xml'))
                  doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
                  nrh = HealthDataStandards::Import::CDA::NarrativeReferenceHandler.new
                  nrh.build_id_map(doc)
              Severity: Major
              Found in test/unit/import/cat1/transfer_to_from_importer_test.rb and 1 other location - About 1 hr to fix
              test/unit/import/cat1/transfer_to_from_importer_test.rb on lines 31..42

              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 67.

              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