app/controllers/application_controller.rb
Assignment Branch Condition size for undo_link is too high. [20.32/15] Open
Open
def undo_link(message)
version = Version.where('whodunnit = ?', session[:user].id).last
return unless version.try(:created_at) && Time.now.in_time_zone - version.created_at < 5.0
link_name = params[:redo] == 'true' ? 'redo' : 'undo'
message + "<a href = #{url_for(controller: :versions, action: :revert, id: version.id, redo: !params[:redo])}>#{link_name}</a>"
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Class ApplicationController
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class ApplicationController < ActionController::Base
include AccessHelper
# You want to get exceptions in development, but not in production.
unless Rails.application.config.consider_all_requests_local
Rename is_available
to available?
. Open
Open
def is_available(user, owner_id)
- Read upRead up
- Exclude checks
This cop makes sure that predicates are named properly.
Example:
# bad
def is_even?(value)
end
# good
def even?(value)
end
# bad
def has_value?
end
# good
def value?
end
Method ApplicationController#current_user_role?
is defined at both app/controllers/application_controller.rb:26 and app/controllers/application_controller.rb:70. Open
Open
alias current_user_role? current_user_role
- Read upRead up
- Exclude checks
This cop checks for duplicated instance (or singleton) method definitions.
Example:
# bad
def duplicated
1
end
def duplicated
2
end
Example:
# bad
def duplicated
1
end
alias duplicated other_duplicated
Example:
# good
def duplicated
1
end
def other_duplicated
2
end