Showing 10 of 20 total issues
Method recommends
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
def recommends(*things)
Recommendable.configure do |config|
config.ratable_classes = []
config.user_class = self
end
Method method_missing
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(method, *args, &block)
if method.to_s =~ /\A((?:dis)?liked|hidden|bookmarked)_(.+)_in_common_with\z/
begin
send("#{$1}_in_common_with", $2.classify.constantize, *args)
rescue NameError
- 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 make_recommendable!
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def make_recommendable!
Recommendable.configure { |config| config.ratable_classes << self }
class_eval do
include Likable
Method update_recommendations_for
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_recommendations_for(user_id)
user_id = user_id.to_s
nearest_neighbors = Recommendable.config.nearest_neighbors || Recommendable.config.user_class.count
Recommendable.config.ratable_classes.each do |klass|
Method update_similarities_for
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_similarities_for(user_id)
user_id = user_id.to_s # For comparison. Redis returns all set members as strings.
similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)
# Only calculate similarities for users who have rated the items that
Method recommends
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def recommends(*things)
Recommendable.configure do |config|
config.ratable_classes = []
config.user_class = self
end
- 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 respond_to?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def respond_to?(method, include_private = false)
if method.to_s =~ /\A((?:dis)?liked|hidden|bookmarked)_(.+)_in_common_with\z/ ||
method.to_s =~ /\A((?:dis)?liked|hidden|bookmarked)_(.+)_ids\z/ ||
method.to_s =~ /\A((?:dis)?liked|hidden|bookmarked|recommended)_(.+)\z/
begin
- 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_similarities_for
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update_similarities_for(user_id)
user_id = user_id.to_s # For comparison. Redis returns all set members as strings.
similarity_set = Recommendable::Helpers::RedisKeyMapper.similarity_set_for(user_id)
# Only calculate similarities for users who have rated the items that
- 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 enqueue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def enqueue(user_id)
user_id = user_id.id if user_id.is_a?(Recommendable.config.user_class)
user_id = user_id.to_s
if defined?(::Sidekiq)
- 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 deeply nested control flow statements. Open
rescue NameError
super