Showing 9 of 9 total issues
Method add_query_stub
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_query_stub(model)
m = model.name
self.class_eval %-
def query_#{AppBase.underscore m}
query = #{m}.accessible_by(current_user)
Method crud_allow
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def crud_allow(crud, criteria=:mine, &block)
validate_crud crud
if criteria == :mine
allow_mine crud
- 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 symbol_array_manipulate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def symbol_array_manipulate(op, source, options)
raise InvalidUsage if op != :only && op != :except
if options.has_key? op
operands = options[op]
operands = [operands] if operands.instance_of?(String) || operands.instance_of?(Symbol)
- 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 init_parameters
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def init_parameters
parameters = @bound_method.parameters
pre_init_parameters(parameters)
need_params = 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 init
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def init
init_parameters do |parameters, need_params|
@requires = parameters.map{|p|":#{p[1]}"}
@parameters = @auth ? ['current_user'] : []
@requires.each { |p| @parameters << "params[#{p}]" }
- 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 show_usage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show_usage(crud)
raise %-
allow_#{crud} usage:
allow_#{crud} :mine
allow_#{crud} :#{ crud == :query ? 'within' : 'if' } => :a_singleton_method
- 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 allow_criteria_with_block
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def allow_criteria_with_block(crud, block)
show_usage(crud) if crud == :query && block.parameters.count != 1
show_usage(crud) if crud != :query && block.parameters.count != 2
model_inject crud == :query ? :accessible_by : "allow_#{crud}", &block
end
- 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 register_rpc
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def register_rpc(model, method_name, options={})
rpc_registry_item = {
model: (model.instance_of?(String) || model.instance_of?(Symbol)) ? Object.const_get(model.to_sym) : model,
method: method_name.to_sym,
auth: options.has_key?(:auth) ? options[:auth] : true
- 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 each_crud
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def each_crud(*models, &block)
models = models.flatten.map { |model| (model.instance_of?(Symbol) || model.instance_of?(String)) ? Object.const_get(model) : model }
@crud_permissions.each do |r|
block.call r[:model], r[:crud] if models.index(r[:model])
end
- 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"