projectcypress/health-data-standards

View on GitHub
test/unit/hqmf/2.0/hqmf_vs_simple_test.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

      def reject_unnecessary_population_criteria(simple_xml_model, hqmf_populations)
        # More restrictive (only checks DENEXCEP) removal of populations in simple_xml
        # obtain all denexceps and denex (and only run if they exist)
        unnecessary_pop_crit = simple_xml_model.instance_variable_get(:@population_criteria).select { |pc| pc.type =~ /(DENEX|MSRPOPLEX)/ }
        unnecessary_pop_crit.each do |pc|
    Severity: Minor
    Found in test/unit/hqmf/2.0/hqmf_vs_simple_test.rb - About 55 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 print_to_file has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def print_to_file(measure_name, hqmf_model, simple_xml_model, hqmf_json_orig, simple_xml_json_orig)
    Severity: Minor
    Found in test/unit/hqmf/2.0/hqmf_vs_simple_test.rb - About 35 mins to fix

      Method remap_preconditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def remap_preconditions(criteria_map, preconditions)
          return if preconditions.nil?
          preconditions.each do |precondition|
            remap_preconditions(criteria_map, precondition.preconditions)
            next if precondition.reference.nil?
      Severity: Minor
      Found in test/unit/hqmf/2.0/hqmf_vs_simple_test.rb - About 35 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 hash_criteria has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.hash_criteria(criteria, criteria_map)
          return criteria.id unless criteria_map[criteria.id]
      
          # generate a SHA256 hash of key fields in the data criteria
          # sha256 = Digest::SHA256.new
      Severity: Minor
      Found in test/unit/hqmf/2.0/hqmf_vs_simple_test.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