Showing 4 of 8 total issues
Method filter
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def filter(param_name, items) # rubocop:disable Metrics/AbcSize
skippables = %w[controller action name t slug] + [param_name.to_s]
items.map do |k, v|
link = params[param_name] == v ? "<strong>#{k}</strong>" : k
param_str = "?#{param_name}=#{CGI.escape(v)}"
- 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 str_matches_short_date?
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def str_matches_short_date?
return false unless str =~ %r{\A(\d{1,2})(-|/)(\d{1,2})(-|/)(\d{1,2})\z}
r = Regexp.last_match
year = r[5]
zero = (year.size == 1 ? '0' : '')
- 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 user_likes_for_shows
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def user_likes_for_shows(shows)
return [] unless current_user && shows
likes = Like.where(user: current_user, likable: shows).includes(:likable)
shows.map do |s|
(like = likes.find { |l| l.likable == s }) ? like : 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 user_likes_for_tracks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def user_likes_for_tracks(tracks)
return [] unless current_user && tracks
likes = Like.where(user: current_user, likable: tracks).includes(:likable)
tracks.map do |t|
(like = likes.find { |l| l.likable == t }) ? like : 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"