Add RuboCop cops to enforce code reusing rules
What does this MR do?
This adds various RuboCop cops that enforce the rules outlined in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21254.
These cops reuse rules such as not being able to use a Finder in another Finder, or using a Finder in a model class method. Existing offences have been disabled, allowing us to solve them over time.
This MR is quite large due to there being many existing offences, which had to be whitelisted. This is done in separate commits, and so I recommend reviewing the following commits individually:
EE MR: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/7229
What are the relevant issue numbers?
- https://gitlab.com/gitlab-org/gitlab-ce/issues/49653
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21254
TODO
- Service classes
-
Disallow in Finders -
Disallow in Presenters -
Disallow in Serializers -
Disallow in model class methods
-
- Finders
-
Disallow in Finders -
Disallow in model class methods
-
- Presenters
-
Disallow in Service classes -
Disallow in Finders -
Disallow in Presenters -
Disallow in Serializers -
Disallow in Model class methods -
Disallow in Model instance methods -
Disallow in Workers
-
- Serializers
-
Disallow in Service classes -
Disallow in Finders -
Disallow in Presenters -
Disallow in Serializers -
Disallow in Model class methods -
Disallow in Model instance methods -
Disallow in Workers
-
- Active Record
-
Disallow everywhere, except in models
-
- Worker
-
Disallow in Controller -
Disallow in Grape API -
Disallow in Finder -
Disallow in Presenter -
Disallow in Serializer -
Disallow in Model class method
-
-
Set up EE MR -
Whitelist EE specific offenses
Does this MR meet the acceptance criteria?
-
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the style guides
Edited by Yorick Peterse