sleepepi/sleepportal

View on GitHub
app/models/resolver.rb

Summary

Maintainability
C
1 day
Test Coverage

Method generate_sql_as_normal has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_sql_as_normal(thesource)
      result = "1 = 0"

      result_hash = thesource.sql_codes(current_user)
      sql_text = result_hash[:text]
Severity: Minor
Found in app/models/resolver.rb - About 6 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 generate_sql_as_normal has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def generate_sql_as_normal(thesource)
      result = "1 = 0"

      result_hash = thesource.sql_codes(current_user)
      sql_text = result_hash[:text]
Severity: Major
Found in app/models/resolver.rb - About 2 hrs to fix

    Method construct_conditions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def construct_conditions
          if criterium.mapping and criterium.mapping.source != source
            # This is get Age at SHHS2 against SHHS1 (linked search)
            # GENERATE LINKED SQL
            # 1) Get the Source Join between criterium.mapping.source and source
    Severity: Minor
    Found in app/models/resolver.rb - About 55 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

    Avoid deeply nested control flow statements.
    Open

                  if left_token.blank? and right_token.blank?
                    all_conditions << "#{numeric_string} BETWEEN #{range[0]} and #{range[1]}"
                  else
                    all_conditions << "#{numeric_string} #{left_token} #{range[0]} and #{numeric_string} #{right_token} #{range[1]}"
                  end
    Severity: Major
    Found in app/models/resolver.rb - About 45 mins to fix

      Consider simplifying this complex logical expression.
      Open

                elsif val == '1 = 0' or (range.size == 1 and range[0].blank?) or (range.size == 2 and range[0].blank? and range[1].blank?)
                  all_conditions << '1 = 0'
                elsif val == '1 = 1'
                  all_conditions << '1 = 1'
                elsif criterium.variable.variable_type == 'date'
      Severity: Major
      Found in app/models/resolver.rb - About 40 mins to fix

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

            def generate_sql_through_link(source_identifer_mapping, criterium_source_identifer_mapping)
              result_hash = criterium.mapping.source.sql_codes(current_user)
              sql_open = result_hash[:open]
              sql_close = result_hash[:close]
        
        
        Severity: Minor
        Found in app/models/resolver.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