MiraitSystems/enju_trunk

View on GitHub
app/controllers/form_input_utils.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method adhoc_text_field_query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def adhoc_text_field_query(qwords, model, fields, nest = true, op = :default)
    model_string_fields = {}
    Sunspot::Setup.for(model).fields.each do |sunspot_field|
      next unless sunspot_field.type.is_a?(Sunspot::Type::StringType)
      model_string_fields[sunspot_field.name] = sunspot_field.indexed_name
Severity: Minor
Found in app/controllers/form_input_utils.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 adhoc_text_field_query has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def adhoc_text_field_query(qwords, model, fields, nest = true, op = :default)
    model_string_fields = {}
    Sunspot::Setup.for(model).fields.each do |sunspot_field|
      next unless sunspot_field.type.is_a?(Sunspot::Type::StringType)
      model_string_fields[sunspot_field.name] = sunspot_field.indexed_name
Severity: Minor
Found in app/controllers/form_input_utils.rb - About 1 hr to fix

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

      def adhoc_text_field_query(qwords, model, fields, nest = true, op = :default)
    Severity: Minor
    Found in app/controllers/form_input_utils.rb - About 35 mins to fix

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

        def construct_time_range(date_from, date_to)
          d1, g1 = parse_date_string(date_from)
          d2, g2 = parse_date_string(date_to)
      
          d1, g1, d2, g2 = d2, g2, d1, g1 if d1 && d2 && d1 > d2
      Severity: Minor
      Found in app/controllers/form_input_utils.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

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

        def parse_date_string(date_str)
          return [nil, nil] if date_str.blank?
      
          begin
            time = Time.zone.parse(date_str)
      Severity: Minor
      Found in app/controllers/form_input_utils.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