Showing 38 of 38 total issues
Class Query
has 56 methods (exceeds 20 allowed). Consider refactoring. Open
class BazaModels::Query
AutoAutoloader.autoload_sub_classes(self, __FILE__)
include BazaModels::Query::Pagination
Class Model
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class BazaModels::Model
AutoAutoloader.autoload_sub_classes(self, __FILE__)
include BelongsToRelations
include Delegation
File query.rb
has 384 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "array_enumerator"
class BazaModels::Query
AutoAutoloader.autoload_sub_classes(self, __FILE__)
Method to_sql
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def to_sql # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
sql = "SELECT "
if @selects.empty?
sql << "#{@db.sep_table}#{@model.table_name}#{@db.sep_table}.*"
- 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 model.rb
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "string-cases"
class BazaModels::Model
AutoAutoloader.autoload_sub_classes(self, __FILE__)
Method to_sql
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_sql # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
sql = "SELECT "
if @selects.empty?
sql << "#{@db.sep_table}#{@model.table_name}#{@db.sep_table}.*"
Method save
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def save(args = {})
if args[:validate] == false || valid?
new_record = new_record?
fire_callbacks(:before_save)
self.updated_at = Time.now if changed? && has_attribute?(:updated_at)
- 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 has_one
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def has_one(relation_name, *all_args)
# rubocop:enable Naming/PredicateName
args = all_args.pop
- 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 belongs_to
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def belongs_to(relation_name, args = {})
relation = {
type: :belongs_to,
relation_name: relation_name,
table_name: args[:table_name] || StringCases.pluralize(relation_name),
- 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 where
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def where(*args)
first_arg = args.first
new_wheres = @wheres.dup
if first_arg.is_a?(String)
- 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 real_attributes
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def real_attributes(attributes)
new_attributes = {}
attributes.each do |attribute_name, attribute_value|
belongs_to_relations = self.class.instance_variable_get(:@belongs_to_relations)
- 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 destroy
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def destroy
if new_record?
errors.add(:base, "cannot destroy new record")
false
else
- 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 valid?
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def valid?
fire_callbacks(:before_validation)
if new_record?
fire_callbacks(:before_validation_on_create)
- 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 parse_relation
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse_relation
current_name = []
relationships = @klass.relationships
loop do
- 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 has_one
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def has_one(relation_name, *all_args)
# rubocop:enable Naming/PredicateName
args = all_args.pop
Method where
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def where(*args)
first_arg = args.first
new_wheres = @wheres.dup
if first_arg.is_a?(String)
Method has_many
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def has_many(relation_name, *all_args)
# rubocop:enable Naming/PredicateName
args = all_args.pop
- 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 has_many
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def has_many(relation_name, *all_args)
# rubocop:enable Naming/PredicateName
args = all_args.pop
Method belongs_to
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def belongs_to(relation_name, args = {})
relation = {
type: :belongs_to,
relation_name: relation_name,
table_name: args[:table_name] || StringCases.pluralize(relation_name),
Method add_filters_to_query
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def add_filters_to_query
@add_filters_to_query_executed = true
return unless @params
ransackable_scopes = @klass.ransackable_scopes.map(&:to_s) if @klass.respond_to?(:ransackable_scopes)
- 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"