Showing 36 of 42 total issues
Method get_group_fields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_group_fields(groupname, group_data = nil)
group_data ||= with_ldap_connection do |ldap|
find_group(ldap, groupname, [n(:groupname), *setting.group_ldap_attrs_to_sync])
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 ldap_users
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ldap_users
return @ldap_users if defined? @ldap_users
with_ldap_connection do |ldap|
changes = { enabled: SortedSet.new, locked: SortedSet.new, deleted: SortedSet.new }
Method validate_fields
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_fields(fields_to_sync, fields, attrs)
fields_ids = fields.map {|f| f.is_a?(String) ? f : f.id.to_s }
if (fields_to_sync - fields_ids).present?
errors.add :user_group_fields, :invalid unless errors.added? :user_group_fields, :invalid
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 sync_user_groups
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def sync_user_groups(user)
return unless setting.active?
if setting.has_fixed_group? && !user.member_of_group?(setting.fixed_group)
user.add_to_fixed_group
- 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 sync_user_status
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync_user_status(user, flags, locked)
locked ||= flags && flags != :deleted && account_locked?(flags)
deleted = flags == :deleted
message = if user.active?
Method find_or_create_user
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_or_create_user(username)
user, is_invalid = find_local_user(username)
return nil, false if is_invalid
return user unless user.nil? && setting.create_users?
- 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 ldap_users
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def ldap_users
return @ldap_users if defined? @ldap_users
with_ldap_connection do |ldap|
changes = { enabled: SortedSet.new, locked: SortedSet.new, deleted: SortedSet.new }
- 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 create_and_sync_group
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_and_sync_group(group_data, attr_groupname)
groupname = group_data[attr_groupname].first
return unless setting.groupname_regexp =~ groupname
group, is_new_group = find_or_create_group(groupname, group_data)
- 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 sync_user_fields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def sync_user_fields(user, user_data = nil)
return unless setting.active? && setting.sync_user_fields?
user.synced_fields = get_user_fields(user.login, user_data)
- 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 user_fields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def user_fields
has_user_ldap_attrs = @ldap_setting.has_user_ldap_attrs?
(User::STANDARD_FIELDS + UserCustomField.all).map do |f|
if f.is_a?(String)
- 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 validate_ldap_attrs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate_ldap_attrs(ldap_attrs, fields)
field_ids = fields.map {|f| f.id.to_s }
ldap_attrs.each do |k, v|
if !field_ids.include?(k)
errors.add :user_group_fields, :invalid unless errors.added? :user_group_fields, :invalid
- 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_all_groups
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def find_all_groups(ldap, extra_filter, attrs, options = {}, &block)
Method sync_admin_privilege
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sync_admin_privilege(user)
return unless setting.has_admin_group?
if user.member_of_group?(setting.admin_group)
unless user.admin?
- 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_all_groups
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def find_all_groups(ldap, extra_filter, attrs, options = {}, &block)
object_class = options[:class] || setting.class_group
groups_base_dn = setting.has_groups_base_dn? ? setting.groups_base_dn : nil
group_filter = Net::LDAP::Filter.eq( :objectclass, object_class )
group_filter &= Net::LDAP::Filter.construct( setting.group_search_filter ) if setting.group_search_filter.present?
- 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 strip_names
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def strip_names
LDAP_ATTRIBUTES.each {|a| @attributes[a].strip! unless @attributes[a].nil? }
CLASS_NAMES.each {|a| @attributes[a].strip! unless @attributes[a].nil? }
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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize args
super
#
# Check the encoding of the newly created String and set the encoding
# to 'UTF-8' (NOTE: we do NOT change the bytes, but only set the
- 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"