Skip to content

Move internal user methods to Users::Internal

What does this MR do and why?

User is one of the single largest classes in GitLab, and these methods do not need to be present on the User model. Move them to their own class in order to reduce the size of User. This is aligned with our software design guidelines for taming omniscient classes.

This will also prevent User from growing as we add more internal users.

Key changes

  • New Files
    • lib/users/internal.rb
    • spec/lib/users/internal_spec.rb
    • ee/lib/ee/users/internal.rb
    • ee/spec/lib/ee/users/internal_spec.rb
  • Deleted files
    • app/models/concerns/has_unique_internal_users.rb (moved to private methods in lib/users/internal.rb)
  • Changed files
    • app/models/user.rb (code moved to lib/users/internal.rb)
    • ee/app/models/ee/user.rb (code moved to ee/lib/ee/users/internal.rb)
    • spec/models/user_spec.rb (code moved to spec/lib/users/internal_spec.rb)
    • app/models/concerns/avatarable.rb (bot_avatar is now a private method in lib/users/internal.rb)

All remaining changes are renames.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Brian Williams

Merge request reports