projectcypress/health-data-standards

View on GitHub
lib/hqmf-model/data_criteria.rb

Summary

Maintainability
D
2 days
Test Coverage

File data_criteria.rb has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module HQMF
  # Represents a data criteria specification
  class DataCriteria

    include HQMF::Conversion::Utilities
Severity: Minor
Found in lib/hqmf-model/data_criteria.rb - About 4 hrs to fix

    Class DataCriteria has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class DataCriteria
    
        include HQMF::Conversion::Utilities
    
        SOURCE_DATA_CRITERIA_TEMPLATE_ID = '2.16.840.1.113883.3.100.1.1'
    Severity: Minor
    Found in lib/hqmf-model/data_criteria.rb - About 3 hrs to fix

      Method initialize has 22 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(id, title, display_name, description, code_list_id, children_criteria, derivation_operator, definition, status, value, field_values, effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators, specific_occurrence, specific_occurrence_const, source_data_criteria=nil, comments=nil, variable=false)
      Severity: Major
      Found in lib/hqmf-model/data_criteria.rb - About 2 hrs to fix

        Method from_json has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.from_json(id, json)
        
              title = json["title"] if json["title"]
              display_name = json["display_name"] if json["display_name"]
              description = json["description"] if json["description"]
        Severity: Minor
        Found in lib/hqmf-model/data_criteria.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 base_json has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def base_json
              x = nil
              json = build_hash(self, [:title,:display_name,:description,:code_list_id,:children_criteria, :derivation_operator, :property, :type, :definition, :status, :hard_status, :negation, :negation_code_list_id,:specific_occurrence,:specific_occurrence_const,:source_data_criteria,:variable])
              json[:children_criteria] = @children_criteria unless @children_criteria.nil? || @children_criteria.empty?
              json[:value] = ((@value.is_a? String) ? @value : @value.to_json) if @value
        Severity: Minor
        Found in lib/hqmf-model/data_criteria.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 statuses_by_definition has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.statuses_by_definition
              settings_file = File.expand_path('../data_criteria.json', __FILE__)
              settings_map = JSON.parse(File.read(settings_file))
              all_defs = (settings_map.map {|key, value| {category: value['category'],definition:value['definition'],status:(value['status'].empty? ? nil : value['status']), sub_category: value['sub_category'],title:value['title']} unless value['not_supported']}).compact
              by_categories = {}
        Severity: Minor
        Found in lib/hqmf-model/data_criteria.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 create_from_category has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def self.create_from_category(id, title, description, code_list_id, category, sub_category=nil, negation=false, negation_code_list_id=nil)
        Severity: Major
        Found in lib/hqmf-model/data_criteria.rb - About 1 hr to fix

          Method update_copy has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def update_copy(hard_status, title, description, derivation_operator, definition)
          Severity: Minor
          Found in lib/hqmf-model/data_criteria.rb - About 35 mins to fix

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

                def all_code_set_oids
            
                  # root oid
                  referenced_oids = [code_list_id]
            
            
            Severity: Minor
            Found in lib/hqmf-model/data_criteria.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

            There are no issues that match your filters.

            Category
            Status