Method permit!
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def permit!(privilege, options = {})
return true if Authorization.ignore_access_control
options = {
object: nil,
skip_attribute_test: false,
- 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 roles_for
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def roles_for(user)
user ||= Authorization.current_user
raise AuthorizationUsageError, "User object doesn't respond to roles (#{user.inspect})" \
if !user.respond_to?(:role_symbols) && !user.respond_to?(:roles)
- 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 permit!
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def permit!(privilege, options = {})
return true if Authorization.ignore_access_control
options = {
object: nil,
skip_attribute_test: false,
Method flatten_privileges
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def flatten_privileges(privileges, context = nil, flattened_privileges = Set.new)
# TODO: caching?
raise AuthorizationUsageError, 'No context given or inferable from object' unless context
privileges.reject { |priv| flattened_privileges.include?(priv) }.each do |priv|
flattened_privileges << priv
- 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 initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(engine, user, object = nil, privilege = nil, context = nil)
Method development_reload?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.development_reload?
if Rails.env.development?
mod_time = AUTH_DSL_FILES.map do |m|
begin
File.mtime(m)
- 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"