projectcypress/health-data-standards

View on GitHub
lib/hqmf-parser/converter/pass2/comparison_converter.rb

Summary

Maintainability
C
1 day
Test Coverage

Method walk_up_tree has a Cognitive Complexity of 58 (exceeds 5 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: Minor
Found in lib/hqmf-parser/converter/pass2/comparison_converter.rb - About 1 day 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

    Avoid deeply nested control flow statements.
    Open

                      if operator.field.downcase == 'status'
                        # only set the status if we don't have one.  We trust the template ID statuses more than the restrictions
                        new_data_criteria.status ||= operator.value.code
                      elsif operator.field.downcase == 'result value' or operator.field.downcase == 'result'
                        puts "\tREFR result value is nil: #{new_data_criteria.title}" if (operator.value.nil?)
    Severity: Major
    Found in lib/hqmf-parser/converter/pass2/comparison_converter.rb - About 45 mins to fix

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

          def get_child_comparisons(node)
            values = []
            node.preconditions.each do |precondition|
              if (precondition.comparison?)
                values << precondition
      Severity: Minor
      Found in lib/hqmf-parser/converter/pass2/comparison_converter.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