projectcypress/health-data-standards

View on GitHub
lib/hqmf-parser/1.0/restriction.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

        def value
          value = nil
          type = attr_val('./cda:observation/cda:value/@xsi:type') || 'CD'
          case type
          when 'IVL_PQ'
    Severity: Minor
    Found in lib/hqmf-parser/1.0/restriction.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(entry, parent, doc)
          @doc = doc
          @entry = entry
          @restrictions = []
          
    Severity: Minor
    Found in lib/hqmf-parser/1.0/restriction.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 value has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def value
          value = nil
          type = attr_val('./cda:observation/cda:value/@xsi:type') || 'CD'
          case type
          when 'IVL_PQ'
    Severity: Minor
    Found in lib/hqmf-parser/1.0/restriction.rb - About 1 hr to fix

      Method to_json has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_json 
            return nil if from_parent
            json = build_hash(self, [:subset,:type,:target_id,:field,:field_code,:from_parent, :negation, :field_time])
            json[:range] = range.to_json if range
            if value
      Severity: Minor
      Found in lib/hqmf-parser/1.0/restriction.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 field_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def field_time
            effectiveTime = @entry.at_xpath('./cda:observation/cda:effectiveTime') || @entry.at_xpath('./cda:encounter/cda:participant/cda:roleParticipant/cda:effectiveTime')
            
            time = nil
            if effectiveTime
      Severity: Minor
      Found in lib/hqmf-parser/1.0/restriction.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