Method permissions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def permissions
arr = role_permissions_collection.map do |rp|
rp.permission.name if rp.granted
end.compact
- 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 remove_permission
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def remove_permission(name, destroy = false)
role_permissions.includes(:permission).each do |rp|
next unless rp.permission.name == name
if destroy
rp.destroy
- 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 array_permission_check
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def array_permission_check(actions)
grants = []
perms = load_permission(actions)
unless perms.length > 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 can?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def can?(action)
if action.is_a?(Array)
if action.length == 1
single_permission_check action.first
else
- 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 add_permission
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_permission(name)
perm = ApiGuardian.configuration.permission_class.find_by_name(name)
fail ApiGuardian::Errors::InvalidPermissionName, "Permission '#{name}' is not valid." unless perm
role_permissions.includes(:permission).each do |rp|
- 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 single_permission_check
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def single_permission_check(action)
perm = load_permission(action).first
fail ApiGuardian::Errors::InvalidPermissionName, "Permission '#{action}' is not valid." unless perm
role_permissions_collection.each do |rp|
- 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"