af83/chouette-core

View on GitHub
app/lib/search/base.rb

Summary

Maintainability
D
2 days
Test Coverage

File base.rb has 664 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Search
  class Base
    extend ActiveModel::Naming
    extend Enumerize

Severity: Major
Found in app/lib/search/base.rb - About 1 day to fix

    Class Base has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Base
        extend ActiveModel::Naming
        extend Enumerize
    
        include ActiveModel::Validations
    Severity: Minor
    Found in app/lib/search/base.rb - About 3 hrs to fix

      Class Chart has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Chart
            class GroupByAttribute
              class << self
                private
      
      
      Severity: Minor
      Found in app/lib/search/base.rb - About 2 hrs to fix

        Method group_by_attribute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def group_by_attribute(name, type, **options, &block) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
                  sub_types = options.delete(:sub_types)
        
                  name_classify = name.classify
                  base_klass = const_get(:"#{type.to_s.classify}GroupByAttribute")
        Severity: Minor
        Found in app/lib/search/base.rb - About 1 hr to fix

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

              def search(scope)
                if valid?
                  result = query(scope).scope
                  result = order.order(result) unless without_order?
                  result = result.paginate(paginate_attributes) unless without_pagination?
          Severity: Minor
          Found in app/lib/search/base.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 group_by_attribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def group_by_attribute(name, type, **options, &block) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
                    sub_types = options.delete(:sub_types)
          
                    name_classify = name.classify
                    base_klass = const_get(:"#{type.to_s.classify}GroupByAttribute")
          Severity: Minor
          Found in app/lib/search/base.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 label_keys_with_sort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def label_keys_with_sort(data) # rubocop:disable Metrics/MethodLength
                  # The idea is to extract the nil key, label and sort the other keys and add the nil key afterwards.
                  # If first, we append nil key at the end (if present).
                  # If not first, we reverse the sorted keys and start with the nil key (if present).
          
          
          Severity: Minor
          Found in app/lib/search/base.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