Class PgSearchPlugin
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class PgSearchPlugin < Noosfero::Plugin
include SearchHelper
def self.plugin_name
"Postgres Full-Text Search"
Method filter_by_facets
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def filter_by_facets(scope, facets)
queries = []
facets.each do |term, values|
kind, klass = term.split("-")
if kind == "attribute" || kind == "relation" || kind == "metadata"
- 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 pg_search_plugin.rb
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "noosfero/friendly_mime"
class PgSearchPlugin < Noosfero::Plugin
include SearchHelper
Method active_filters
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def active_filters(asset, scope, params, query = nil)
facets = params[:facets] || {}
periods = (params[:periods] || default_periods_for(asset)).to_h
query ||= params[:query] || params[:q]
block = Block.find_by id: params[:block]
- 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 filter_by_periods
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def filter_by_periods(scope, periods)
periods.each do |attribute, period|
next if period.blank?
if !period["is_metadata"].blank? && period["is_metadata"] == "true"
- 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 profile_search_block_extra_content
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def profile_search_block_extra_content(block, params)
if block.advanced_search
if params[:controller] == "profile_search"
# Load facets and periods
load_facets = true
- 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 generic_facet
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def generic_facet(klass, scope, selected_facets, kind, params = {})
no_results = false
results = self.send("#{kind}_results", klass, scope, params)
if results.blank?
no_results = true
- 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 generic_facet
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def generic_facet(klass, scope, selected_facets, kind, params = {})
Method register_search_facet_occurrence
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def register_search_facet_occurrence(environment, asset, kind, facet_slug, argument)
Method find_by_contents
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_by_contents(asset, scope, query, paginate_options = {}, params = {})
Method attribute_option_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def attribute_option_name(name, klass, params)
return nil if name.blank?
if params[:attribute].to_s == "content_type"
Noosfero::FriendlyMIME.find(name)[1..-1].upcase
- 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"