File base.rb
has 664 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Search
class Base
extend ActiveModel::Naming
extend Enumerize
Class Base
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Base
extend ActiveModel::Naming
extend Enumerize
include ActiveModel::Validations
Class Chart
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Chart
class GroupByAttribute
class << self
private
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")
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?
- 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 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")
- 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 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).
- 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"