Method prepare
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
def self.prepare
return self if @init_done
@init_done = true
actions = Setup::Models.all.reduce(Set.new) do |set, model|
- 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 prepare
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.prepare
return self if @init_done
@init_done = true
actions = Setup::Models.all.reduce(Set.new) do |set, model|
File ability.rb
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cancan/model_adapters/mongoff_adapter'
require 'setup/storage'
class Ability
include CanCan::Ability
Method can?
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def can?(action, subject, *extra_args)
return true if action == :digest
if action == :json_edit
subject.is_a?(Mongoff::Record) && !subject.is_a?(Mongoff::GridFs::File)
elsif (action == :simple_cross && crossing_models.exclude?(subject.is_a?(Class) ? subject : subject.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 initialize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
@deferred_abilities = []
deferred_abilities <<
if (@user = user)
- 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 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
@deferred_abilities = []
deferred_abilities <<
if (@user = user)
Consider simplifying this complex logical expression. Open
elsif (action == :simple_cross && crossing_models.exclude?(subject.is_a?(Class) ? subject : subject.class)) ||
(subject == ScriptExecution && (user.nil? || !user.super_admin?))
false
else
super || deferred_abilities.any? { |ability| ability.can?(action, subject, *extra_args) }