concord-consortium/rigse

View on GitHub
rails/app/models/search.rb

Summary

Maintainability
D
2 days
Test Coverage

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

  def search
    self.results[:all] = []
    self.hits[:all] = []
    self.total_entries[:all] = 0

Severity: Minor
Found in rails/app/models/search.rb - About 4 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

File search.rb has 308 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Search
  attr_accessor :engine
  attr_accessor :results
  attr_accessor :hits
  attr_accessor :total_entries
Severity: Minor
Found in rails/app/models/search.rb - About 3 hrs to fix

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

    class Search
      attr_accessor :engine
      attr_accessor :results
      attr_accessor :hits
      attr_accessor :total_entries
    Severity: Minor
    Found in rails/app/models/search.rb - About 3 hrs to fix

      Method search has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def search
          self.results[:all] = []
          self.hits[:all] = []
          self.total_entries[:all] = 0
      
      
      Severity: Major
      Found in rails/app/models/search.rb - About 2 hrs to fix

        Method initialize has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(opts={})
        
            #
            # If this is not a subclass, use the default models.
            #
        Severity: Minor
        Found in rails/app/models/search.rb - About 1 hr to fix

          Method fetch_available_filter_options has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def fetch_available_filter_options
              results = self.engine.search(self.searchable_models) do |s|
                s.facet :subject_areas
                s.facet :sensors
                s.facet :grade_levels do
          Severity: Minor
          Found in rails/app/models/search.rb - About 1 hr to fix

            Method search_by_authorship has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def search_by_authorship(search)
                return if !include_official && !include_contributed
                search.any_of do |c|
                  # always show user's non-official work
                  c.all_of do |c2|
            Severity: Minor
            Found in rails/app/models/search.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

            There are no issues that match your filters.

            Category
            Status