Showing 162 of 163 total issues
Method apply_scopes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def apply_scopes(filters, opts = {})
context = opts[:context]
if @_search_service
# Separate queries from filters
queries = filters.select { |f| @_query_fields.include?(f) }
- 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 apply_scopes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def apply_scopes(filters, opts = {})
context = opts[:context]
if _search_service
# Separate queries from filters
queries = filters.select { |f| @_query_fields.include?(f) }
- 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?
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def create?
return false unless user
return false if user.unregistered?
return false if user.blocked?(record.post.user)
return false if user.has_role?(:banned)
- 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 stats_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def stats_data
data = super || default_data
# Generate percentile data
if global_stat
data['percentiles'] = %w[media units time].each_with_object({}) do |key, out|
- 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 follow_many
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def follow_many(follows, backlog)
return false unless ENV['STREAMLOG_REDIS_URL']
follow_keys = follows.map do |follow|
source = follow[:source].split(':')
target = follow[:target].split(':')
- 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 object_hash
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def object_hash(source, include_directives = {})
obj_hash = {}
if source.is_a?(JSONAPI::CachedResourceFragment)
if source.class.name != 'CategoryRecommendationResource'
Method query_for
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.query_for(query)
fields = %w[name^2 people media]
{
bool: {
must: {
Method date_format
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def date_format
return @date_format if @date_format
# if any dates have values higher than 12, assume the date format
data.each do |row|
row.fetch_values('start_date_string', 'finish_date_string').each do |date|
- 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?
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create?
return false unless user
return false if user.unregistered?
return false if user.blocked?(record.comment.user)
return false if user.blocked?(record.comment.post.user)
- 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 parameter
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parameter(key, cast: nil, load: nil, required: false)
# Set up the accessor
attr_accessor(key)
# Track all the attributes we've set up so far
- 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 strip_unenriched
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def strip_unenriched(activities, includes)
activities.map do |act|
if act['activities'] # Recurse into activity groups
act['activities'] = strip_unenriched(act['activities'], includes)
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 apply_order_to
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def apply_order_to(scope)
return scope unless orders
# Replace _text_match with _text_match(buckets: 6),user_count in the same direction
# This generally gives significantly better results for media searches
- 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 apply_order_to
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def apply_order_to(scope)
return scope unless orders
# Replace _text_match with _text_match(buckets: 6),user_count in the same direction
# This generally gives significantly better results for media searches
- 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 image_field
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def image_field(key, **options)
options = {
type: Types::Image,
null: true
}.merge(options)
- 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_average_ratings
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_average_ratings
#
# Bayesian rating:
#
# (total + (MIN * global_average)) / (count + MIN)
Method create?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create?
return false unless user
return false if user.unregistered?
return false if user&.blocked?(record.post.user)
return false if user&.has_role?(:banned)
- 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 apply!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def apply!
data.each do |item|
item = item.deep_symbolize_keys
puts item[:titles][:canonical].titleize
- 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 auto_query_for
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def auto_query_for(field, value)
case value
when String, Numeric, Date
{ match: { field => value } }
when Range
- 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 decrement
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def decrement(user, library_entry)
record = user.stats.find_by(type: "Stat::#{media_type}FavoriteYear")
return unless record
return if record.stats_data['total_media'].nil?
- 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 apply_status_filter_for
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_status_filter_for(scope)
return scope if filters[:status].blank?
statuses = filters[:status].map do |status|
case status