Showing 24 of 28 total issues
Method validate?
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
def validate?(attr_validator, object = nil, hash = nil)
object ||= attr_validator.object
return false unless object
if Authorization.is_a_association_proxy?(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 validate?
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate?(attr_validator, object = nil, hash = nil)
object ||= attr_validator.object
return false unless object
if Authorization.is_a_association_proxy?(object) &&
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
Class AuthorizationRulesParser
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class AuthorizationRulesParser
attr_reader :roles, :role_hierarchy, :auth_rules,
:role_descriptions, :role_titles, :omnipotent_roles # :nodoc:
def initialize # :nodoc:
Method obligation
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def obligation(attr_validator, hash_or_attr = nil, path = [])
hash_or_attr ||= @attr_hash
case hash_or_attr
when Symbol
@context ||= begin
Method validate?
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def validate?(attr_validator, object = nil, hash_or_attr = nil)
object ||= attr_validator.object
hash_or_attr ||= @attr_hash
return false unless 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 obligations
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def obligations(attr_validator)
exceptions = []
obligations = @attributes.collect do |attr|
begin
attr.obligation(attr_validator)
- 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 to_long_s
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def to_long_s(hash = nil)
if hash
hash.inject({}) do |memo, key_val|
key, val = key_val
memo[key] = case val
- 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?
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate?(attr_validator, object = nil, hash_or_attr = nil)
object ||= attr_validator.object
hash_or_attr ||= @attr_hash
return false unless object
Method obligations
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def obligations(attr_validator)
exceptions = []
obligations = @attributes.collect do |attr|
begin
attr.obligation(attr_validator)
Method reflection_for_path
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.reflection_for_path(parent_model, path)
reflection = path.empty? ? parent_model : begin
parent = reflection_for_path(parent_model, path[0..-2])
if !parent.respond_to?(:proxy_reflection) && parent.respond_to?(:klass)
parent.klass.reflect_on_association(path.last)
- 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
Consider simplifying this complex logical expression. Open
elsif value.is_a?(Array) && value.length == 2 && value.first.is_a?(Symbol)
evaluated = if value[1].is_a?(Proc)
attr_validator.evaluate(value[1])
else
value[1]
Method obligation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def obligation(attr_validator, hash_or_attr = nil, path = [])
hash_or_attr ||= @attr_hash
case hash_or_attr
when Symbol
@context ||= begin
- 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 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 has_permission_on
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def has_permission_on(*args)
options = args.extract_options!
context = args.flatten
raise DSLError, 'has_permission_on only allowed in role blocks' if @current_role.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 initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(role, privileges = [], contexts = nil, join_operator = :or,
options = {})
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(engine, user, object = nil, privilege = nil, context = nil)
Method obligation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def obligation(attr_validator, hash = nil)
hash = (hash || @conditions_hash).clone
hash.each do |attr, value|
if value.is_a?(Hash)
hash[attr] = obligation(attr_validator, value)
- 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"