Showing 98 of 164 total issues
Method feed_visible?
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def feed_visible?
case params[:group].sub(/_aggr\z/, '')
when 'media'
media_type, media_id = params[:id].split('-')
return false unless %w[Manga Anime Drama].include?(media_type)
Method generate_query
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def generate_query(filters)
# For each queryable field, attempt to apply. If there's no apply
# specified, use auto_query to generate one.
queries = @_query_fields.map do |field, opts|
next unless filters.key?(field) # Skip if we don't have a filter
- 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_sort
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.apply_sort(records, order_options, context = {})
# For each requested sort option, decide whether to use the title sort logic
order_options = order_options.map do |field, dir|
[(TITLE_SORT.match?(field) ? :title : :other), field, dir]
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 by_slug
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def by_slug(slug)
record = where(slug: slug)
return record if record.present?
value = slug.is_a?(Array) ? slug.first : slug
- 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 only_following
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def only_following(user_id)
followed = Set.new(Follow.where(follower_id: user_id).pluck(:followed_id))
select(0.5) do |act|
user_id = act['actor'].split(':')[1].to_i
is_followed = followed.include?(user_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 generate_query
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def generate_query(filters)
# For each queryable field, attempt to apply. If there's no apply
# specified, use auto_query to generate one.
queries = @_query_fields.map do |field, opts|
next unless filters.key?(field) # Skip if we don't have a filter
- 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 feed_visible?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def feed_visible?
case params[:group].sub(/_aggr\z/, '')
when 'media'
media_type, media_id = params[:id].split('-')
return false unless %w[Manga Anime Drama].include?(media_type)
- 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 increment
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def increment(user, library_entry)
record = user.stats.find_or_initialize_by(
type: "Stat::#{media_type}FavoriteYear"
)
# set default to total and all_years if it doesn't exist
- 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 blocking
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def blocking(user_ids)
blocked = Set.new(user_ids)
select do |act|
user_id = act['actor'].split(':')[1].to_i
will_block = blocked.include?(user_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 stream_activity
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def stream_activity
to = []
to << post.user.notifications unless post.user == user
to << parent&.user&.notifications unless parent&.user == user
to += mentioned_users.map(&:notifications)
- 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 status
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def status
return :tba if start_date.nil? && end_date.nil?
return :finished if end_date&.past?
return :current if start_date&.past? || start_date&.today?
return :upcoming if start_date && start_date <= Date.today + 3.months
- 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 results_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def results_for(key, limit = 5, offset = 0)
results = []
loop.with_index do |_, index|
break if index > 5
page = raw_results_for(key, limit, offset)
- 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 verify
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def verify
mode = params['hub.mode']
topic = params['hub.topic']
challenge = params['hub.challenge']
- 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 run!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def run!
each_anime do |kitsu_id, anime|
# Import Anime Mappings
create_mapping('aozora', anime['_id'], kitsu_id)
mal_id = anime['myAnimeListID']
- 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 include?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def include?(key)
return true if @whitelist.include?(key)
# Magic match-handling code
match = TITLE_SORT.match(key.to_s)
return false unless match
- 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 perform
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def perform(namespace, half_life, user, id, weight)
Method processable
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def processable(column, pipeline)
processed_column = "processed_#{column}"
memoized = "@#{processed_column}"
define_method(processed_column) 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 complete_stream_activity
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def complete_stream_activity
stream_activity&.tap do |activity|
activity.actor ||= user if respond_to?(:user)
activity.object ||= self
activity.foreign_id ||= activity.object
- 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?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update?
return false unless user
return false if user.has_role?(:banned)
return true if can_administrate?
# admins are allowed to update comments on locked posts
- 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 validate_each
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attr, value)
if value.respond_to?(:each)
value.each do |v|
error = validate_value(v)
record.errors.add(attr, message: error) if error
- 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"