Showing 15 of 17 total issues
Class Network
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Network
class << self
def has_reputation_for?(class_name, reputation_name)
reputation_def = get_reputation_def(class_name, reputation_name)
!!reputation_def[:source]
Method update_reputation_value_with_updated_source
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.update_reputation_value_with_updated_source(rep, source, oldValue, newSize, weight, process)
weight ||= 1 # weight is 1 by default.
oldSize = rep.received_messages.size
valueBeforeUpdate = oldSize > 0 ? rep.value : nil
newValue = source.value
- 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 get_reputation_def
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_reputation_def(class_name, reputation_name)
reputation_def = {}
unless class_name == "ActiveRecord::Base"
reputation_defs = get_reputation_defs(class_name)
reputation_defs[reputation_name.to_sym] ||= {}
- 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 normalized_value
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def normalized_value
if self.active == 1 || self.active == true
max = ReputationSystem::Reputation.max(self.reputation_name, self.target_type)
min = ReputationSystem::Reputation.min(self.reputation_name, self.target_type)
if max && min
- 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 up
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.up
create_table :rs_evaluations do |t|
t.string :reputation_name
t.references :source, :polymorphic => true
t.references :target, :polymorphic => true
Method get_attributes_of
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_attributes_of(reputation)
of = reputation[:of]
attrs = (of == :self) ? self : self.instance_eval(of.to_s) if of.is_a?(String) || of.is_a?(Symbol)
attrs = attrs.to_a if attrs.is_a?(ActiveRecord::Associations::CollectionProxy)
attrs = self.instance_exec(self, &of) if of.is_a?(Proc)
- 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 update_reputation_value_with_updated_source
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.update_reputation_value_with_updated_source(rep, source, oldValue, newSize, weight, process)
Method add_reputation_def
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_reputation_def(class_name, reputation_name, options)
reputation_defs = get_reputation_defs(class_name)
options[:source] = convert_to_array_if_hash(options[:source])
options[:source_of] ||= []
options[:source_of] = convert_to_array_if_hash(options[:source_of])
- 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 create_scoped_reputation_def
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_scoped_reputation_def(class_name, reputation_name, scope, options)
raise ArgumentError, "#{reputation_name} does not have scope." unless has_scopes?(class_name, reputation_name)
scope_options = options.reject { |k, v| ![:source, :aggregated_by].include? k }
reputation_def = get_reputation_def(class_name, reputation_name)
unless is_primary_reputation?(class_name, reputation_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 has_reputation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def has_reputation(reputation_name, options)
has_valid_input = reputation_name && options[:source]
raise ArgumentError, "has_reputation method received invalid arguments." unless has_valid_input
# Overwrites reputation if the same reputation name is declared in the same model.
- 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 update_reputation_value_with_new_source
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.update_reputation_value_with_new_source(rep, source, weight, process)
weight ||= 1 # weight is 1 by default.
size = rep.received_messages.size
valueBeforeUpdate = size > 0 ? rep.value : nil
newValue = source.value
- 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 send_reputation_message_to_receiver
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.send_reputation_message_to_receiver(reputation_name, sender, target, scope, oldValue)
Method update_reputation_value
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.update_reputation_value(receiver, sender, weight, process, oldValue)
Method build_select_statement
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_select_statement(table_name, reputation_name, select=nil, srn=nil, normalize=false)
Method initialize_reputation_value
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.initialize_reputation_value(receiver, target, process)
name = receiver.reputation_name
unless ReputationSystem::Network.is_primary_reputation?(target.class.name, name)
sender_defs = ReputationSystem::Network.get_reputation_def(target.class.name, name)[:source]
sender_defs.each do |sd|
- 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"