Remove `User.existing_member?`

While resolving a conflict in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7392 today I first saw this method in User:

def existing_member?(email)
  User.where(email: email).any? || Email.where(email: email).any?
end

Apart from the misleading name -- it has nothing to do with group or project membership, but seems to checking membership of the instance -- this would seem to be duplicating functionality we already have in User.by_any_email. It also only exists in EE, so it's creating a CE-EE disparity in app/models/user.rb.

It only seems to be used in one non-spec location:

gitlab-ee ce-to-ee-2018-09-17 % g grep -F 'existing_member?'
app/models/user.rb:369:    def existing_member?(email)
ee/lib/ee/gitlab/checks/change_access.rb:141:            unless ::User.existing_member?(commit.author_email.downcase)
ee/lib/ee/gitlab/checks/change_access.rb:146:              unless ::User.existing_member?(commit.committer_email.downcase)
ee/spec/lib/gitlab/checks/change_access_spec.rb:182:          allow(User).to receive(:existing_member?).and_return(false)
spec/models/user_spec.rb:1682:  describe "#existing_member?" do
spec/models/user_spec.rb:1686:      expect(described_class.existing_member?("bruno@example.com")).to be_truthy
spec/models/user_spec.rb:1692:      expect(described_class.existing_member?("rendom@example.com")).to be_falsey
spec/models/user_spec.rb:1699:      expect(described_class.existing_member?("bruno@example.com")).to be_truthy

Would it make sense to remove this method?

Assignee Loading
Time tracking Loading