projectcypress/health-data-standards

View on GitHub
lib/hqmf-parser/converter/pass1/precondition_extractor.rb

Summary

Maintainability
C
1 day
Test Coverage

Method extract_preconditions_from_restriction has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    def self.extract_preconditions_from_restriction(restriction,data_criteria_converter)
      target_id=nil
      if restriction[:target_id] and data_criteria_converter.v1_data_criteria_by_id[restriction[:target_id]]
        target_id = data_criteria_converter.v1_data_criteria_by_id[restriction[:target_id]].id
      elsif restriction[:target_id]
Severity: Minor
Found in lib/hqmf-parser/converter/pass1/precondition_extractor.rb - About 5 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 extract_preconditions_from_restriction has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.extract_preconditions_from_restriction(restriction,data_criteria_converter)
      target_id=nil
      if restriction[:target_id] and data_criteria_converter.v1_data_criteria_by_id[restriction[:target_id]]
        target_id = data_criteria_converter.v1_data_criteria_by_id[restriction[:target_id]].id
      elsif restriction[:target_id]
Severity: Major
Found in lib/hqmf-parser/converter/pass1/precondition_extractor.rb - About 3 hrs to fix

    Method flatten_v2_preconditions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.flatten_v2_preconditions(preconditions)
          flattened = []
          preconditions.each do |precondition|
            if (precondition.reference and precondition.has_preconditions?)
              raise "don't know how to handle a condition with a reference that has preconditions" if (precondition.reference and precondition.has_preconditions?)
    Severity: Minor
    Found in lib/hqmf-parser/converter/pass1/precondition_extractor.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

    There are no issues that match your filters.

    Category
    Status