thorin/redmine_ldap_sync

View on GitHub

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
Severity: Major
Found in app/models/ldap_setting.rb - About 1 day to fix

    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)
    Severity: Minor
    Found in app/models/ldap_test.rb - About 1 day to fix

    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 }
    Severity: Minor
    Found in lib/ldap_sync/entity_manager.rb - About 5 hrs to fix

    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
    
    
    Severity: Minor
    Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 4 hrs to fix

      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?
      Severity: Minor
      Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 4 hrs to fix

      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
      Severity: Minor
      Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 3 hrs to fix

      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
      Severity: Minor
      Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 3 hrs to fix

      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?
      Severity: Minor
      Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 3 hrs to fix

      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
      
      
      Severity: Minor
      Found in lib/ldap_sync/entity_manager.rb - About 2 hrs to fix

        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
        Severity: Minor
        Found in app/models/ldap_setting.rb - About 2 hrs to fix

          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'
          Severity: Minor
          Found in lib/ldap_sync/entity_manager.rb - About 2 hrs to fix

          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 }
          Severity: Minor
          Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 2 hrs to fix

          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 }
          Severity: Major
          Found in lib/ldap_sync/entity_manager.rb - About 2 hrs to fix

            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)
            Severity: Minor
            Found in app/models/ldap_test.rb - About 1 hr to fix

              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
              Severity: Minor
              Found in lib/ldap_sync/infectors/user.rb - About 1 hr to fix

              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?
              Severity: Minor
              Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 1 hr to fix

                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?
                
                
                Severity: Minor
                Found in lib/ldap_sync/entity_manager.rb - About 1 hr to fix

                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)
                Severity: Minor
                Found in lib/ldap_sync/entity_manager.rb - About 1 hr to fix

                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?
                Severity: Minor
                Found in lib/ldap_sync/infectors/auth_source_ldap.rb - About 1 hr to fix

                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 || {}
                
                
                Severity: Minor
                Found in lib/ldap_sync/entity_manager.rb - About 1 hr to fix

                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

                Severity
                Category
                Status
                Source
                Language