Class User
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
include Clearance::User
has_many :devices, :dependent => :delete_all
accepts_nested_attributes_for :devices
File user.rb
has 343 lines of code (exceeds 250 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
include Clearance::User
has_many :devices, :dependent => :delete_all
accepts_nested_attributes_for :devices
Method handle_org_requests
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def handle_org_requests(req_json, current_user)
return [ false, [ "Permission denied" ] ] unless editable_by?(current_user)
rq_list = ActiveSupport::JSON.decode(req_json)
result = "success"
rq_errors = []
- 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 handle_org_requests
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_org_requests(req_json, current_user)
return [ false, [ "Permission denied" ] ] unless editable_by?(current_user)
rq_list = ActiveSupport::JSON.decode(req_json)
result = "success"
rq_errors = []
Method to_dsml
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_dsml(builder=nil)
builder=::Builder::XmlMarkup.new( :indent => 2) if builder.nil?
builder.dsml(:entry, :dn => dn) do |entry|
entry.dsml:objectclass do |oc|
ocv="oc-value".to_sym
Method is_org_admin_for?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def is_org_admin_for?(other)
unless other.class == Array || other.class == ActiveRecord::NamedScope::Scope
other = [ other ]
end
other.each do |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 is_org_member_of?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def is_org_member_of?(other)
if other.class == Organization
return true if other.members.include?(self)
elsif other.class == Array || other.class == ActiveRecord::Relation
other.each do |org|
- 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"