Showing 42 of 42 total issues
Class LdapSetting
has 59 methods (exceeds 20 allowed). Consider refactoring. Open
class LdapSetting
include Redmine::SafeAttributes
include Redmine::I18n
include ActiveModel::Validations
Method run_with_users_and_groups
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def run_with_users_and_groups(users, groups)
with_ldap_connection(@bind_user, @bind_password) do |ldap|
@user_changes = ldap_users
users.each do |login|
user_data = find_user(ldap, login, 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"
Further reading
Method groups_changes
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def groups_changes(user)
return unless setting.active?
changes = { added: SortedSet.new, deleted: SortedSet.new }
user_groups = user.groups.map {|g| g.name.downcase }
- 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
File auth_source_ldap.rb
has 373 lines of code (exceeds 250 allowed). Consider refactoring. Open
module LdapSync::Infectors::AuthSourceLdap
module InstanceMethods
include LdapSync::EntityManager
Method sync_users
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def sync_users
if connect_as_user?
trace " -> Cannot synchronize: no account/password configured"; return
end
unless setting.active?
- 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 trace
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def trace(msg = nil, options = {}, &block)
return if trace_level == :silent || msg.nil?
if !running_rake?
logger.error(block_given? ? yield : msg) if options[:level] == :error
return
- 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
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def sync_user(user, is_new_user = false, options = {})
with_ldap_connection(options[:login], options[:password]) do |ldap|
trace "-- #{is_new_user ? 'Creating' : 'Updating'} user '#{user.login}' (#{user.name})...",
:level => is_new_user ? :change : :debug,
:obj => user.login
- 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 a Cognitive Complexity of 22 (exceeds 5 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?
- 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
File entity_manager.rb
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
module LdapSync::EntityManager
public
def connect_as_user?; setting.account.include?('$login'); end
File ldap_setting.rb
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
class LdapSetting
include Redmine::SafeAttributes
include Redmine::I18n
include ActiveModel::Validations
Method get_group_closure
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def get_group_closure(ldap, group, closure=Set.new)
groupname = group.is_a?(String) ? group : group[n(:groupname)].first
parent_groups = parents_cache.fetch(groupname) do
case setting.nested_groups
when 'on_members'
- 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 trace_groups_changes_summary
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def trace_groups_changes_summary(user, groups, added, deleted)
return unless running_rake?
a = added.size; d = deleted.size; nc = groups[:added].size - a
added_names = added.map {|g| g.lastname.mb_chars.downcase.to_s }
- 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 groups_changes
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def groups_changes(user)
return unless setting.active?
changes = { added: SortedSet.new, deleted: SortedSet.new }
user_groups = user.groups.map {|g| g.name.downcase }
Method run_with_users_and_groups
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_with_users_and_groups(users, groups)
with_ldap_connection(@bind_user, @bind_password) do |ldap|
@user_changes = ldap_users
users.each do |login|
user_data = find_user(ldap, login, nil)
Method try_to_login_with_ldap_sync
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def try_to_login_with_ldap_sync(*args)
user = try_to_login_without_ldap_sync(*args)
return user unless user.try(:sync_on_login?)
login, password = *args
- 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_users
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync_users
if connect_as_user?
trace " -> Cannot synchronize: no account/password configured"; return
end
unless setting.active?
Method ldap_search
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def ldap_search(ldap, options, &block)
attrs = options[:attributes]
return ldap.search(options, &block) if attrs.is_a?(Array) || attrs.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"
Further reading
Method get_user_fields
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_user_fields(username, user_data=nil, options={})
fields_to_sync = setting.user_fields_to_sync
if options.try(:fetch, :include_required, false)
custom_fields = user_required_custom_fields.map {|cf| cf.id.to_s }
fields_to_sync -= (User::STANDARD_FIELDS + custom_fields)
- 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_groups
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def sync_groups
if connect_as_user?
trace " -> Cannot synchronize: no account/password configured"; return
end
unless setting.active?
- 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 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"