Add Rubocop to prevent new usages of Default Organization
Some new usages of Organizations::Organization.default_organization showed up.
We do have a cop that flags usages of the "default" trait on Organization factory. This cop does not detect create(:organization, id: Organizations::Organization::DEFAULT_ORGANIZATION_ID).
And we also don't detect use of Organizations::Organization.default_organization
(https://docs.gitlab.com/development/organization/#the-default-organization)
Proposal
- Update docs: We need to highlight that self-managed also doesn't have a guarantee that the Default Organization exist.
- Modify
AvoidCreateDefaultOrganizationcop:- Add a link to the
MSG: https://docs.gitlab.com/development/organization/#the-default-organization
- Add a link to the
- Create new cop
AvoidDefaultOrganization:- This should detect usages of
Organizations::Organization.default_organization - Include a link to https://docs.gitlab.com/development/organization/#the-default-organization
- This should detect usages of
- Create new cop
AvoidConstDefaultOrganizationId- This should detect the usage of
DEFAULT_ORGANIZATION_IDin specs or application code - Include a link to https://docs.gitlab.com/development/organization/#the-default-organization
- This should detect the usage of
Next step would be to refactor the new usages of Organizations::Organization.default_organization. We need to coordinate with the team(s) that are owner of the code that is now using the default organization.
Edited by Rutger Wessels