Detect duplicate locations for EE specs
Description of the proposal
Resolves #209052 (closed)
Cop that detects duplicate EE spec files
There should not be files in both ee/spec/*/ee/my_spec.rb
and ee/spec/*/my_spec.rb
#
# # bad
# ee/spec/controllers/my_spec.rb # describe MyClass
# ee/spec/controllers/ee/my_spec.rb # describe MyClass
#
# # good, spec for EE extension code
# ee/spec/controllers/ee/my_spec.rb # describe MyClass
#
# # good, spec for EE only code
# ee/spec/controllers/my_spec.rb # describe MyClass
Example
$ be rubocop --only Gitlab/DuplicateSpecLocation ee/spec --parallel
Inspecting 2204 files
................................................................................C.............................C...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C...........................................................................................................................................................................................................................................................................................................................................................................C.........................................................C.............................................................................................................................................................................................................................C.C.............................................................................................................................................................................................................................................................................................C...................................................................................................................................................................................................................................................................................C.............C..C....C..........................................................................................C....................................................................................................................................................................................................................................................
Offenses:
ee/spec/controllers/groups_controller_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/controllers/ee/groups_controller_spec.rb.
describe GroupsController do
^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/controllers/projects/jobs_controller_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/controllers/ee/projects/jobs_controller_spec.rb.
describe Projects::JobsController, :clean_gitlab_redis_shared_state do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/helpers/auth_helper_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/helpers/ee/auth_helper_spec.rb.
describe AuthHelper do
^^^^^^^^^^^^^^^^^^^
ee/spec/lib/gitlab/gl_repository_spec.rb:4:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/lib/ee/gitlab/gl_repository_spec.rb.
describe Gitlab::GlRepository do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/lib/gitlab/usage_data_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/lib/ee/gitlab/usage_data_spec.rb.
describe Gitlab::UsageData do
^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/models/namespace_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/models/ee/namespace_spec.rb.
describe Namespace do
^^^^^^^^^^^^^^^^^^
ee/spec/models/note_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/models/ee/note_spec.rb.
describe Note do
^^^^^^^^^^^^^
ee/spec/serializers/environment_entity_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/serializers/ee/environment_entity_spec.rb.
describe EnvironmentEntity do
^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/issues/create_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/services/ee/issues/create_service_spec.rb.
describe Issues::CreateService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/merge_requests/create_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/services/ee/merge_requests/create_service_spec.rb.
describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/merge_requests/refresh_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/services/ee/merge_requests/refresh_service_spec.rb.
describe MergeRequests::RefreshService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/merge_requests/update_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/services/ee/merge_requests/update_service_spec.rb.
describe MergeRequests::UpdateService, :mailer do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/system_hooks_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in /Users/tkuah/code/ee-gdk/gitlab/ee/spec/services/ee/system_hooks_service_spec.rb.
describe SystemHooksService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/controllers/ee/groups_controller_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/controllers/groups_controller_spec.rb.
describe GroupsController do
^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/controllers/ee/projects/jobs_controller_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/controllers/projects/jobs_controller_spec.rb.
describe Projects::JobsController do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/helpers/ee/auth_helper_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/helpers/auth_helper_spec.rb.
describe EE::AuthHelper do
^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/lib/ee/gitlab/gl_repository_spec.rb:4:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/lib/gitlab/gl_repository_spec.rb.
describe ::EE::Gitlab::GlRepository do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/lib/ee/gitlab/usage_data_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/lib/gitlab/usage_data_spec.rb.
describe Gitlab::UsageData do
^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/models/ee/namespace_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/models/namespace_spec.rb.
describe Namespace do
^^^^^^^^^^^^^^^^^^
ee/spec/models/ee/note_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/models/note_spec.rb.
describe Note do
^^^^^^^^^^^^^
ee/spec/serializers/ee/environment_entity_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/serializers/environment_entity_spec.rb.
describe EnvironmentEntity do
^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/ee/issues/create_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/services/issues/create_service_spec.rb.
describe Issues::CreateService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/ee/merge_requests/create_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/services/merge_requests/create_service_spec.rb.
describe MergeRequests::CreateService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/ee/merge_requests/refresh_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/services/merge_requests/refresh_service_spec.rb.
describe MergeRequests::RefreshService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/ee/merge_requests/update_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/services/merge_requests/update_service_spec.rb.
describe MergeRequests::UpdateService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/ee/system_hooks_service_spec.rb:5:1: C: Gitlab/DuplicateSpecLocation: Duplicate spec location in ee/spec/services/system_hooks_service_spec.rb.
describe EE::SystemHooksService do
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2204 files inspected, 26 offenses detected
Check-list
-
Make sure this MR enables a static analysis check rule for new usage but ignores current offenses -
Mention this proposal in the relevant Slack channels (e.g. #development
,#backend
,#frontend
) - [-] If there is a choice to make between two potential styles, set up an emoji vote in the MR:
- CHOICE_A:
🅰 - CHOICE_B:
🅱 - Vote yourself for both choices so that people know these are the choices
- CHOICE_A:
-
The MR doesn't have significant objections, and is getting a majority of 👍 vs👎 (remember that we don't need to reach a consensus) -
(If applicable) One style is getting a majority of vote (compared to the other choice) -
(If applicable) Update the MR with the chosen style -
Create a follow-up issue to fix the current offenses as a separate iteration: #211887 (closed) -
Follow the review process as usual -
Once approved and merged by a maintainer, mention it again: -
In the relevant Slack channels (e.g. #development
,#backend
,#frontend
) -
(Optional depending on the impact of the change) In the Engineering Week in Review
-
Edited by 🤖 GitLab Bot 🤖