Class ApplicationController
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
protect_from_forgery
APP_DOMAIN = 'coderwall.com'
Method record_event
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def record_event(action_name, options = {})
if !signed_in? || !current_user.admin?
options.merge!('mp_name_tag' => cookies[:identity]) unless cookies[:identity].blank?
options.merge!('distinct_id' => cookies[:trc]) unless cookies[:trc].blank?
unless current_user.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
File application_controller.rb
has 264 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
protect_from_forgery
APP_DOMAIN = 'coderwall.com'
Method record_visit
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def record_visit
if viewing_user
if viewing_user == current_user && (viewing_user.try(:last_request_at) || 1.week.ago) < 1.day.ago && viewing_user.active? && viewing_user.last_refresh_at < 2.days.ago
RefreshUserJob.perform_async(current_user.id)
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 destination_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def destination_url
if session[:return_to]
session.delete(:return_to)
elsif signed_in?
if current_user.oldest_achievement_since_last_visit
- 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"