rails/app/models/search.rb
Method search
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
Open
def search
self.results[:all] = []
self.hits[:all] = []
self.total_entries[:all] = 0
- Read upRead up
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
Open
class Search
attr_accessor :engine
attr_accessor :results
attr_accessor :hits
attr_accessor :total_entries
Class Search
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Search
attr_accessor :engine
attr_accessor :results
attr_accessor :hits
attr_accessor :total_entries
Method search
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def search
self.results[:all] = []
self.hits[:all] = []
self.total_entries[:all] = 0
Method initialize
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize(opts={})
#
# If this is not a subclass, use the default models.
#
Method fetch_available_filter_options
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Method search_by_authorship
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
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|
- Read upRead up
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"