plugins/solr/lib/solr_plugin.rb
Method scopes_to_solr_options
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
Open
def scopes_to_solr_options(scope, klass = nil, options = {})
filter_queries = []
klass ||= scope.base_class
solr_fields = klass.configuration[:solr_fields].keys
scopes_applied = scope.scopes_applied.dup rescue [] # rescue association and class direct filtering
- 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
Method scopes_to_solr_options
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def scopes_to_solr_options(scope, klass = nil, options = {})
filter_queries = []
klass ||= scope.base_class
solr_fields = klass.configuration[:solr_fields].keys
scopes_applied = scope.scopes_applied.dup rescue [] # rescue association and class direct filtering
Method find_by_contents
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def find_by_contents(asset, scope, query, paginate_options = {}, options = {})
klass = asset_class(asset)
category = options[:category]
empty_query = empty_query? query, category
- 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
Method find_by_contents
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def find_by_contents(asset, scope, query, paginate_options = {}, options = {})