projectcypress/health-data-standards

View on GitHub
lib/hqmf-parser/2.0/document.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

        def handle_data_criteria(criteria, collapsed_source_data_criteria)
          # Sometimes there are multiple criteria with the same ID, even though they're different; in the HQMF
          # criteria refer to parent criteria via outboundRelationship, using an extension (aka ID) and a root;
          # we use just the extension to follow the reference, and build the lookup hash using that; since they
          # can repeat, we wind up overwriting some content. This becomes important when we want, for example,
    Severity: Minor
    Found in lib/hqmf-parser/2.0/document.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 read_attribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_attribute(attribute)
          id = attribute.at_xpath('./cda:id/@root', NAMESPACES).try(:value)
          code = attribute.at_xpath('./cda:code/@code', NAMESPACES).try(:value)
          name = attribute.at_xpath('./cda:code/cda:displayName/@value', NAMESPACES).try(:value)
          value = attribute.at_xpath('./cda:value/@value', NAMESPACES).try(:value)
    Severity: Minor
    Found in lib/hqmf-parser/2.0/document.rb - About 45 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_specific_source_data_criteria_reference has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_specific_source_data_criteria_reference(criteria)
          original_sdc = find(@source_data_criteria, :id, criteria.source_data_criteria)
          updated_sdc = find(@source_data_criteria, :id, criteria.id)
          if !updated_sdc.nil? && !criteria.specific_occurrence.nil? && (original_sdc.nil? || original_sdc.specific_occurrence.nil?)
            criteria.instance_variable_set(:@source_data_criteria, criteria.id)
    Severity: Minor
    Found in lib/hqmf-parser/2.0/document.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_attribute_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_attribute_value(attribute, value)
          type = attribute.at_xpath('./cda:value/@xsi:type', NAMESPACES).try(:value)
          case type
          when 'II'
            if value.nil?
    Severity: Minor
    Found in lib/hqmf-parser/2.0/document.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