File entity.rb
has 547 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mongoid'
require 'lrucache'
require_relative '../link_manager'
require_relative '../position/proximity'
Method positions_flow
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
def self.positions_flow(ids, from, to, options = {})
ext = 70*60
t = Time.at(from.to_i)
from = Time.new(t.year, t.month, t.day, t.hour, t.min, 0).to_i
- 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
Class Entity
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class Entity
extend RCS::Tracer
include RCS::Tracer
include Mongoid::Document
include Mongoid::Timestamps
Method flow
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.flow(params)
start_time = Time.now # for debugging
# aggregate all the entities by their handles' handle
# so if 2 entities share the same handle you'll get {'foo.bar@gmail.com' => ['entity1_id', 'entity2_id']}
- 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 positions_flow
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.positions_flow(ids, from, to, options = {})
ext = 70*60
t = Time.at(from.to_i)
from = Time.new(t.year, t.month, t.day, t.hour, t.min, 0).to_i
Method name_from_handle
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def self.name_from_handle(type, handle, target_id)
# use a class cache
@@acc_cache ||= LRUCache.new(:ttl => 24.hour)
- 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 flow
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.flow(params)
start_time = Time.now # for debugging
# aggregate all the entities by their handles' handle
# so if 2 entities share the same handle you'll get {'foo.bar@gmail.com' => ['entity1_id', 'entity2_id']}
Method create_or_update_group
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.create_or_update_group(operation, name: nil, children: [], stand_for: nil)
children = children[0].respond_to?(:id) ? children.map(&:id) : children
level = stand_for ? :automatic : :manual
operation = operation.respond_to?(:id) ? operation : Item.operations.find(operation)
- 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 link_target_entities_passed_from_here
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def link_target_entities_passed_from_here
return if type != :position
operation_id = path.first
- 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 handle_regexp_for_queries
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.handle_regexp_for_queries(type, value)
if type.to_s != 'phone'
value
else
# if the type is phone but the value contains no numbers
- 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 linked_to?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def linked_to? another_entity, options = {}
filter = {}
filter[:type] = options[:type] if options[:type]
filter[:level] = options[:level] if options[:level]
- 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_or_update_operation_group
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.create_or_update_operation_group(first_operation, second_operation)
first_operation = Item.operations.find(first_operation) unless first_operation.respond_to?(:id)
second_operation = Item.operations.find(second_operation) unless second_operation.respond_to?(:id)
first_op_name, second_op_name = *[first_operation.name, second_operation.name].map do |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 merge
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def merge(merging)
raise "cannot merge a target over a person" if merging.type == :target
raise "cannot merge different type of entities" unless [:person, :target].include? self.type and [:person, :target].include? merging.type
trace :debug, "Merging entities: #{merging.name} -> #{self.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
Avoid too many return
statements within this method. Open
return e[:data]['name']
Avoid too many return
statements within this method. Open
return nil
Avoid too many return
statements within this method. Open
return nil
Method link_similar_position
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def link_similar_position
return if type != :position
return if level != :manual
self.class.same_path_of(self).positions_within(position, 100).each do |other_entity|
- 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"