Method find_collection
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def find_collection(resource_class, options = {})
permission = options.delete :permission
resource_class = Host if resource_class == Host::Base
Foreman::Logging.logger('permissions').debug "checking permission #{permission} for class #{resource_class}"
- 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 find_collection
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_collection(resource_class, options = {})
permission = options.delete :permission
resource_class = Host if resource_class == Host::Base
Foreman::Logging.logger('permissions').debug "checking permission #{permission} for class #{resource_class}"
Method build_filtered_scope_components
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_filtered_scope_components(resource_class, all_filters, options)
result = { where: [], includes: [], joins: [] }
if all_filters.empty? || (!@base_collection.nil? && @base_collection.empty?)
Foreman::Logging.logger('permissions').debug 'no filters found for given permission' if all_filters.empty?
- 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?(permission, subject = nil, cache = true)
return false if user.nil? || user.disabled?
return true if user.admin?
if subject.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"