summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-08-27 17:31:01 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2018-09-11 17:32:00 +0200
commit2039c8280db1646845c33d6c5a74e5f23ca6f4de (patch)
treee2b3cd3012d9711cda7c6afb962ae4228d59521a
parent91c40973dc620430b173ea2df968587d2a708dff (diff)
downloadgitlab-ce-2039c8280db1646845c33d6c5a74e5f23ca6f4de.tar.gz
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of which most are triggered by the CodeReuse/ActiveRecord cop.
-rw-r--r--app/controllers/abuse_reports_controller.rb2
-rw-r--r--app/controllers/admin/abuse_reports_controller.rb2
-rw-r--r--app/controllers/admin/applications_controller.rb4
-rw-r--r--app/controllers/admin/broadcast_messages_controller.rb2
-rw-r--r--app/controllers/admin/dashboard_controller.rb2
-rw-r--r--app/controllers/admin/groups_controller.rb2
-rw-r--r--app/controllers/admin/identities_controller.rb2
-rw-r--r--app/controllers/admin/impersonation_tokens_controller.rb4
-rw-r--r--app/controllers/admin/jobs_controller.rb2
-rw-r--r--app/controllers/admin/keys_controller.rb2
-rw-r--r--app/controllers/admin/projects_controller.rb4
-rw-r--r--app/controllers/admin/runners_controller.rb4
-rw-r--r--app/controllers/admin/services_controller.rb4
-rw-r--r--app/controllers/admin/spam_logs_controller.rb2
-rw-r--r--app/controllers/admin/users_controller.rb2
-rw-r--r--app/controllers/boards/issues_controller.rb2
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor.rb2
-rw-r--r--app/controllers/concerns/creates_commit.rb2
-rw-r--r--app/controllers/concerns/enforces_two_factor_authentication.rb2
-rw-r--r--app/controllers/concerns/group_tree.rb4
-rw-r--r--app/controllers/concerns/issuable_actions.rb2
-rw-r--r--app/controllers/concerns/issuable_collections.rb4
-rw-r--r--app/controllers/concerns/issues_calendar.rb2
-rw-r--r--app/controllers/concerns/members_presentation.rb2
-rw-r--r--app/controllers/concerns/membership_actions.rb2
-rw-r--r--app/controllers/concerns/renders_member_access.rb2
-rw-r--r--app/controllers/concerns/renders_notes.rb4
-rw-r--r--app/controllers/concerns/uploads_actions.rb2
-rw-r--r--app/controllers/dashboard/projects_controller.rb4
-rw-r--r--app/controllers/dashboard/todos_controller.rb2
-rw-r--r--app/controllers/explore/projects_controller.rb4
-rw-r--r--app/controllers/groups_controller.rb6
-rw-r--r--app/controllers/import/base_controller.rb4
-rw-r--r--app/controllers/import/bitbucket_controller.rb2
-rw-r--r--app/controllers/import/bitbucket_server_controller.rb2
-rw-r--r--app/controllers/import/fogbugz_controller.rb2
-rw-r--r--app/controllers/import/github_controller.rb4
-rw-r--r--app/controllers/import/gitlab_controller.rb2
-rw-r--r--app/controllers/import/google_code_controller.rb2
-rw-r--r--app/controllers/import/manifest_controller.rb6
-rw-r--r--app/controllers/instance_statistics/conversational_development_index_controller.rb2
-rw-r--r--app/controllers/passwords_controller.rb2
-rw-r--r--app/controllers/profiles/accounts_controller.rb2
-rw-r--r--app/controllers/profiles/notifications_controller.rb2
-rw-r--r--app/controllers/profiles/personal_access_tokens_controller.rb2
-rw-r--r--app/controllers/profiles_controller.rb2
-rw-r--r--app/controllers/projects/artifacts_controller.rb4
-rw-r--r--app/controllers/projects/blob_controller.rb2
-rw-r--r--app/controllers/projects/branches_controller.rb2
-rw-r--r--app/controllers/projects/build_artifacts_controller.rb4
-rw-r--r--app/controllers/projects/clusters/applications_controller.rb2
-rw-r--r--app/controllers/projects/commit_controller.rb4
-rw-r--r--app/controllers/projects/commits_controller.rb2
-rw-r--r--app/controllers/projects/compare_controller.rb2
-rw-r--r--app/controllers/projects/deploy_keys_controller.rb2
-rw-r--r--app/controllers/projects/deployments_controller.rb4
-rw-r--r--app/controllers/projects/discussions_controller.rb2
-rw-r--r--app/controllers/projects/environments_controller.rb4
-rw-r--r--app/controllers/projects/forks_controller.rb4
-rw-r--r--app/controllers/projects/issues_controller.rb2
-rw-r--r--app/controllers/projects/jobs_controller.rb4
-rw-r--r--app/controllers/projects/labels_controller.rb2
-rw-r--r--app/controllers/projects/lfs_api_controller.rb2
-rw-r--r--app/controllers/projects/lfs_storage_controller.rb4
-rw-r--r--app/controllers/projects/merge_requests/application_controller.rb2
-rw-r--r--app/controllers/projects/merge_requests/creations_controller.rb2
-rw-r--r--app/controllers/projects/merge_requests/diffs_controller.rb4
-rw-r--r--app/controllers/projects/milestones_controller.rb2
-rw-r--r--app/controllers/projects/pages_controller.rb2
-rw-r--r--app/controllers/projects/pages_domains_controller.rb2
-rw-r--r--app/controllers/projects/pipeline_schedules_controller.rb2
-rw-r--r--app/controllers/projects/pipelines_controller.rb2
-rw-r--r--app/controllers/projects/project_members_controller.rb2
-rw-r--r--app/controllers/projects/releases_controller.rb2
-rw-r--r--app/controllers/projects/settings/repository_controller.rb2
-rw-r--r--app/controllers/projects/tags_controller.rb4
-rw-r--r--app/controllers/projects_controller.rb8
-rw-r--r--app/controllers/search_controller.rb2
-rw-r--r--app/controllers/sessions_controller.rb2
-rw-r--r--app/controllers/snippets/notes_controller.rb2
-rw-r--r--app/controllers/snippets_controller.rb4
-rw-r--r--app/controllers/user_callouts_controller.rb2
-rw-r--r--app/finders/admin/projects_finder.rb6
-rw-r--r--app/finders/autocomplete/users_finder.rb4
-rw-r--r--app/finders/concerns/custom_attributes_filter.rb2
-rw-r--r--app/finders/concerns/finder_methods.rb4
-rw-r--r--app/finders/concerns/finder_with_cross_project_access.rb2
-rw-r--r--app/finders/contributed_projects_finder.rb2
-rw-r--r--app/finders/environments_finder.rb2
-rw-r--r--app/finders/events_finder.rb12
-rw-r--r--app/finders/fork_projects_finder.rb2
-rw-r--r--app/finders/group_descendants_finder.rb20
-rw-r--r--app/finders/group_finder.rb2
-rw-r--r--app/finders/group_members_finder.rb2
-rw-r--r--app/finders/group_projects_finder.rb2
-rw-r--r--app/finders/groups_finder.rb8
-rw-r--r--app/finders/issuable_finder.rb38
-rw-r--r--app/finders/issues_finder.rb6
-rw-r--r--app/finders/labels_finder.rb12
-rw-r--r--app/finders/members_finder.rb4
-rw-r--r--app/finders/merge_request_target_project_finder.rb2
-rw-r--r--app/finders/merge_requests_finder.rb4
-rw-r--r--app/finders/milestones_finder.rb6
-rw-r--r--app/finders/notes_finder.rb12
-rw-r--r--app/finders/personal_access_tokens_finder.rb2
-rw-r--r--app/finders/personal_projects_finder.rb2
-rw-r--r--app/finders/pipeline_schedules_finder.rb2
-rw-r--r--app/finders/pipelines_finder.rb20
-rw-r--r--app/finders/projects_finder.rb10
-rw-r--r--app/finders/runner_jobs_finder.rb2
-rw-r--r--app/finders/snippets_finder.rb10
-rw-r--r--app/finders/template_finder.rb2
-rw-r--r--app/finders/todos_finder.rb12
-rw-r--r--app/finders/union_finder.rb2
-rw-r--r--app/finders/user_finder.rb2
-rw-r--r--app/finders/user_recent_events_finder.rb6
-rw-r--r--app/finders/users_finder.rb6
-rw-r--r--app/graphql/resolvers/merge_request_resolver.rb2
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/helpers/auth_helper.rb2
-rw-r--r--app/helpers/auto_devops_helper.rb2
-rw-r--r--app/helpers/diff_helper.rb2
-rw-r--r--app/helpers/environment_helper.rb2
-rw-r--r--app/helpers/issuables_helper.rb8
-rw-r--r--app/helpers/milestones_helper.rb2
-rw-r--r--app/helpers/namespaces_helper.rb4
-rw-r--r--app/helpers/numbers_helper.rb2
-rw-r--r--app/helpers/projects_helper.rb2
-rw-r--r--app/helpers/safe_params_helper.rb2
-rw-r--r--app/helpers/search_helper.rb4
-rw-r--r--app/helpers/tree_helper.rb4
-rw-r--r--app/mailers/emails/issues.rb2
-rw-r--r--app/mailers/emails/merge_requests.rb2
-rw-r--r--app/mailers/emails/profile.rb4
-rw-r--r--app/mailers/repository_check_mailer.rb2
-rw-r--r--app/models/ci/build.rb6
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/models/commit_status.rb4
-rw-r--r--app/models/container_repository.rb2
-rw-r--r--app/models/dashboard_group_milestone.rb2
-rw-r--r--app/models/environment.rb2
-rw-r--r--app/models/global_milestone.rb6
-rw-r--r--app/models/group.rb4
-rw-r--r--app/models/hooks/service_hook.rb2
-rw-r--r--app/models/hooks/web_hook.rb4
-rw-r--r--app/models/issue.rb4
-rw-r--r--app/models/key.rb8
-rw-r--r--app/models/member.rb10
-rw-r--r--app/models/members/project_member.rb2
-rw-r--r--app/models/merge_request.rb12
-rw-r--r--app/models/merge_request_diff.rb2
-rw-r--r--app/models/note.rb2
-rw-r--r--app/models/pages_domain.rb2
-rw-r--r--app/models/project.rb20
-rw-r--r--app/models/project_import_state.rb2
-rw-r--r--app/models/project_services/slash_commands_service.rb4
-rw-r--r--app/models/user.rb24
-rw-r--r--app/policies/application_setting/term_policy.rb2
-rw-r--r--app/policies/ci/runner_policy.rb2
-rw-r--r--app/policies/deploy_key_policy.rb2
-rw-r--r--app/policies/project_policy.rb2
-rw-r--r--app/presenters/conversational_development_index/metric_presenter.rb2
-rw-r--r--app/presenters/merge_request_presenter.rb4
-rw-r--r--app/presenters/project_presenter.rb2
-rw-r--r--app/presenters/projects/settings/deploy_keys_presenter.rb8
-rw-r--r--app/serializers/commit_entity.rb2
-rw-r--r--app/serializers/diffs_entity.rb4
-rw-r--r--app/serializers/environment_serializer.rb2
-rw-r--r--app/serializers/group_child_entity.rb2
-rw-r--r--app/serializers/group_entity.rb2
-rw-r--r--app/serializers/merge_request_widget_entity.rb2
-rw-r--r--app/serializers/pipeline_serializer.rb2
-rw-r--r--app/services/applications/create_service.rb2
-rw-r--r--app/services/boards/issues/list_service.rb12
-rw-r--r--app/services/boards/issues/move_service.rb6
-rw-r--r--app/services/boards/lists/destroy_service.rb2
-rw-r--r--app/services/boards/lists/move_service.rb4
-rw-r--r--app/services/chat_names/find_user_service.rb2
-rw-r--r--app/services/ci/compare_test_reports_service.rb2
-rw-r--r--app/services/ci/create_pipeline_service.rb4
-rw-r--r--app/services/ci/ensure_stage_service.rb2
-rw-r--r--app/services/ci/extract_sections_from_build_trace_service.rb2
-rw-r--r--app/services/ci/process_pipeline_service.rb8
-rw-r--r--app/services/ci/register_job_service.rb12
-rw-r--r--app/services/ci/retry_build_service.rb2
-rw-r--r--app/services/cohorts_service.rb2
-rw-r--r--app/services/concerns/issues/resolve_discussions.rb2
-rw-r--r--app/services/create_release_service.rb2
-rw-r--r--app/services/delete_merged_branches_service.rb2
-rw-r--r--app/services/git_push_service.rb2
-rw-r--r--app/services/groups/destroy_service.rb2
-rw-r--r--app/services/groups/transfer_service.rb4
-rw-r--r--app/services/import_export_clean_up_service.rb2
-rw-r--r--app/services/issuable/bulk_update_service.rb2
-rw-r--r--app/services/issuable_base_service.rb4
-rw-r--r--app/services/issues/base_service.rb2
-rw-r--r--app/services/issues/move_service.rb4
-rw-r--r--app/services/issues/referenced_merge_requests_service.rb6
-rw-r--r--app/services/issues/update_service.rb4
-rw-r--r--app/services/labels/find_or_create_service.rb2
-rw-r--r--app/services/labels/promote_service.rb16
-rw-r--r--app/services/labels/transfer_service.rb10
-rw-r--r--app/services/lfs/file_transformer.rb2
-rw-r--r--app/services/lfs/lock_file_service.rb2
-rw-r--r--app/services/lfs/locks_finder_service.rb2
-rw-r--r--app/services/lfs/unlock_file_service.rb2
-rw-r--r--app/services/merge_requests/base_service.rb2
-rw-r--r--app/services/merge_requests/create_from_issue_service.rb2
-rw-r--r--app/services/merge_requests/create_service.rb2
-rw-r--r--app/services/merge_requests/delete_non_latest_diffs_service.rb2
-rw-r--r--app/services/merge_requests/refresh_service.rb6
-rw-r--r--app/services/merge_requests/reload_diffs_service.rb2
-rw-r--r--app/services/milestones/promote_service.rb8
-rw-r--r--app/services/milestones/update_service.rb2
-rw-r--r--app/services/notification_recipient_service.rb18
-rw-r--r--app/services/projects/auto_devops/disable_service.rb2
-rw-r--r--app/services/projects/base_move_relations_service.rb2
-rw-r--r--app/services/projects/batch_forks_count_service.rb2
-rw-r--r--app/services/projects/batch_open_issues_count_service.rb2
-rw-r--r--app/services/projects/create_service.rb6
-rw-r--r--app/services/projects/destroy_service.rb4
-rw-r--r--app/services/projects/detect_repository_languages_service.rb6
-rw-r--r--app/services/projects/enable_deploy_key_service.rb2
-rw-r--r--app/services/projects/forks_count_service.rb2
-rw-r--r--app/services/projects/gitlab_projects_import_service.rb2
-rw-r--r--app/services/projects/hashed_storage/migrate_repository_service.rb4
-rw-r--r--app/services/projects/lfs_pointers/lfs_download_service.rb2
-rw-r--r--app/services/projects/lfs_pointers/lfs_import_service.rb2
-rw-r--r--app/services/projects/lfs_pointers/lfs_link_service.rb2
-rw-r--r--app/services/projects/move_deploy_keys_projects_service.rb2
-rw-r--r--app/services/projects/move_forks_service.rb6
-rw-r--r--app/services/projects/move_lfs_objects_projects_service.rb2
-rw-r--r--app/services/projects/move_notification_settings_service.rb2
-rw-r--r--app/services/projects/move_project_authorizations_service.rb2
-rw-r--r--app/services/projects/move_project_group_links_service.rb2
-rw-r--r--app/services/projects/move_project_members_service.rb2
-rw-r--r--app/services/projects/open_issues_count_service.rb4
-rw-r--r--app/services/projects/propagate_service_template.rb4
-rw-r--r--app/services/projects/transfer_service.rb2
-rw-r--r--app/services/projects/unlink_fork_service.rb2
-rw-r--r--app/services/projects/update_service.rb2
-rw-r--r--app/services/quick_actions/interpret_service.rb12
-rw-r--r--app/services/quick_actions/target_service.rb4
-rw-r--r--app/services/resource_events/merge_into_notes_service.rb2
-rw-r--r--app/services/search/group_service.rb2
-rw-r--r--app/services/search_service.rb4
-rw-r--r--app/services/spam_check_service.rb2
-rw-r--r--app/services/system_note_service.rb2
-rw-r--r--app/services/tags/destroy_service.rb2
-rw-r--r--app/services/todo_service.rb10
-rw-r--r--app/services/todos/destroy/base_service.rb4
-rw-r--r--app/services/todos/destroy/confidential_issue_service.rb6
-rw-r--r--app/services/todos/destroy/entity_leave_service.rb18
-rw-r--r--app/services/todos/destroy/group_private_service.rb4
-rw-r--r--app/services/todos/destroy/private_features_service.rb4
-rw-r--r--app/services/todos/destroy/project_private_service.rb4
-rw-r--r--app/services/update_release_service.rb2
-rw-r--r--app/services/users/last_push_event_service.rb2
-rw-r--r--app/services/users/migrate_to_ghost_user_service.rb4
-rw-r--r--app/services/users/respond_to_terms_service.rb2
-rw-r--r--app/uploaders/records_uploads.rb6
-rw-r--r--app/validators/variable_duplicates_validator.rb2
-rw-r--r--app/views/admin/users/projects.html.haml2
-rw-r--r--app/views/dashboard/issues.atom.builder2
-rw-r--r--app/views/doorkeeper/applications/index.html.haml2
-rw-r--r--app/views/groups/issues.atom.builder2
-rw-r--r--app/views/issues/_issues_calendar.ics.ruby2
-rw-r--r--app/views/projects/diffs/_stats.html.haml4
-rw-r--r--app/views/projects/issues/index.atom.builder2
-rw-r--r--app/views/projects/jobs/index.html.haml2
-rw-r--r--app/views/projects/runners/_runner.html.haml2
-rw-r--r--app/views/shared/issuable/_assignees.html.haml2
-rw-r--r--app/views/shared/members/_access_request_buttons.html.haml4
-rw-r--r--app/workers/admin_email_worker.rb2
-rw-r--r--app/workers/archive_trace_worker.rb2
-rw-r--r--app/workers/authorized_projects_worker.rb2
-rw-r--r--app/workers/build_coverage_worker.rb2
-rw-r--r--app/workers/build_finished_worker.rb2
-rw-r--r--app/workers/build_hooks_worker.rb2
-rw-r--r--app/workers/build_queue_worker.rb2
-rw-r--r--app/workers/build_success_worker.rb2
-rw-r--r--app/workers/build_trace_sections_worker.rb2
-rw-r--r--app/workers/ci/archive_traces_cron_worker.rb2
-rw-r--r--app/workers/ci/build_trace_chunk_flush_worker.rb2
-rw-r--r--app/workers/concerns/gitlab/github_import/rescheduling_methods.rb2
-rw-r--r--app/workers/concerns/gitlab/github_import/stage_methods.rb2
-rw-r--r--app/workers/concerns/new_issuable.rb4
-rw-r--r--app/workers/create_gpg_signature_worker.rb2
-rw-r--r--app/workers/delete_container_repository_worker.rb2
-rw-r--r--app/workers/delete_diff_files_worker.rb2
-rw-r--r--app/workers/detect_repository_languages_worker.rb2
-rw-r--r--app/workers/expire_build_artifacts_worker.rb2
-rw-r--r--app/workers/expire_build_instance_artifacts_worker.rb2
-rw-r--r--app/workers/expire_job_cache_worker.rb2
-rw-r--r--app/workers/expire_pipeline_cache_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/advance_stage_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/refresh_import_jid_worker.rb2
-rw-r--r--app/workers/invalid_gpg_signature_update_worker.rb2
-rw-r--r--app/workers/issue_due_scheduler_worker.rb2
-rw-r--r--app/workers/mail_scheduler/issue_due_worker.rb2
-rw-r--r--app/workers/new_note_worker.rb2
-rw-r--r--app/workers/object_storage/migrate_uploads_worker.rb4
-rw-r--r--app/workers/pages_domain_verification_worker.rb2
-rw-r--r--app/workers/pages_worker.rb2
-rw-r--r--app/workers/pipeline_hooks_worker.rb2
-rw-r--r--app/workers/pipeline_metrics_worker.rb4
-rw-r--r--app/workers/pipeline_notification_worker.rb2
-rw-r--r--app/workers/pipeline_process_worker.rb2
-rw-r--r--app/workers/pipeline_schedule_worker.rb2
-rw-r--r--app/workers/pipeline_success_worker.rb2
-rw-r--r--app/workers/pipeline_update_worker.rb2
-rw-r--r--app/workers/process_commit_worker.rb4
-rw-r--r--app/workers/project_cache_worker.rb2
-rw-r--r--app/workers/project_migrate_hashed_storage_worker.rb2
-rw-r--r--app/workers/propagate_service_template_worker.rb2
-rw-r--r--app/workers/prune_old_events_worker.rb2
-rw-r--r--app/workers/prune_web_hook_logs_worker.rb2
-rw-r--r--app/workers/reactive_caching_worker.rb2
-rw-r--r--app/workers/repository_check/batch_worker.rb6
-rw-r--r--app/workers/repository_check/clear_worker.rb2
-rw-r--r--app/workers/repository_check/single_repository_worker.rb2
-rw-r--r--app/workers/run_pipeline_schedule_worker.rb2
-rw-r--r--app/workers/stage_update_worker.rb2
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb2
-rw-r--r--app/workers/stuck_import_jobs_worker.rb8
-rw-r--r--app/workers/stuck_merge_jobs_worker.rb6
-rw-r--r--app/workers/update_head_pipeline_for_merge_request_worker.rb2
-rw-r--r--app/workers/update_merge_requests_worker.rb2
-rw-r--r--lib/api/access_requests.rb6
-rw-r--r--lib/api/award_emoji.rb2
-rw-r--r--lib/api/boards_responses.rb2
-rw-r--r--lib/api/branches.rb4
-rw-r--r--lib/api/commit_statuses.rb4
-rw-r--r--lib/api/commits.rb2
-rw-r--r--lib/api/custom_attributes_endpoints.rb6
-rw-r--r--lib/api/deploy_keys.rb8
-rw-r--r--lib/api/deployments.rb2
-rw-r--r--lib/api/discussions.rb4
-rw-r--r--lib/api/entities.rb14
-rw-r--r--lib/api/events.rb8
-rw-r--r--lib/api/features.rb2
-rw-r--r--lib/api/group_variables.rb6
-rw-r--r--lib/api/groups.rb2
-rw-r--r--lib/api/helpers.rb18
-rw-r--r--lib/api/helpers/custom_attributes.rb2
-rw-r--r--lib/api/helpers/members_helpers.rb4
-rw-r--r--lib/api/helpers/pagination.rb4
-rw-r--r--lib/api/internal.rb10
-rw-r--r--lib/api/issues.rb10
-rw-r--r--lib/api/job_artifacts.rb2
-rw-r--r--lib/api/jobs.rb6
-rw-r--r--lib/api/labels.rb6
-rw-r--r--lib/api/members.rb12
-rw-r--r--lib/api/merge_requests.rb2
-rw-r--r--lib/api/notes.rb2
-rw-r--r--lib/api/pages_domains.rb4
-rw-r--r--lib/api/pipeline_schedules.rb6
-rw-r--r--lib/api/pipelines.rb2
-rw-r--r--lib/api/project_snippets.rb8
-rw-r--r--lib/api/projects.rb4
-rw-r--r--lib/api/protected_branches.rb8
-rw-r--r--lib/api/protected_tags.rb6
-rw-r--r--lib/api/resource_label_events.rb3
-rw-r--r--lib/api/runner.rb2
-rw-r--r--lib/api/runners.rb2
-rw-r--r--lib/api/services.rb2
-rw-r--r--lib/api/snippets.rb8
-rw-r--r--lib/api/system_hooks.rb2
-rw-r--r--lib/api/triggers.rb2
-rw-r--r--lib/api/users.rb56
-rw-r--r--lib/api/variables.rb6
-rw-r--r--lib/container_registry/path.rb4
-rw-r--r--lib/container_registry/tag.rb2
-rw-r--r--lib/event_filter.rb2
-rw-r--r--lib/file_size_validator.rb2
-rw-r--r--lib/gitlab/auth.rb6
-rw-r--r--lib/gitlab/auth/ldap/user.rb2
-rw-r--r--lib/gitlab/auth/o_auth/user.rb4
-rw-r--r--lib/gitlab/auth/omniauth_identity_linker_base.rb2
-rw-r--r--lib/gitlab/auth/user_auth_finders.rb2
-rw-r--r--lib/gitlab/badge/coverage/report.rb2
-rw-r--r--lib/gitlab/badge/pipeline/status.rb2
-rw-r--r--lib/gitlab/bitbucket_import/importer.rb4
-rw-r--r--lib/gitlab/bitbucket_server_import/importer.rb2
-rw-r--r--lib/gitlab/checks/commit_check.rb2
-rw-r--r--lib/gitlab/checks/lfs_integrity.rb2
-rw-r--r--lib/gitlab/checks/matching_merge_request.rb2
-rw-r--r--lib/gitlab/ci/build/artifacts/metadata/entry.rb2
-rw-r--r--lib/gitlab/ci/charts.rb6
-rw-r--r--lib/gitlab/ci/config/entry/configurable.rb4
-rw-r--r--lib/gitlab/ci/config/entry/global.rb2
-rw-r--r--lib/gitlab/ci/config/entry/jobs.rb2
-rw-r--r--lib/gitlab/ci/pipeline/chain/create.rb2
-rw-r--r--lib/gitlab/ci/pipeline/duration.rb4
-rw-r--r--lib/gitlab/ci/reports/test_reports.rb6
-rw-r--r--lib/gitlab/ci/reports/test_reports_comparer.rb2
-rw-r--r--lib/gitlab/ci/reports/test_suite.rb2
-rw-r--r--lib/gitlab/ci/trace/chunked_io.rb8
-rw-r--r--lib/gitlab/cleanup/project_uploads.rb6
-rw-r--r--lib/gitlab/cleanup/remote_uploads.rb2
-rw-r--r--lib/gitlab/contributions_calendar.rb6
-rw-r--r--lib/gitlab/diff/file.rb4
-rw-r--r--lib/gitlab/diff/inline_diff.rb2
-rw-r--r--lib/gitlab/email/handler/create_issue_handler.rb2
-rw-r--r--lib/gitlab/email/handler/create_merge_request_handler.rb2
-rw-r--r--lib/gitlab/fogbugz_import/importer.rb4
-rw-r--r--lib/gitlab/git/storage/health.rb2
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb2
-rw-r--r--lib/gitlab/github_import/importer/labels_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/milestones_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/releases_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/repository_importer.rb2
-rw-r--r--lib/gitlab/github_import/label_finder.rb2
-rw-r--r--lib/gitlab/github_import/milestone_finder.rb2
-rw-r--r--lib/gitlab/github_import/user_finder.rb4
-rw-r--r--lib/gitlab/gitlab_import/importer.rb2
-rw-r--r--lib/gitlab/gl_repository.rb2
-rw-r--r--lib/gitlab/google_code_import/importer.rb2
-rw-r--r--lib/gitlab/gpg/commit.rb4
-rw-r--r--lib/gitlab/gpg/invalid_gpg_signature_updater.rb2
-rw-r--r--lib/gitlab/graphql/connections/keyset_connection.rb4
-rw-r--r--lib/gitlab/group_hierarchy.rb10
-rw-r--r--lib/gitlab/hashed_storage/migrator.rb4
-rw-r--r--lib/gitlab/hashed_storage/rake_helper.rb8
-rw-r--r--lib/gitlab/health_checks/redis/cache_check.rb2
-rw-r--r--lib/gitlab/health_checks/redis/queues_check.rb2
-rw-r--r--lib/gitlab/health_checks/redis/shared_state_check.rb2
-rw-r--r--lib/gitlab/identifier.rb2
-rw-r--r--lib/gitlab/import/database_helpers.rb2
-rw-r--r--lib/gitlab/import/merge_request_helpers.rb4
-rw-r--r--lib/gitlab/legacy_github_import/base_formatter.rb2
-rw-r--r--lib/gitlab/legacy_github_import/importer.rb6
-rw-r--r--lib/gitlab/legacy_github_import/issuable_formatter.rb2
-rw-r--r--lib/gitlab/legacy_github_import/label_formatter.rb2
-rw-r--r--lib/gitlab/legacy_github_import/user_formatter.rb2
-rw-r--r--lib/gitlab/multi_collection_paginator.rb2
-rw-r--r--lib/gitlab/otp_key_rotator.rb4
-rw-r--r--lib/gitlab/performance_bar.rb2
-rw-r--r--lib/gitlab/profiler.rb4
-rw-r--r--lib/gitlab/project_search_results.rb4
-rw-r--r--lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb2
-rw-r--r--lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb2
-rw-r--r--lib/gitlab/prometheus/queries/deployment_query.rb2
-rw-r--r--lib/gitlab/prometheus/queries/environment_query.rb2
-rw-r--r--lib/gitlab/search_results.rb16
-rw-r--r--lib/gitlab/shell.rb4
-rw-r--r--lib/gitlab/slash_commands/base_command.rb2
-rw-r--r--lib/gitlab/slash_commands/deploy.rb2
-rw-r--r--lib/gitlab/slash_commands/issue_search.rb2
-rw-r--r--lib/gitlab/snippet_search_results.rb4
-rw-r--r--lib/gitlab/string_regex_marker.rb2
-rw-r--r--lib/gitlab/usage_data.rb4
-rw-r--r--lib/gitlab/user_extractor.rb2
-rw-r--r--lib/gitlab/verify/uploads.rb2
454 files changed, 1683 insertions, 32 deletions
diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb
index ed13ead63f9..51547ed7eaf 100644
--- a/app/controllers/abuse_reports_controller.rb
+++ b/app/controllers/abuse_reports_controller.rb
@@ -30,6 +30,7 @@ class AbuseReportsController < ApplicationController
))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def set_user
@user = User.find_by(id: params[:user_id])
@@ -39,4 +40,5 @@ class AbuseReportsController < ApplicationController
redirect_to @user, alert: "Cannot create the abuse report. This user has been blocked."
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/admin/abuse_reports_controller.rb b/app/controllers/admin/abuse_reports_controller.rb
index dc9a6df5f75..68a49f0749f 100644
--- a/app/controllers/admin/abuse_reports_controller.rb
+++ b/app/controllers/admin/abuse_reports_controller.rb
@@ -1,8 +1,10 @@
class Admin::AbuseReportsController < Admin::ApplicationController
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@abuse_reports = AbuseReport.order(id: :desc).page(params[:page])
@abuse_reports.includes(:reporter, :user)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def destroy
abuse_report = AbuseReport.find(params[:id])
diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb
index 5be23c76a95..daa21d1be93 100644
--- a/app/controllers/admin/applications_controller.rb
+++ b/app/controllers/admin/applications_controller.rb
@@ -4,9 +4,11 @@ class Admin::ApplicationsController < Admin::ApplicationController
before_action :set_application, only: [:show, :edit, :update, :destroy]
before_action :load_scopes, only: [:new, :create, :edit, :update]
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@applications = Doorkeeper::Application.where("owner_id IS NULL")
end
+ # rubocop: enable CodeReuse/ActiveRecord
def show
end
@@ -45,9 +47,11 @@ class Admin::ApplicationsController < Admin::ApplicationController
private
+ # rubocop: disable CodeReuse/ActiveRecord
def set_application
@application = Doorkeeper::Application.where("owner_id IS NULL").find(params[:id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Only allow a trusted parameter "white list" through.
def application_params
diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb
index a9109a1d4d0..b2fbbfc3e64 100644
--- a/app/controllers/admin/broadcast_messages_controller.rb
+++ b/app/controllers/admin/broadcast_messages_controller.rb
@@ -3,10 +3,12 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
before_action :finder, only: [:edit, :update, :destroy]
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@broadcast_messages = BroadcastMessage.order(ends_at: :desc).page(params[:page])
@broadcast_message = BroadcastMessage.new
end
+ # rubocop: enable CodeReuse/ActiveRecord
def edit
end
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
index 737942f3eb2..5dc3e6c2990 100644
--- a/app/controllers/admin/dashboard_controller.rb
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -4,10 +4,12 @@ class Admin::DashboardController < Admin::ApplicationController
COUNTED_ITEMS = [Project, User, Group, ForkedProjectLink, Issue, MergeRequest,
Note, Snippet, Key, Milestone].freeze
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@counts = Gitlab::Database::Count.approximate_counts(COUNTED_ITEMS)
@projects = Project.order_id_desc.without_deleted.with_route.limit(10)
@users = User.order_id_desc.limit(10)
@groups = Group.order_id_desc.with_route.limit(10)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb
index d7a5b745d3f..2a47f01c6ad 100644
--- a/app/controllers/admin/groups_controller.rb
+++ b/app/controllers/admin/groups_controller.rb
@@ -10,6 +10,7 @@ class Admin::GroupsController < Admin::ApplicationController
@groups = @groups.page(params[:page])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def show
@group = Group.with_statistics.joins(:route).group('routes.path').find_by_full_path(params[:id])
@members = present_members(
@@ -18,6 +19,7 @@ class Admin::GroupsController < Admin::ApplicationController
AccessRequestsFinder.new(@group).execute(current_user))
@projects = @group.projects.with_statistics.page(params[:projects_page])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def new
@group = Group.new
diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb
index ceb45865804..57ad7389a23 100644
--- a/app/controllers/admin/identities_controller.rb
+++ b/app/controllers/admin/identities_controller.rb
@@ -44,9 +44,11 @@ class Admin::IdentitiesController < Admin::ApplicationController
protected
+ # rubocop: disable CodeReuse/ActiveRecord
def user
@user ||= User.find_by!(username: params[:user_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def identity
@identity ||= user.identities.find(params[:id])
diff --git a/app/controllers/admin/impersonation_tokens_controller.rb b/app/controllers/admin/impersonation_tokens_controller.rb
index a7b562b1d8e..9ebba88ef16 100644
--- a/app/controllers/admin/impersonation_tokens_controller.rb
+++ b/app/controllers/admin/impersonation_tokens_controller.rb
@@ -30,9 +30,11 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
private
+ # rubocop: disable CodeReuse/ActiveRecord
def user
@user ||= User.find_by!(username: params[:user_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def finder(options = {})
PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
@@ -42,6 +44,7 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
params.require(:personal_access_token).permit(:name, :expires_at, :impersonation, scopes: [])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def set_index_vars
@scopes = Gitlab::Auth.available_scopes(current_user)
@@ -49,4 +52,5 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
@inactive_impersonation_tokens = finder(state: 'inactive').execute
@active_impersonation_tokens = finder(state: 'active').execute.order(:expires_at)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/admin/jobs_controller.rb b/app/controllers/admin/jobs_controller.rb
index e355d5fdea7..788693c62c4 100644
--- a/app/controllers/admin/jobs_controller.rb
+++ b/app/controllers/admin/jobs_controller.rb
@@ -1,4 +1,5 @@
class Admin::JobsController < Admin::ApplicationController
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@scope = params[:scope]
@all_builds = Ci::Build
@@ -16,6 +17,7 @@ class Admin::JobsController < Admin::ApplicationController
end
@builds = @builds.page(params[:page]).per(30)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def cancel_all
Ci::Build.running_or_pending.each(&:cancel)
diff --git a/app/controllers/admin/keys_controller.rb b/app/controllers/admin/keys_controller.rb
index 0b76193a90e..0400a3b2f3b 100644
--- a/app/controllers/admin/keys_controller.rb
+++ b/app/controllers/admin/keys_controller.rb
@@ -24,9 +24,11 @@ class Admin::KeysController < Admin::ApplicationController
protected
+ # rubocop: disable CodeReuse/ActiveRecord
def user
@user ||= User.find_by!(username: params[:user_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def key_params
params.require(:user_id, :id)
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index 3afe66c3566..5cb08c9787b 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -19,6 +19,7 @@ class Admin::ProjectsController < Admin::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def show
if @group
@group_members = present_members(
@@ -30,7 +31,9 @@ class Admin::ProjectsController < Admin::ApplicationController
@requesters = present_members(
AccessRequestsFinder.new(@project).execute(current_user))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def transfer
namespace = Namespace.find_by(id: params[:new_namespace_id])
::Projects::TransferService.new(@project, current_user, params.dup).execute(namespace)
@@ -38,6 +41,7 @@ class Admin::ProjectsController < Admin::ApplicationController
@project.reload
redirect_to admin_project_path(@project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def repository_check
RepositoryCheck::SingleRepositoryWorker.perform_async(@project.id)
diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb
index 6c76c55a9d4..090149fc1e2 100644
--- a/app/controllers/admin/runners_controller.rb
+++ b/app/controllers/admin/runners_controller.rb
@@ -1,6 +1,7 @@
class Admin::RunnersController < Admin::ApplicationController
before_action :runner, except: :index
+ # rubocop: disable CodeReuse/ActiveRecord
def index
sort = params[:sort] == 'contacted_asc' ? { contacted_at: :asc } : { id: :desc }
@runners = Ci::Runner.order(sort)
@@ -8,6 +9,7 @@ class Admin::RunnersController < Admin::ApplicationController
@runners = @runners.page(params[:page]).per(30)
@active_runners_cnt = Ci::Runner.online.count
end
+ # rubocop: enable CodeReuse/ActiveRecord
def show
assign_builds_and_projects
@@ -57,6 +59,7 @@ class Admin::RunnersController < Admin::ApplicationController
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def assign_builds_and_projects
@builds = runner.builds.order('id DESC').first(30)
@projects =
@@ -69,4 +72,5 @@ class Admin::RunnersController < Admin::ApplicationController
@projects = @projects.where.not(id: runner.projects.select(:id)) if runner.projects.any?
@projects = @projects.page(params[:page]).per(30)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb
index 91a36af34f3..c455930c044 100644
--- a/app/controllers/admin/services_controller.rb
+++ b/app/controllers/admin/services_controller.rb
@@ -30,16 +30,20 @@ class Admin::ServicesController < Admin::ApplicationController
private
+ # rubocop: disable CodeReuse/ActiveRecord
def services_templates
Service.available_services_names.map do |service_name|
service_template = "#{service_name}_service".camelize.constantize
service_template.where(template: true).first_or_create
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def service
@service ||= Service.where(id: params[:id], template: true).first
end
+ # rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42430')
diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb
index d52d67a67a5..8df35d25303 100644
--- a/app/controllers/admin/spam_logs_controller.rb
+++ b/app/controllers/admin/spam_logs_controller.rb
@@ -1,7 +1,9 @@
class Admin::SpamLogsController < Admin::ApplicationController
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@spam_logs = SpamLog.order(id: :desc).page(params[:page])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def destroy
spam_log = SpamLog.find(params[:id])
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index a51a8c3ed4a..85bdc85c55b 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -174,9 +174,11 @@ class Admin::UsersController < Admin::ApplicationController
user == current_user
end
+ # rubocop: disable CodeReuse/ActiveRecord
def user
@user ||= User.find_by!(username: params[:id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def redirect_back_or_admin_user(options = {})
redirect_back_or_default(default: default_route, options: options)
diff --git a/app/controllers/boards/issues_controller.rb b/app/controllers/boards/issues_controller.rb
index 7dd19f87ef5..071906f1e91 100644
--- a/app/controllers/boards/issues_controller.rb
+++ b/app/controllers/boards/issues_controller.rb
@@ -11,6 +11,7 @@ module Boards
before_action :authorize_update_issue, only: [:update]
skip_before_action :authenticate_user!, only: [:index]
+ # rubocop: disable CodeReuse/ActiveRecord
def index
list_service = Boards::Issues::ListService.new(board_parent, current_user, filter_params)
issues = list_service.execute
@@ -25,6 +26,7 @@ module Boards
render_issues(issues, list_service.metadata)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create
service = Boards::Issues::CreateService.new(board_parent, project, current_user, issue_params)
diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb
index dfa1da7872c..961f121548b 100644
--- a/app/controllers/concerns/authenticates_with_two_factor.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor.rb
@@ -88,6 +88,7 @@ module AuthenticatesWithTwoFactor
# Setup in preparation of communication with a U2F (universal 2nd factor) device
# Actual communication is performed using a Javascript API
+ # rubocop: disable CodeReuse/ActiveRecord
def setup_u2f_authentication(user)
key_handles = user.u2f_registrations.pluck(:key_handle)
u2f = U2F::U2F.new(u2f_app_id)
@@ -99,4 +100,5 @@ module AuthenticatesWithTwoFactor
sign_requests: sign_requests })
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb
index b26a76d2b62..709c8aaf337 100644
--- a/app/controllers/concerns/creates_commit.rb
+++ b/app/controllers/concerns/creates_commit.rb
@@ -99,6 +99,7 @@ module CreatesCommit
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_request_exists?
strong_memoize(:merge_request) do
MergeRequestsFinder.new(current_user, project_id: @project.id)
@@ -110,6 +111,7 @@ module CreatesCommit
target_branch: @start_branch)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def different_project?
diff --git a/app/controllers/concerns/enforces_two_factor_authentication.rb b/app/controllers/concerns/enforces_two_factor_authentication.rb
index 997af4ab9e9..69e5cbed343 100644
--- a/app/controllers/concerns/enforces_two_factor_authentication.rb
+++ b/app/controllers/concerns/enforces_two_factor_authentication.rb
@@ -24,6 +24,7 @@ module EnforcesTwoFactorAuthentication
current_user.try(:require_two_factor_authentication_from_group?)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def two_factor_authentication_reason(global: -> {}, group: -> {})
if two_factor_authentication_required?
if Gitlab::CurrentSettings.require_two_factor_authentication?
@@ -34,6 +35,7 @@ module EnforcesTwoFactorAuthentication
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def two_factor_grace_period
periods = [Gitlab::CurrentSettings.two_factor_grace_period]
diff --git a/app/controllers/concerns/group_tree.rb b/app/controllers/concerns/group_tree.rb
index 6ec6897e707..c363cad0ffa 100644
--- a/app/controllers/concerns/group_tree.rb
+++ b/app/controllers/concerns/group_tree.rb
@@ -1,5 +1,6 @@
module GroupTree
# rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # rubocop: disable CodeReuse/ActiveRecord
def render_group_tree(groups)
groups = groups.sort_by_attribute(@sort = params[:sort])
@@ -23,7 +24,9 @@ module GroupTree
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def filtered_groups_with_ancestors(groups)
filtered_groups = groups.search(params[:filter]).page(params[:page])
@@ -40,4 +43,5 @@ module GroupTree
filtered_groups
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb
index 7b6e5bcb5f1..e723107bd7f 100644
--- a/app/controllers/concerns/issuable_actions.rb
+++ b/app/controllers/concerns/issuable_actions.rb
@@ -89,6 +89,7 @@ module IssuableActions
render json: { notice: "#{quantity} #{resource_name.pluralize(quantity)} updated" }
end
+ # rubocop: disable CodeReuse/ActiveRecord
def discussions
notes = issuable.discussion_notes
.inc_relations_for_view
@@ -103,6 +104,7 @@ module IssuableActions
render json: discussion_serializer.represent(discussions, context: self)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb
index a2c96f5d635..d29154d5c60 100644
--- a/app/controllers/concerns/issuable_collections.rb
+++ b/app/controllers/concerns/issuable_collections.rb
@@ -48,9 +48,11 @@ module IssuableCollections
false
end
+ # rubocop: disable CodeReuse/ActiveRecord
def issuables_collection
finder.execute.preload(preload_for_collection)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def redirect_out_of_range(total_pages)
return false if total_pages.nil? || total_pages.zero?
@@ -81,6 +83,7 @@ module IssuableCollections
end
# rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # rubocop: disable CodeReuse/ActiveRecord
def filter_params
set_sort_order_from_cookie
set_default_state
@@ -101,6 +104,7 @@ module IssuableCollections
@filter_params.permit(finder_type.valid_params)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def set_default_state
diff --git a/app/controllers/concerns/issues_calendar.rb b/app/controllers/concerns/issues_calendar.rb
index 671a204621d..76e1d1ff4e8 100644
--- a/app/controllers/concerns/issues_calendar.rb
+++ b/app/controllers/concerns/issues_calendar.rb
@@ -2,6 +2,7 @@ module IssuesCalendar
extend ActiveSupport::Concern
# rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # rubocop: disable CodeReuse/ActiveRecord
def render_issues_calendar(issuables)
@issues = issuables
.non_archived
@@ -20,5 +21,6 @@ module IssuesCalendar
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# rubocop:enable Gitlab/ModuleWithInstanceVariables
end
diff --git a/app/controllers/concerns/members_presentation.rb b/app/controllers/concerns/members_presentation.rb
index 215e0bdf3cb..e146e7574aa 100644
--- a/app/controllers/concerns/members_presentation.rb
+++ b/app/controllers/concerns/members_presentation.rb
@@ -10,10 +10,12 @@ module MembersPresentation
).fabricate!
end
+ # rubocop: disable CodeReuse/ActiveRecord
def preload_associations(members)
ActiveRecord::Associations::Preloader.new.preload(members, :user)
ActiveRecord::Associations::Preloader.new.preload(members, :source)
ActiveRecord::Associations::Preloader.new.preload(members.map(&:user), :status)
ActiveRecord::Associations::Preloader.new.preload(members.map(&:user), :u2f_registrations)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb
index 409e6d4c4d2..94a352c0bcc 100644
--- a/app/controllers/concerns/membership_actions.rb
+++ b/app/controllers/concerns/membership_actions.rb
@@ -57,6 +57,7 @@ module MembershipActions
redirect_to members_page_url
end
+ # rubocop: disable CodeReuse/ActiveRecord
def leave
member = membershipable.members_and_requesters.find_by!(user_id: current_user.id)
Members::DestroyService.new(current_user).execute(member)
@@ -77,6 +78,7 @@ module MembershipActions
format.json { render json: { notice: notice } }
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def resend_invite
member = membershipable.members.find(params[:id])
diff --git a/app/controllers/concerns/renders_member_access.rb b/app/controllers/concerns/renders_member_access.rb
index d640378c24d..c5b77dacb26 100644
--- a/app/controllers/concerns/renders_member_access.rb
+++ b/app/controllers/concerns/renders_member_access.rb
@@ -13,6 +13,7 @@ module RendersMemberAccess
private
+ # rubocop: disable CodeReuse/ActiveRecord
def preload_max_member_access_for_collection(klass, collection)
return if !current_user || collection.blank?
@@ -20,4 +21,5 @@ module RendersMemberAccess
current_user.public_send(method_name, collection.ids) # rubocop:disable GitlabSecurity/PublicSend
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/concerns/renders_notes.rb b/app/controllers/concerns/renders_notes.rb
index cf04023080a..c5f23e33424 100644
--- a/app/controllers/concerns/renders_notes.rb
+++ b/app/controllers/concerns/renders_notes.rb
@@ -20,9 +20,11 @@ module RendersNotes
project.team.max_member_access_for_user_ids(user_ids)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def preload_noteable_for_regular_notes(notes)
ActiveRecord::Associations::Preloader.new.preload(notes.reject(&:for_commit?), :noteable)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def preload_first_time_contribution_for_authors(noteable, notes)
return unless noteable.is_a?(Issuable) && noteable.first_contribution?
@@ -30,7 +32,9 @@ module RendersNotes
notes.each {|n| n.specialize_for_first_contribution!(noteable)}
end
+ # rubocop: disable CodeReuse/ActiveRecord
def preload_author_status(notes)
ActiveRecord::Associations::Preloader.new.preload(notes, { author: :status })
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb
index bb8c245a5b7..56772df21d7 100644
--- a/app/controllers/concerns/uploads_actions.rb
+++ b/app/controllers/concerns/uploads_actions.rb
@@ -89,6 +89,7 @@ module UploadsActions
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def build_uploader_from_upload
return unless uploader = build_uploader
@@ -96,6 +97,7 @@ module UploadsActions
upload = Upload.find_by(uploader: uploader_class.to_s, path: upload_paths)
upload&.build_uploader
end
+ # rubocop: enable CodeReuse/ActiveRecord
def build_uploader_from_params
return unless uploader = build_uploader
diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb
index ccfcbbdc776..e8f796f17ca 100644
--- a/app/controllers/dashboard/projects_controller.rb
+++ b/app/controllers/dashboard/projects_controller.rb
@@ -23,6 +23,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def starred
@projects = load_projects(params.merge(starred: true))
.includes(:forked_from_project, :tags)
@@ -38,6 +39,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -46,6 +48,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
@sort = params[:sort]
end
+ # rubocop: disable CodeReuse/ActiveRecord
def load_projects(finder_params)
projects = ProjectsFinder
.new(params: finder_params, current_user: current_user)
@@ -55,6 +58,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
prepare_projects_for_rendering(projects)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def load_events
projects = load_projects(params.merge(non_public: true))
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb
index bd7111e28bc..231a23427f7 100644
--- a/app/controllers/dashboard/todos_controller.rb
+++ b/app/controllers/dashboard/todos_controller.rb
@@ -73,6 +73,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
params.permit(:action_id, :author_id, :project_id, :type, :sort, :state, :group_id)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def redirect_out_of_range(todos)
total_pages =
if todo_params.except(:sort, :page).empty?
@@ -91,4 +92,5 @@ class Dashboard::TodosController < Dashboard::ApplicationController
out_of_range
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb
index c7273606a85..03a2ee07fea 100644
--- a/app/controllers/explore/projects_controller.rb
+++ b/app/controllers/explore/projects_controller.rb
@@ -34,6 +34,7 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def starred
@projects = load_projects.reorder('star_count DESC')
@@ -46,9 +47,11 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def load_projects
projects = ProjectsFinder.new(current_user: current_user, params: params)
.execute
@@ -58,4 +61,5 @@ class Explore::ProjectsController < Explore::ApplicationController
prepare_projects_for_rendering(projects)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 1f48c3417d0..8b46eedae79 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -97,6 +97,7 @@ class GroupsController < Groups::ApplicationController
redirect_to root_path, status: 302, alert: "Group '#{@group.name}' was scheduled for deletion."
end
+ # rubocop: disable CodeReuse/ActiveRecord
def transfer
parent_group = Group.find_by(id: params[:new_parent_group_id])
service = ::Groups::TransferService.new(@group, current_user)
@@ -109,9 +110,11 @@ class GroupsController < Groups::ApplicationController
render :edit
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
protected
+ # rubocop: disable CodeReuse/ActiveRecord
def authorize_create_group!
allowed = if params[:parent_id].present?
parent = Group.find_by(id: params[:parent_id])
@@ -122,6 +125,7 @@ class GroupsController < Groups::ApplicationController
render_404 unless allowed
end
+ # rubocop: enable CodeReuse/ActiveRecord
def determine_layout
if [:new, :create].include?(action_name.to_sym)
@@ -156,6 +160,7 @@ class GroupsController < Groups::ApplicationController
]
end
+ # rubocop: disable CodeReuse/ActiveRecord
def load_events
params[:sort] ||= 'latest_activity_desc'
@@ -175,6 +180,7 @@ class GroupsController < Groups::ApplicationController
.new(current_user)
.execute(@events, atom_request: request.format.atom?)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def user_actions
if current_user
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb
index 5766c6924cd..14b8c6e4137 100644
--- a/app/controllers/import/base_controller.rb
+++ b/app/controllers/import/base_controller.rb
@@ -1,16 +1,20 @@
class Import::BaseController < ApplicationController
private
+ # rubocop: disable CodeReuse/ActiveRecord
def find_already_added_projects(import_type)
current_user.created_projects.where(import_type: import_type).includes(:import_state)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def find_jobs(import_type)
current_user.created_projects
.includes(:import_state)
.where(import_type: import_type)
.to_json(only: [:id], methods: [:import_status])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_or_create_namespace(names, owner)
names = params[:target_namespace].presence || names
diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb
index fa31933e778..f885e04b198 100644
--- a/app/controllers/import/bitbucket_controller.rb
+++ b/app/controllers/import/bitbucket_controller.rb
@@ -16,6 +16,7 @@ class Import::BitbucketController < Import::BaseController
redirect_to status_import_bitbucket_url
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
bitbucket_client = Bitbucket::Client.new(credentials)
repos = bitbucket_client.repos
@@ -27,6 +28,7 @@ class Import::BitbucketController < Import::BaseController
@repos.to_a.reject! { |repo| already_added_projects_names.include?(repo.full_name) }
end
+ # rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('bitbucket')
diff --git a/app/controllers/import/bitbucket_server_controller.rb b/app/controllers/import/bitbucket_server_controller.rb
index 798daeca6c9..fdd1078cdf7 100644
--- a/app/controllers/import/bitbucket_server_controller.rb
+++ b/app/controllers/import/bitbucket_server_controller.rb
@@ -52,6 +52,7 @@ class Import::BitbucketServerController < Import::BaseController
redirect_to status_import_bitbucket_server_path
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
repos = bitbucket_client.repos
@@ -66,6 +67,7 @@ class Import::BitbucketServerController < Import::BaseController
clear_session_data
redirect_to new_import_bitbucket_server_path
end
+ # rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('bitbucket_server')
diff --git a/app/controllers/import/fogbugz_controller.rb b/app/controllers/import/fogbugz_controller.rb
index 2d665e05ac3..df96d181153 100644
--- a/app/controllers/import/fogbugz_controller.rb
+++ b/app/controllers/import/fogbugz_controller.rb
@@ -39,6 +39,7 @@ class Import::FogbugzController < Import::BaseController
redirect_to status_import_fogbugz_path
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
unless client.valid?
return redirect_to new_import_fogbugz_path
@@ -51,6 +52,7 @@ class Import::FogbugzController < Import::BaseController
@repos.reject! { |repo| already_added_projects_names.include? repo.name }
end
+ # rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('fogbugz')
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index c9870332c0f..f8b43b4fde5 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -22,6 +22,7 @@ class Import::GithubController < Import::BaseController
redirect_to status_import_url
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
@repos = client.repos
@already_added_projects = find_already_added_projects(provider)
@@ -29,6 +30,7 @@ class Import::GithubController < Import::BaseController
@repos.reject! { |repo| already_added_projects_names.include? repo.full_name }
end
+ # rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs(provider)
@@ -104,9 +106,11 @@ class Import::GithubController < Import::BaseController
:github
end
+ # rubocop: disable CodeReuse/ActiveRecord
def logged_in_with_provider?
current_user.identities.exists?(provider: provider)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def provider_auth
if session[access_token_key].blank?
diff --git a/app/controllers/import/gitlab_controller.rb b/app/controllers/import/gitlab_controller.rb
index 53f70446d95..bdc402b0a77 100644
--- a/app/controllers/import/gitlab_controller.rb
+++ b/app/controllers/import/gitlab_controller.rb
@@ -12,6 +12,7 @@ class Import::GitlabController < Import::BaseController
redirect_to status_import_gitlab_url
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
@repos = client.projects(starting_page: 1, page_limit: MAX_PROJECT_PAGES, per_page: PER_PAGE_PROJECTS)
@@ -20,6 +21,7 @@ class Import::GitlabController < Import::BaseController
@repos = @repos.to_a.reject { |repo| already_added_projects_names.include? repo["path_with_namespace"] }
end
+ # rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('gitlab')
diff --git a/app/controllers/import/google_code_controller.rb b/app/controllers/import/google_code_controller.rb
index 3bce27e810a..e9387d0ad14 100644
--- a/app/controllers/import/google_code_controller.rb
+++ b/app/controllers/import/google_code_controller.rb
@@ -65,6 +65,7 @@ class Import::GoogleCodeController < Import::BaseController
redirect_to status_import_google_code_path
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
unless client.valid?
return redirect_to new_import_google_code_path
@@ -78,6 +79,7 @@ class Import::GoogleCodeController < Import::BaseController
@repos.reject! { |repo| already_added_projects_names.include? repo.name }
end
+ # rubocop: enable CodeReuse/ActiveRecord
def jobs
render json: find_jobs('google_code')
diff --git a/app/controllers/import/manifest_controller.rb b/app/controllers/import/manifest_controller.rb
index e5a719fa0df..4ed9dca2475 100644
--- a/app/controllers/import/manifest_controller.rb
+++ b/app/controllers/import/manifest_controller.rb
@@ -6,6 +6,7 @@ class Import::ManifestController < Import::BaseController
def new
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
@already_added_projects = find_already_added_projects
already_added_import_urls = @already_added_projects.pluck(:import_url)
@@ -14,6 +15,7 @@ class Import::ManifestController < Import::BaseController
already_added_import_urls.include?(repository[:url])
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def upload
group = Group.find(params[:group_id])
@@ -64,9 +66,11 @@ class Import::ManifestController < Import::BaseController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def group
@group ||= Group.find_by(id: session[:manifest_import_group_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def repositories
@repositories ||= session[:manifest_import_repositories]
@@ -76,12 +80,14 @@ class Import::ManifestController < Import::BaseController
find_already_added_projects.to_json(only: [:id], methods: [:import_status])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_already_added_projects
group.all_projects
.where(import_type: 'manifest')
.where(creator_id: current_user)
.includes(:import_state)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def verify_import_enabled
render_404 unless manifest_import_enabled?
diff --git a/app/controllers/instance_statistics/conversational_development_index_controller.rb b/app/controllers/instance_statistics/conversational_development_index_controller.rb
index d6d2191849f..306c16d559c 100644
--- a/app/controllers/instance_statistics/conversational_development_index_controller.rb
+++ b/app/controllers/instance_statistics/conversational_development_index_controller.rb
@@ -1,7 +1,9 @@
# frozen_string_literal: true
class InstanceStatistics::ConversationalDevelopmentIndexController < InstanceStatistics::ApplicationController
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@metric = ConversationalDevelopmentIndex::Metric.order(:created_at).last&.present
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb
index 331583c49e6..a1bcf206b65 100644
--- a/app/controllers/passwords_controller.rb
+++ b/app/controllers/passwords_controller.rb
@@ -5,6 +5,7 @@ class PasswordsController < Devise::PasswordsController
before_action :check_password_authentication_available, only: [:create]
before_action :throttle_reset, only: [:create]
+ # rubocop: disable CodeReuse/ActiveRecord
def edit
super
reset_password_token = Devise.token_generator.digest(
@@ -24,6 +25,7 @@ class PasswordsController < Devise::PasswordsController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update
super do |resource|
diff --git a/app/controllers/profiles/accounts_controller.rb b/app/controllers/profiles/accounts_controller.rb
index 7d1aa8d1ce0..fd9cb9fca3e 100644
--- a/app/controllers/profiles/accounts_controller.rb
+++ b/app/controllers/profiles/accounts_controller.rb
@@ -5,6 +5,7 @@ class Profiles::AccountsController < Profiles::ApplicationController
@user = current_user
end
+ # rubocop: disable CodeReuse/ActiveRecord
def unlink
provider = params[:provider]
identity = current_user.identities.find_by(provider: provider)
@@ -19,4 +20,5 @@ class Profiles::AccountsController < Profiles::ApplicationController
redirect_to profile_account_path
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/profiles/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb
index 8a38ba65d4c..00bd2040b9a 100644
--- a/app/controllers/profiles/notifications_controller.rb
+++ b/app/controllers/profiles/notifications_controller.rb
@@ -1,10 +1,12 @@
class Profiles::NotificationsController < Profiles::ApplicationController
+ # rubocop: disable CodeReuse/ActiveRecord
def show
@user = current_user
@group_notifications = current_user.notification_settings.for_groups.order(:id)
@project_notifications = current_user.notification_settings.for_projects.order(:id)
@global_notification_setting = current_user.global_notification_setting
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update
result = Users::UpdateService.new(current_user, user_params.merge(user: current_user)).execute
diff --git a/app/controllers/profiles/personal_access_tokens_controller.rb b/app/controllers/profiles/personal_access_tokens_controller.rb
index 346eab4ba19..b357741e3fb 100644
--- a/app/controllers/profiles/personal_access_tokens_controller.rb
+++ b/app/controllers/profiles/personal_access_tokens_controller.rb
@@ -38,6 +38,7 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController
params.require(:personal_access_token).permit(:name, :expires_at, scopes: [])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def set_index_vars
@scopes = Gitlab::Auth.available_scopes(current_user)
@@ -46,4 +47,5 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController
@new_personal_access_token = PersonalAccessToken.redis_getdel(current_user.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index 5671663f81e..94e6efca487 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -44,11 +44,13 @@ class ProfilesController < Profiles::ApplicationController
redirect_to profile_personal_access_tokens_path
end
+ # rubocop: disable CodeReuse/ActiveRecord
def audit_log
@events = AuditEvent.where(entity_type: "User", entity_id: current_user.id)
.order("created_at DESC")
.page(params[:page])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update_username
result = Users::UpdateService.new(current_user, user: @user, username: username_param).execute
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index 6484a713f8e..3e8ffa485dd 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -82,16 +82,20 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def build_from_id
project.builds.find_by(id: params[:job_id]) if params[:job_id]
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def build_from_ref
return unless @ref_name
builds = project.latest_successful_builds_for(@ref_name)
builds.find_by(name: params[:job])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def artifacts_file
@artifacts_file ||= build.artifacts_file
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 56dafa31332..bfe4e7f934f 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -177,6 +177,7 @@ class Projects::BlobController < Projects::ApplicationController
render_404
end
+ # rubocop: disable CodeReuse/ActiveRecord
def after_edit_path
from_merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).find_by(iid: params[:from_merge_request_iid])
if from_merge_request && @branch_name == @ref
@@ -186,6 +187,7 @@ class Projects::BlobController < Projects::ApplicationController
project_blob_path(@project, File.join(@branch_name, @path))
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def editor_variables
@branch_name = params[:branch_name]
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb
index d1dc9fe9600..d14795e787b 100644
--- a/app/controllers/projects/branches_controller.rb
+++ b/app/controllers/projects/branches_controller.rb
@@ -48,6 +48,7 @@ class Projects::BranchesController < Projects::ApplicationController
@branches = @repository.recent_branches
end
+ # rubocop: disable CodeReuse/ActiveRecord
def create
branch_name = sanitize(strip_tags(params[:branch_name]))
branch_name = Addressable::URI.unescape(branch_name)
@@ -88,6 +89,7 @@ class Projects::BranchesController < Projects::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def destroy
@branch_name = Addressable::URI.unescape(params[:id])
diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb
index b45e5d7ff43..9e99a84fac7 100644
--- a/app/controllers/projects/build_artifacts_controller.rb
+++ b/app/controllers/projects/build_artifacts_controller.rb
@@ -42,14 +42,18 @@ class Projects::BuildArtifactsController < Projects::ApplicationController
@job ||= job_from_id || job_from_ref
end
+ # rubocop: disable CodeReuse/ActiveRecord
def job_from_id
project.builds.find_by(id: params[:build_id]) if params[:build_id]
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def job_from_ref
return unless @ref_name
jobs = project.latest_successful_builds_for(@ref_name)
jobs.find_by(name: params[:job])
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb
index a5c82caa897..8c9df51981a 100644
--- a/app/controllers/projects/clusters/applications_controller.rb
+++ b/app/controllers/projects/clusters/applications_controller.rb
@@ -4,6 +4,7 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:create]
+ # rubocop: disable CodeReuse/ActiveRecord
def create
application = @application_class.find_or_initialize_by(cluster: @cluster)
@@ -23,6 +24,7 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
rescue StandardError
head :bad_request
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 53637780a07..81f375875b2 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -38,6 +38,7 @@ class Projects::CommitController < Projects::ApplicationController
render_diff_for_path(@commit.diffs(diff_options))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def pipelines
@pipelines = @commit.pipelines.order(id: :desc)
@pipelines = @pipelines.where(ref: params[:ref]) if params[:ref]
@@ -58,6 +59,7 @@ class Projects::CommitController < Projects::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def merge_requests
@merge_requests = @commit.merge_requests.map do |mr|
@@ -144,6 +146,7 @@ class Projects::CommitController < Projects::ApplicationController
@environment = EnvironmentsFinder.new(@project, current_user, commit: @commit).execute.last
end
+ # rubocop: disable CodeReuse/ActiveRecord
def define_note_vars
@noteable = @commit
@note = @project.build_commit_note(commit)
@@ -176,6 +179,7 @@ class Projects::CommitController < Projects::ApplicationController
@notes = (@grouped_diff_discussions.values.flatten + @discussions).flat_map(&:notes)
@notes = prepare_notes_for_rendering(@notes, @commit)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def assign_change_commit_vars
@start_branch = params[:start_branch]
diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb
index 5546bef850b..cd9c9aa30f1 100644
--- a/app/controllers/projects/commits_controller.rb
+++ b/app/controllers/projects/commits_controller.rb
@@ -15,6 +15,7 @@ class Projects::CommitsController < Projects::ApplicationController
redirect_to project_commits_path(@project, @project.default_branch)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def show
@merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
.find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref)
@@ -32,6 +33,7 @@ class Projects::CommitsController < Projects::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def signatures
respond_to do |format|
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index a1e12821caf..cca77903250 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -96,8 +96,10 @@ class Projects::CompareController < Projects::ApplicationController
@diff_notes_disabled = compare.present?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_request
@merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
.find_by(source_project: @project, source_branch: head_ref, target_branch: start_ref)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb
index 28fea322334..2555139cd2c 100644
--- a/app/controllers/projects/deploy_keys_controller.rb
+++ b/app/controllers/projects/deploy_keys_controller.rb
@@ -52,6 +52,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def disable
deploy_key_project = @project.deploy_keys_projects.find_by(deploy_key_id: params[:id])
return render_404 unless deploy_key_project
@@ -63,6 +64,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
format.json { head :ok }
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
protected
diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb
index b68cdc39cb8..5a2da7274d1 100644
--- a/app/controllers/projects/deployments_controller.rb
+++ b/app/controllers/projects/deployments_controller.rb
@@ -2,6 +2,7 @@ class Projects::DeploymentsController < Projects::ApplicationController
before_action :authorize_read_environment!
before_action :authorize_read_deployment!
+ # rubocop: disable CodeReuse/ActiveRecord
def index
deployments = environment.deployments.reorder(created_at: :desc)
deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time
@@ -9,6 +10,7 @@ class Projects::DeploymentsController < Projects::ApplicationController
render json: { deployments: DeploymentSerializer.new(project: project)
.represent_concise(deployments) }
end
+ # rubocop: enable CodeReuse/ActiveRecord
def metrics
return render_404 unless deployment.has_metrics?
@@ -41,9 +43,11 @@ class Projects::DeploymentsController < Projects::ApplicationController
private
+ # rubocop: disable CodeReuse/ActiveRecord
def deployment
@deployment ||= environment.deployments.find_by(iid: params[:id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def environment
@environment ||= project.environments.find(params[:environment_id])
diff --git a/app/controllers/projects/discussions_controller.rb b/app/controllers/projects/discussions_controller.rb
index 78b9d53a780..efdddb24290 100644
--- a/app/controllers/projects/discussions_controller.rb
+++ b/app/controllers/projects/discussions_controller.rb
@@ -50,9 +50,11 @@ class Projects::DiscussionsController < Projects::ApplicationController
}
end
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_request
@merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).find_by!(iid: params[:merge_request_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def discussion
@discussion ||= @merge_request.find_discussion(params[:id]) || render_404
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index 68353e6a210..be22950286e 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -31,6 +31,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def folder
folder_environments = project.environments.where(environment_type: params[:id])
@environments = folder_environments.with_state(params[:scope] || :available)
@@ -51,10 +52,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def show
@deployments = environment.deployments.order(id: :desc).page(params[:page])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def new
@environment = project.environments.new
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index f43bba18d81..b709edc8f10 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -7,6 +7,7 @@ class Projects::ForksController < Projects::ApplicationController
before_action :authorize_download_code!
before_action :authenticate_user!, only: [:new, :create]
+ # rubocop: disable CodeReuse/ActiveRecord
def index
base_query = project.forks.includes(:creator)
@@ -27,12 +28,14 @@ class Projects::ForksController < Projects::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def new
@namespaces = current_user.manageable_namespaces
@namespaces.delete(@project.namespace)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def create
namespace = Namespace.find(params[:namespace_key])
@@ -55,6 +58,7 @@ class Projects::ForksController < Projects::ApplicationController
render :error
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42335')
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index c3ac8e107fb..632e498e4ba 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -161,6 +161,7 @@ class Projects::IssuesController < Projects::ApplicationController
protected
+ # rubocop: disable CodeReuse/ActiveRecord
def issue
return @issue if defined?(@issue)
@@ -172,6 +173,7 @@ class Projects::IssuesController < Projects::ApplicationController
@issue
end
+ # rubocop: enable CodeReuse/ActiveRecord
alias_method :subscribable_resource, :issue
alias_method :issuable, :issue
alias_method :awardable, :issue
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb
index e69faae754a..62b74e84c2c 100644
--- a/app/controllers/projects/jobs_controller.rb
+++ b/app/controllers/projects/jobs_controller.rb
@@ -11,6 +11,7 @@ class Projects::JobsController < Projects::ApplicationController
layout 'project'
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@scope = params[:scope]
@all_builds = project.builds.relevant
@@ -33,6 +34,7 @@ class Projects::JobsController < Projects::ApplicationController
])
@builds = @builds.page(params[:page]).per(30).without_count
end
+ # rubocop: enable CodeReuse/ActiveRecord
def cancel_all
return access_denied! unless can?(current_user, :update_build, project)
@@ -44,6 +46,7 @@ class Projects::JobsController < Projects::ApplicationController
redirect_to project_jobs_path(project)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def show
@pipeline = @build.pipeline
@builds = @pipeline.builds
@@ -61,6 +64,7 @@ class Projects::JobsController < Projects::ApplicationController
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def trace
build.trace.read do |stream|
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index 8a2bce6e7b5..18dbd65637c 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -90,6 +90,7 @@ class Projects::LabelsController < Projects::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def set_priorities
Label.transaction do
available_labels_ids = @available_labels.where(id: params[:label_ids]).pluck(:id)
@@ -105,6 +106,7 @@ class Projects::LabelsController < Projects::ApplicationController
format.json { render json: { message: 'success' } }
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def promote
promote_service = Labels::PromoteService.new(@project, @current_user)
diff --git a/app/controllers/projects/lfs_api_controller.rb b/app/controllers/projects/lfs_api_controller.rb
index a01351ba292..6d6f88c1075 100644
--- a/app/controllers/projects/lfs_api_controller.rb
+++ b/app/controllers/projects/lfs_api_controller.rb
@@ -41,11 +41,13 @@ class Projects::LfsApiController < Projects::GitHttpClientController
params[:operation] == 'upload'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def existing_oids
@existing_oids ||= begin
project.all_lfs_objects.where(oid: objects.map { |o| o['oid'].to_s }).pluck(:oid)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def download_objects!
objects.each do |object|
diff --git a/app/controllers/projects/lfs_storage_controller.rb b/app/controllers/projects/lfs_storage_controller.rb
index dd7e673ec75..930d9a05c50 100644
--- a/app/controllers/projects/lfs_storage_controller.rb
+++ b/app/controllers/projects/lfs_storage_controller.rb
@@ -56,6 +56,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
params[:size].to_i
end
+ # rubocop: disable CodeReuse/ActiveRecord
def store_file!(oid, size)
object = LfsObject.find_by(oid: oid, size: size)
unless object&.file&.exists?
@@ -66,6 +67,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
link_to_project!(object)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create_file!(oid, size)
uploaded_file = UploadedFile.from_params(
@@ -75,9 +77,11 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
LfsObject.create!(oid: oid, size: size, file: uploaded_file)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def link_to_project!(object)
if object && !object.projects.exists?(storage_project.id)
object.lfs_objects_projects.create!(project: storage_project)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/projects/merge_requests/application_controller.rb b/app/controllers/projects/merge_requests/application_controller.rb
index fead81dd472..aa2008722ec 100644
--- a/app/controllers/projects/merge_requests/application_controller.rb
+++ b/app/controllers/projects/merge_requests/application_controller.rb
@@ -5,9 +5,11 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
private
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_request
@issuable = @merge_request ||= @project.merge_requests.includes(author: :status).find_by!(iid: params[:id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def merge_request_params
params.require(:merge_request).permit(merge_request_params_attributes)
diff --git a/app/controllers/projects/merge_requests/creations_controller.rb b/app/controllers/projects/merge_requests/creations_controller.rb
index 03d0290ac1d..2ccb3896857 100644
--- a/app/controllers/projects/merge_requests/creations_controller.rb
+++ b/app/controllers/projects/merge_requests/creations_controller.rb
@@ -109,6 +109,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
set_pipeline_variables
end
+ # rubocop: disable CodeReuse/ActiveRecord
def selected_target_project
if @project.id.to_s == params[:target_project_id] || !@project.forked?
@project
@@ -119,6 +120,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
@project.forked_from_project
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42384')
diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb
index 34de554212f..666e65b6c5e 100644
--- a/app/controllers/projects/merge_requests/diffs_controller.rb
+++ b/app/controllers/projects/merge_requests/diffs_controller.rb
@@ -34,13 +34,16 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
@diffs = @compare.diffs(diff_options)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def commit
return nil unless commit_id = params[:commit_id].presence
return nil unless @merge_request.all_commits.exists?(sha: commit_id)
@commit ||= @project.commit(commit_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def find_merge_request_diff_compare
@merge_request_diff =
if diff_id = params[:diff_id].presence
@@ -68,6 +71,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
@merge_request_diff
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def additional_attributes
{
diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb
index b9b3dcd5a85..e2c05171cd6 100644
--- a/app/controllers/projects/milestones_controller.rb
+++ b/app/controllers/projects/milestones_controller.rb
@@ -118,9 +118,11 @@ class Projects::MilestonesController < Projects::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def milestone
@milestone ||= @project.milestones.find_by!(iid: params[:id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def authorize_admin_milestone!
return render_404 unless can?(current_user, :admin_milestone, @project)
diff --git a/app/controllers/projects/pages_controller.rb b/app/controllers/projects/pages_controller.rb
index ff49911d892..e1eba4f8327 100644
--- a/app/controllers/projects/pages_controller.rb
+++ b/app/controllers/projects/pages_controller.rb
@@ -5,9 +5,11 @@ class Projects::PagesController < Projects::ApplicationController
before_action :authorize_read_pages!, only: [:show]
before_action :authorize_update_pages!, except: [:show]
+ # rubocop: disable CodeReuse/ActiveRecord
def show
@domains = @project.pages_domains.order(:domain)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def destroy
project.remove_pages
diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb
index 4856be61e88..c29b3c953a6 100644
--- a/app/controllers/projects/pages_domains_controller.rb
+++ b/app/controllers/projects/pages_domains_controller.rb
@@ -70,7 +70,9 @@ class Projects::PagesDomainsController < Projects::ApplicationController
params.require(:pages_domain).permit(:key, :certificate)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def domain
@domain ||= @project.pages_domains.find_by!(domain: params[:id].to_s)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb
index aeda7b3edf5..d8adeffd0b2 100644
--- a/app/controllers/projects/pipeline_schedules_controller.rb
+++ b/app/controllers/projects/pipeline_schedules_controller.rb
@@ -8,12 +8,14 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
before_action :authorize_update_pipeline_schedule!, except: [:index, :new, :create, :play]
before_action :authorize_admin_pipeline_schedule!, only: [:destroy]
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@scope = params[:scope]
@all_schedules = PipelineSchedulesFinder.new(@project).execute
@schedules = PipelineSchedulesFinder.new(@project).execute(scope: params[:scope])
.includes(:last_pipeline)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def new
@schedule = project.pipeline_schedules.new
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index b5db646bf57..2cc721dfeec 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -159,6 +159,7 @@ class Projects::PipelinesController < Projects::ApplicationController
params.require(:pipeline).permit(:ref, variables_attributes: %i[key secret_value])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def pipeline
@pipeline ||= project
.pipelines
@@ -166,6 +167,7 @@ class Projects::PipelinesController < Projects::ApplicationController
.find_by!(id: params[:id])
.present(current_user: current_user)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
# Also see https://gitlab.com/gitlab-org/gitlab-ce/issues/42343
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb
index cfa5e72af64..08d5e377941 100644
--- a/app/controllers/projects/project_members_controller.rb
+++ b/app/controllers/projects/project_members_controller.rb
@@ -6,6 +6,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
# Authorize
before_action :authorize_admin_project_member!, except: [:index, :leave, :request_access]
+ # rubocop: disable CodeReuse/ActiveRecord
def index
@sort = params[:sort].presence || sort_value_name
@group_links = @project.project_group_links
@@ -25,6 +26,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@requesters = present_members(AccessRequestsFinder.new(@project).execute(current_user))
@project_member = @project.project_members.new
end
+ # rubocop: enable CodeReuse/ActiveRecord
def import
@projects = current_user.authorized_projects.order_id_desc
diff --git a/app/controllers/projects/releases_controller.rb b/app/controllers/projects/releases_controller.rb
index 19e09b3af6f..caf400ecd92 100644
--- a/app/controllers/projects/releases_controller.rb
+++ b/app/controllers/projects/releases_controller.rb
@@ -28,9 +28,11 @@ class Projects::ReleasesController < Projects::ApplicationController
@tag ||= @repository.find_tag(params[:tag_id])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def release
@release ||= @project.releases.find_or_initialize_by(tag: @tag.name)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def release_params
params.require(:release).permit(:description)
diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb
index 4697af4f26a..ccd481b4dbd 100644
--- a/app/controllers/projects/settings/repository_controller.rb
+++ b/app/controllers/projects/settings/repository_controller.rb
@@ -31,6 +31,7 @@ module Projects
render 'show'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def define_protected_refs
@protected_branches = @project.protected_branches.order(:name).page(params[:page])
@protected_tags = @project.protected_tags.order(:name).page(params[:page])
@@ -42,6 +43,7 @@ module Projects
load_gon_index
end
+ # rubocop: enable CodeReuse/ActiveRecord
def remote_mirror
@remote_mirror = project.remote_mirrors.first_or_initialize
diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb
index 7f2c3ca38ad..74bba97987f 100644
--- a/app/controllers/projects/tags_controller.rb
+++ b/app/controllers/projects/tags_controller.rb
@@ -7,6 +7,7 @@ class Projects::TagsController < Projects::ApplicationController
before_action :authorize_push_code!, only: [:new, :create]
before_action :authorize_admin_project!, only: [:destroy]
+ # rubocop: disable CodeReuse/ActiveRecord
def index
params[:sort] = params[:sort].presence || sort_value_recently_updated
@@ -23,7 +24,9 @@ class Projects::TagsController < Projects::ApplicationController
format.atom { render layout: 'xml.atom' }
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def show
@tag = @repository.find_tag(params[:id])
@@ -32,6 +35,7 @@ class Projects::TagsController < Projects::ApplicationController
@release = @project.releases.find_or_initialize_by(tag: @tag.name)
@commit = @repository.commit(@tag.dereferenced_target)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create
result = Tags::CreateService.new(@project, current_user)
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 98076791ab9..e2f9d501c4b 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -25,12 +25,14 @@ class ProjectsController < Projects::ApplicationController
redirect_to(current_user ? root_path : explore_root_path)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def new
namespace = Namespace.find_by(id: params[:namespace_id]) if params[:namespace_id]
return access_denied! if namespace && !can?(current_user, :create_projects, namespace)
@project = Project.new(namespace_id: namespace&.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def edit
@badge_api_endpoint = expose_url(api_v4_projects_badges_path(id: @project.id))
@@ -75,6 +77,7 @@ class ProjectsController < Projects::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def transfer
return access_denied! unless can?(current_user, :change_namespace, @project)
@@ -85,6 +88,7 @@ class ProjectsController < Projects::ApplicationController
flash[:alert] = @project.errors[:new_namespace].first
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def remove_fork
return access_denied! unless can?(current_user, :remove_fork_project, @project)
@@ -231,6 +235,7 @@ class ProjectsController < Projects::ApplicationController
}
end
+ # rubocop: disable CodeReuse/ActiveRecord
def refs
find_refs = params['find']
@@ -265,6 +270,7 @@ class ProjectsController < Projects::ApplicationController
render json: options.to_json
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Render project landing depending of which features are available
# So if page is not availble in the list it renders the next page
@@ -303,6 +309,7 @@ class ProjectsController < Projects::ApplicationController
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def load_events
projects = Project.where(id: @project.id)
@@ -312,6 +319,7 @@ class ProjectsController < Projects::ApplicationController
Events::RenderService.new(current_user).execute(@events, atom_request: request.format.atom?)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def project_params
params.require(:project)
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 983f888b8ec..a928758f325 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -31,6 +31,7 @@ class SearchController < ApplicationController
check_single_commit_result
end
+ # rubocop: disable CodeReuse/ActiveRecord
def autocomplete
term = params[:term]
@@ -43,6 +44,7 @@ class SearchController < ApplicationController
render json: search_autocomplete_opts(term).to_json
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index ab8e2e35b98..9f2e66dea90 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -107,6 +107,7 @@ class SessionsController < Devise::SessionsController
# Handle an "initial setup" state, where there's only one user, it's an admin,
# and they require a password change.
+ # rubocop: disable CodeReuse/ActiveRecord
def check_initial_setup
return unless User.limit(2).count == 1 # Count as much 2 to know if we have exactly one
@@ -121,6 +122,7 @@ class SessionsController < Devise::SessionsController
redirect_to edit_user_password_path(reset_password_token: @token),
notice: "Please create a password for your new account."
end
+ # rubocop: enable CodeReuse/ActiveRecord
def user_params
params.require(:user).permit(:login, :password, :remember_me, :otp_attempt, :device_response)
diff --git a/app/controllers/snippets/notes_controller.rb b/app/controllers/snippets/notes_controller.rb
index 217da89a1fd..e992afc0026 100644
--- a/app/controllers/snippets/notes_controller.rb
+++ b/app/controllers/snippets/notes_controller.rb
@@ -17,9 +17,11 @@ class Snippets::NotesController < ApplicationController
nil
end
+ # rubocop: disable CodeReuse/ActiveRecord
def snippet
PersonalSnippet.find_by(id: params[:snippet_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
alias_method :noteable, :snippet
def note_params
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index dcf18c1f751..19d865900e9 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -24,6 +24,7 @@ class SnippetsController < ApplicationController
layout 'snippets'
respond_to :html
+ # rubocop: disable CodeReuse/ActiveRecord
def index
if params[:username].present?
@user = User.find_by(username: params[:username])
@@ -38,6 +39,7 @@ class SnippetsController < ApplicationController
redirect_to(current_user ? dashboard_snippets_path : explore_snippets_path)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def new
@snippet = PersonalSnippet.new
@@ -94,9 +96,11 @@ class SnippetsController < ApplicationController
protected
+ # rubocop: disable CodeReuse/ActiveRecord
def snippet
@snippet ||= PersonalSnippet.inc_relations_for_view.find_by(id: params[:id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
alias_method :awardable, :snippet
alias_method :spammable, :snippet
diff --git a/app/controllers/user_callouts_controller.rb b/app/controllers/user_callouts_controller.rb
index 18cde4a7b1a..b8d2deba93b 100644
--- a/app/controllers/user_callouts_controller.rb
+++ b/app/controllers/user_callouts_controller.rb
@@ -13,9 +13,11 @@ class UserCalloutsController < ApplicationController
private
+ # rubocop: disable CodeReuse/ActiveRecord
def ensure_callout
current_user.callouts.find_or_create_by(feature_name: UserCallout.feature_names[feature_name])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def feature_name
params.require(:feature_name)
diff --git a/app/finders/admin/projects_finder.rb b/app/finders/admin/projects_finder.rb
index 543bf1a1415..6b805c432f6 100644
--- a/app/finders/admin/projects_finder.rb
+++ b/app/finders/admin/projects_finder.rb
@@ -6,6 +6,7 @@ class Admin::ProjectsFinder
@current_user = current_user
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
items = Project.without_deleted.with_statistics.with_route
items = by_namespace_id(items)
@@ -19,6 +20,7 @@ class Admin::ProjectsFinder
items = items.includes(namespace: [:owner, :route])
sort(items).page(params[:page])
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -26,9 +28,11 @@ class Admin::ProjectsFinder
params[:namespace_id].present? ? items.in_namespace(params[:namespace_id]) : items
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_visibilty_level(items)
params[:visibility_level].present? ? items.where(visibility_level: params[:visibility_level]) : items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_with_push(items)
params[:with_push].present? ? items.with_push : items
@@ -38,9 +42,11 @@ class Admin::ProjectsFinder
params[:abandoned].present? ? items.abandoned : items
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_last_repository_check_failed(items)
params[:last_repository_check_failed].present? ? items.where(last_repository_check_failed: true) : items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_archived(items)
if params[:archived] == 'only'
diff --git a/app/finders/autocomplete/users_finder.rb b/app/finders/autocomplete/users_finder.rb
index b2557469079..e2283f3266e 100644
--- a/app/finders/autocomplete/users_finder.rb
+++ b/app/finders/autocomplete/users_finder.rb
@@ -44,6 +44,7 @@ module Autocomplete
# Returns the users based on the input parameters, as an Array.
#
# This method is separate so it is easier to extend in EE.
+ # rubocop: disable CodeReuse/ActiveRecord
def limited_users
# When changing the order of these method calls, make sure that
# reorder_by_name() is called _before_ optionally_search(), otherwise
@@ -61,6 +62,7 @@ module Autocomplete
.limit(LIMIT)
.to_a
end
+ # rubocop: enable CodeReuse/ActiveRecord
def prepend_current_user?
filter_by_current_user.present? && current_user
@@ -70,6 +72,7 @@ module Autocomplete
author_id.present? && current_user
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_users
if project
project.authorized_users.union_with_user(author_id)
@@ -81,5 +84,6 @@ module Autocomplete
User.none
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/finders/concerns/custom_attributes_filter.rb b/app/finders/concerns/custom_attributes_filter.rb
index 5bbf9ca242d..022a19b0a7f 100644
--- a/app/finders/concerns/custom_attributes_filter.rb
+++ b/app/finders/concerns/custom_attributes_filter.rb
@@ -1,4 +1,5 @@
module CustomAttributesFilter
+ # rubocop: disable CodeReuse/ActiveRecord
def by_custom_attributes(items)
return items unless params[:custom_attributes].is_a?(Hash)
return items unless Ability.allowed?(current_user, :read_custom_attribute)
@@ -17,4 +18,5 @@ module CustomAttributesFilter
scope.where('EXISTS (?)', custom_attributes.where(key: key, value: value))
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/concerns/finder_methods.rb b/app/finders/concerns/finder_methods.rb
index 2e905fa5750..ce0ec214b8a 100644
--- a/app/finders/concerns/finder_methods.rb
+++ b/app/finders/concerns/finder_methods.rb
@@ -1,11 +1,15 @@
module FinderMethods
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by!(*args)
raise_not_found_unless_authorized execute.find_by!(*args)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by(*args)
if_authorized execute.find_by(*args)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find(*args)
raise_not_found_unless_authorized model.find(*args)
diff --git a/app/finders/concerns/finder_with_cross_project_access.rb b/app/finders/concerns/finder_with_cross_project_access.rb
index 92bf98d7cd2..f70a0b60864 100644
--- a/app/finders/concerns/finder_with_cross_project_access.rb
+++ b/app/finders/concerns/finder_with_cross_project_access.rb
@@ -14,6 +14,7 @@ module FinderWithCrossProjectAccess
end
override :execute
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(*args)
check = Gitlab::CrossProjectAccess.find_check(self)
original = super
@@ -27,6 +28,7 @@ module FinderWithCrossProjectAccess
original
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# We can skip the cross project check for finding indivitual records.
# this would be handled by the `can?(:read_*, result)` call in `FinderMethods`
diff --git a/app/finders/contributed_projects_finder.rb b/app/finders/contributed_projects_finder.rb
index a685719555c..1447def0cdf 100644
--- a/app/finders/contributed_projects_finder.rb
+++ b/app/finders/contributed_projects_finder.rb
@@ -10,11 +10,13 @@ class ContributedProjectsFinder < UnionFinder
# visible by this user.
#
# Returns an ActiveRecord::Relation.
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(current_user = nil)
segments = all_projects(current_user)
find_union(segments, Project).includes(:namespace).order_id_desc
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/finders/environments_finder.rb b/app/finders/environments_finder.rb
index a59f8c1efa3..95af6214c7d 100644
--- a/app/finders/environments_finder.rb
+++ b/app/finders/environments_finder.rb
@@ -5,6 +5,7 @@ class EnvironmentsFinder
@project, @current_user, @params = project, current_user, params
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
deployments = project.deployments
deployments =
@@ -42,6 +43,7 @@ class EnvironmentsFinder
environments
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/finders/events_finder.rb b/app/finders/events_finder.rb
index 8676925a540..a8d4f56a84c 100644
--- a/app/finders/events_finder.rb
+++ b/app/finders/events_finder.rb
@@ -36,32 +36,42 @@ class EventsFinder
private
+ # rubocop: disable CodeReuse/ActiveRecord
def by_current_user_access(events)
- events.merge(ProjectsFinder.new(current_user: current_user).execute)
+ events.merge(ProjectsFinder.new(current_user: current_user).execute) # rubocop: disable CodeReuse/Finder
.joins(:project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_action(events)
return events unless Event::ACTIONS[params[:action]]
events.where(action: Event::ACTIONS[params[:action]])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_target_type(events)
return events unless Event::TARGET_TYPES[params[:target_type]]
events.where(target_type: Event::TARGET_TYPES[params[:target_type]])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_created_at_before(events)
return events unless params[:before]
events.where('events.created_at < ?', params[:before].beginning_of_day)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_created_at_after(events)
return events unless params[:after]
events.where('events.created_at > ?', params[:after].end_of_day)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/fork_projects_finder.rb b/app/finders/fork_projects_finder.rb
index 28d1b31868e..8713d43136f 100644
--- a/app/finders/fork_projects_finder.rb
+++ b/app/finders/fork_projects_finder.rb
@@ -1,6 +1,8 @@
class ForkProjectsFinder < ProjectsFinder
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(project, params: {}, current_user: nil)
project_ids = project.forks.includes(:creator).select(:id)
super(params: params, current_user: current_user, project_ids_relation: project_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/group_descendants_finder.rb b/app/finders/group_descendants_finder.rb
index 2300b7fd114..15060a99930 100644
--- a/app/finders/group_descendants_finder.rb
+++ b/app/finders/group_descendants_finder.rb
@@ -61,12 +61,16 @@ class GroupDescendantsFinder
end
def direct_child_groups
+ # rubocop: disable CodeReuse/Finder
GroupsFinder.new(current_user,
parent: parent_group,
all_available: true).execute
+ # rubocop: enable CodeReuse/Finder
end
+ # rubocop: disable CodeReuse/ActiveRecord
def all_visible_descendant_groups
+ # rubocop: disable CodeReuse/Finder
groups_table = Group.arel_table
visible_to_user = groups_table[:visibility_level]
.in(Gitlab::VisibilityLevel.levels_for_user(current_user))
@@ -84,7 +88,9 @@ class GroupDescendantsFinder
hierarchy_for_parent
.descendants
.where(visible_to_user)
+ # rubocop: enable CodeReuse/Finder
end
+ # rubocop: enable CodeReuse/ActiveRecord
def subgroups_matching_filter
all_visible_descendant_groups
@@ -101,24 +107,29 @@ class GroupDescendantsFinder
#
# So when searching 'project', on the 'subgroup' page we want to preload
# 'nested-group' but not 'subgroup' or 'root'
+ # rubocop: disable CodeReuse/ActiveRecord
def ancestors_of_groups(base_for_ancestors)
group_ids = base_for_ancestors.except(:select, :sort).select(:id)
Gitlab::GroupHierarchy.new(Group.where(id: group_ids))
.base_and_ancestors(upto: parent_group.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def ancestors_of_filtered_projects
projects_to_load_ancestors_of = projects.where.not(namespace: parent_group)
groups_to_load_ancestors_of = Group.where(id: projects_to_load_ancestors_of.select(:namespace_id))
ancestors_of_groups(groups_to_load_ancestors_of)
.with_selects_for_list(archived: params[:archived])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def ancestors_of_filtered_subgroups
ancestors_of_groups(subgroups)
.with_selects_for_list(archived: params[:archived])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def subgroups
return Group.none unless Group.supports_nested_groups?
@@ -132,22 +143,29 @@ class GroupDescendantsFinder
groups.with_selects_for_list(archived: params[:archived]).order_by(sort)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/Finder
def direct_child_projects
GroupProjectsFinder.new(group: parent_group, current_user: current_user, params: params, options: { only_owned: true })
.execute
end
+ # rubocop: enable CodeReuse/Finder
# Finds all projects nested under `parent_group` or any of its descendant
# groups
+ # rubocop: disable CodeReuse/ActiveRecord
def projects_matching_filter
+ # rubocop: disable CodeReuse/Finder
projects_nested_in_group = Project.where(namespace_id: hierarchy_for_parent.base_and_descendants.select(:id))
params_with_search = params.merge(search: params[:filter])
ProjectsFinder.new(params: params_with_search,
current_user: current_user,
project_ids_relation: projects_nested_in_group).execute
+ # rubocop: enable CodeReuse/Finder
end
+ # rubocop: enable CodeReuse/ActiveRecord
def projects
projects = if params[:filter]
@@ -163,7 +181,9 @@ class GroupDescendantsFinder
params.fetch(:sort, 'id_asc')
end
+ # rubocop: disable CodeReuse/ActiveRecord
def hierarchy_for_parent
@hierarchy ||= Gitlab::GroupHierarchy.new(Group.where(id: parent_group.id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/group_finder.rb b/app/finders/group_finder.rb
index 24c84d2d1aa..8fde3a00af7 100644
--- a/app/finders/group_finder.rb
+++ b/app/finders/group_finder.rb
@@ -5,6 +5,7 @@ class GroupFinder
@current_user = current_user
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(*params)
group = Group.find_by(*params)
@@ -14,4 +15,5 @@ class GroupFinder
nil
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb
index 2a656c0d31c..cab1ff8fb98 100644
--- a/app/finders/group_members_finder.rb
+++ b/app/finders/group_members_finder.rb
@@ -3,6 +3,7 @@ class GroupMembersFinder
@group = group
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(include_descendants: false)
group_members = @group.members
wheres = []
@@ -29,4 +30,5 @@ class GroupMembersFinder
GroupMember.where(wheres.join(' OR '))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/group_projects_finder.rb b/app/finders/group_projects_finder.rb
index b6bdb2b7b0f..52a347fa598 100644
--- a/app/finders/group_projects_finder.rb
+++ b/app/finders/group_projects_finder.rb
@@ -82,6 +82,7 @@ class GroupProjectsFinder < ProjectsFinder
options.fetch(:include_subgroups, false)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def owned_projects
if include_subgroups?
Project.where(namespace_id: group.self_and_descendants.select(:id))
@@ -89,6 +90,7 @@ class GroupProjectsFinder < ProjectsFinder
group.projects
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def shared_projects
group.shared_projects
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb
index 0eeba1d2428..436abb332ff 100644
--- a/app/finders/groups_finder.rb
+++ b/app/finders/groups_finder.rb
@@ -38,6 +38,7 @@ class GroupsFinder < UnionFinder
attr_reader :current_user, :params
+ # rubocop: disable CodeReuse/ActiveRecord
def all_groups
return [owned_groups] if params[:owned]
return [groups_with_min_access_level] if min_access_level?
@@ -49,6 +50,7 @@ class GroupsFinder < UnionFinder
groups << Group.none if groups.empty?
groups
end
+ # rubocop: enable CodeReuse/ActiveRecord
def groups_for_ancestors
current_user.authorized_groups
@@ -58,6 +60,7 @@ class GroupsFinder < UnionFinder
current_user.groups
end
+ # rubocop: disable CodeReuse/ActiveRecord
def groups_with_min_access_level
groups = current_user
.groups
@@ -67,16 +70,21 @@ class GroupsFinder < UnionFinder
.new(groups)
.base_and_descendants
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_parent(groups)
return groups unless params[:parent]
groups.where(parent: params[:parent])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def owned_groups
current_user&.owned_groups || Group.none
end
+ # rubocop: enable CodeReuse/ActiveRecord
def include_public_groups?
current_user.nil? || all_available?
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index 372e2a96c2c..3308fd6d697 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -109,6 +109,7 @@ class IssuableFinder
# (even if that query is slower than any of the individual state queries) and
# grouping and counting within that query.
#
+ # rubocop: disable CodeReuse/ActiveRecord
def count_by_state
count_params = params.merge(state: nil, sort: nil)
finder = self.class.new(current_user, count_params)
@@ -132,6 +133,7 @@ class IssuableFinder
counts.with_indifferent_access
end
+ # rubocop: enable CodeReuse/ActiveRecord
def group
return @group if defined?(@group)
@@ -157,6 +159,7 @@ class IssuableFinder
@project = project
end
+ # rubocop: disable CodeReuse/ActiveRecord
def projects(items = nil)
return @projects = project if project?
@@ -165,13 +168,14 @@ class IssuableFinder
current_user.authorized_projects
elsif group
finder_options = { include_subgroups: params[:include_subgroups], only_owned: true }
- GroupProjectsFinder.new(group: group, current_user: current_user, options: finder_options).execute
+ GroupProjectsFinder.new(group: group, current_user: current_user, options: finder_options).execute # rubocop: disable CodeReuse/Finder
else
- ProjectsFinder.new(current_user: current_user).execute
+ ProjectsFinder.new(current_user: current_user).execute # rubocop: disable CodeReuse/Finder
end
@projects = projects.with_feature_available_for_user(klass, current_user).reorder(nil)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def search
params[:search].presence
@@ -185,6 +189,7 @@ class IssuableFinder
milestones? && params[:milestone_title] == Milestone::None.title
end
+ # rubocop: disable CodeReuse/ActiveRecord
def milestones
return @milestones if defined?(@milestones)
@@ -200,11 +205,12 @@ class IssuableFinder
search_params =
{ title: params[:milestone_title], project_ids: project_id, group_ids: group_id }
- MilestonesFinder.new(search_params).execute
+ MilestonesFinder.new(search_params).execute # rubocop: disable CodeReuse/Finder
else
Milestone.none
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def labels?
params[:label_name].present?
@@ -214,16 +220,18 @@ class IssuableFinder
labels? && params[:label_name].include?(Label::None.title)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def labels
return @labels if defined?(@labels)
@labels =
if labels? && !filter_by_no_label?
- LabelsFinder.new(current_user, project_ids: projects, title: label_names).execute(skip_authorization: true)
+ LabelsFinder.new(current_user, project_ids: projects, title: label_names).execute(skip_authorization: true) # rubocop: disable CodeReuse/Finder
else
Label.none
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def assignee_id?
params[:assignee_id].present? && params[:assignee_id] != NONE
@@ -238,6 +246,7 @@ class IssuableFinder
params[:assignee_id] == NONE || params[:assignee_username] == NONE
end
+ # rubocop: disable CodeReuse/ActiveRecord
def assignee
return @assignee if defined?(@assignee)
@@ -250,6 +259,7 @@ class IssuableFinder
nil
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def author_id?
params[:author_id].present? && params[:author_id] != NONE
@@ -264,6 +274,7 @@ class IssuableFinder
params[:author_id] == NONE || params[:author_username] == NONE
end
+ # rubocop: disable CodeReuse/ActiveRecord
def author
return @author if defined?(@author)
@@ -276,6 +287,7 @@ class IssuableFinder
nil
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -283,6 +295,7 @@ class IssuableFinder
klass.all
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_scope(items)
return items.none if current_user_related? && !current_user
@@ -295,6 +308,7 @@ class IssuableFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_updated_at(items)
items = items.updated_after(params[:updated_after]) if params[:updated_after].present?
@@ -303,6 +317,7 @@ class IssuableFinder
items
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_state(items)
case params[:state].to_s
when 'closed'
@@ -317,12 +332,14 @@ class IssuableFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_group(items)
# Selection by group is already covered by `by_project` and `projects`
items
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_project(items)
items =
if project?
@@ -335,6 +352,7 @@ class IssuableFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def use_cte_for_search?
return false unless search
@@ -343,6 +361,7 @@ class IssuableFinder
params[:use_cte_for_search]
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_search(items)
return items unless search
@@ -355,17 +374,23 @@ class IssuableFinder
items.full_search(search)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_iids(items)
params[:iids].present? ? items.where(iid: params[:iids]) : items
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def sort(items)
# Ensure we always have an explicit sort order (instead of inheriting
# multiple orders when combining ActiveRecord::Relation objects).
params[:sort] ? items.sort_by_attribute(params[:sort], excluded_labels: label_names) : items.reorder(id: :desc)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_assignee(items)
if assignee
items = items.where(assignee_id: assignee.id)
@@ -377,7 +402,9 @@ class IssuableFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_author(items)
if author
items = items.where(author_id: author.id)
@@ -389,6 +416,7 @@ class IssuableFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def filter_by_upcoming_milestone?
params[:milestone_title] == Milestone::Upcoming.name
@@ -398,6 +426,7 @@ class IssuableFinder
params[:milestone_title] == Milestone::Started.name
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_milestone(items)
if milestones?
if filter_by_no_milestone?
@@ -414,6 +443,7 @@ class IssuableFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_label(items)
return items unless labels?
diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb
index 24a6b9349a0..c347ef1ec19 100644
--- a/app/finders/issues_finder.rb
+++ b/app/finders/issues_finder.rb
@@ -29,10 +29,13 @@ class IssuesFinder < IssuableFinder
@scalar_params ||= super + [:due_date]
end
+ # rubocop: disable CodeReuse/ActiveRecord
def klass
Issue.includes(:author)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def with_confidentiality_access_check
return Issue.all if user_can_see_all_confidential_issues?
return Issue.where('issues.confidential IS NOT TRUE') if user_cannot_see_confidential_issues?
@@ -46,6 +49,7 @@ class IssuesFinder < IssuableFinder
user_id: current_user.id,
project_ids: current_user.authorized_projects(CONFIDENTIAL_ACCESS_LEVEL).select(:id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -125,6 +129,7 @@ class IssuesFinder < IssuableFinder
current_user.blank?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_assignee(items)
if assignee
items.assigned_to(assignee)
@@ -136,4 +141,5 @@ class IssuesFinder < IssuableFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index 1d05bf28438..690b00ae8d4 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -10,6 +10,7 @@ class LabelsFinder < UnionFinder
@params = params
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(skip_authorization: false)
@skip_authorization = skip_authorization
items = find_union(label_ids, Label) || Label.none
@@ -17,11 +18,13 @@ class LabelsFinder < UnionFinder
items = by_search(items)
sort(items)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
attr_reader :current_user, :params, :skip_authorization
+ # rubocop: disable CodeReuse/ActiveRecord
def label_ids
label_ids = []
@@ -52,17 +55,22 @@ class LabelsFinder < UnionFinder
label_ids
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def sort(items)
items.reorder(title: :asc)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def with_title(items)
return items if title.nil?
return items.none if title.blank?
items.where(title: title)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_search(labels)
return labels unless search?
@@ -134,13 +142,14 @@ class LabelsFinder < UnionFinder
@project
end
+ # rubocop: disable CodeReuse/ActiveRecord
def projects
return @projects if defined?(@projects)
@projects = if skip_authorization
Project.all
else
- ProjectsFinder.new(params: { non_archived: true }, current_user: current_user).execute
+ ProjectsFinder.new(params: { non_archived: true }, current_user: current_user).execute # rubocop: disable CodeReuse/Finder
end
@projects = @projects.in_namespace(params[:group_id]) if group?
@@ -149,6 +158,7 @@ class LabelsFinder < UnionFinder
@projects
end
+ # rubocop: enable CodeReuse/ActiveRecord
def authorized_to_read_labels?(label_parent)
return true if skip_authorization
diff --git a/app/finders/members_finder.rb b/app/finders/members_finder.rb
index 4c893ae2de6..58e3606692d 100644
--- a/app/finders/members_finder.rb
+++ b/app/finders/members_finder.rb
@@ -7,12 +7,13 @@ class MembersFinder
@group = project.group
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(include_descendants: false)
project_members = project.project_members
project_members = project_members.non_invite unless can?(current_user, :admin_project, project)
if group
- group_members = GroupMembersFinder.new(group).execute(include_descendants: include_descendants)
+ group_members = GroupMembersFinder.new(group).execute(include_descendants: include_descendants) # rubocop: disable CodeReuse/Finder
group_members = group_members.non_invite
union = Gitlab::SQL::Union.new([project_members, group_members], remove_duplicates: false)
@@ -24,6 +25,7 @@ class MembersFinder
project_members
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def can?(*args)
Ability.allowed?(*args)
diff --git a/app/finders/merge_request_target_project_finder.rb b/app/finders/merge_request_target_project_finder.rb
index 188ec447a94..66d4c4018f3 100644
--- a/app/finders/merge_request_target_project_finder.rb
+++ b/app/finders/merge_request_target_project_finder.rb
@@ -8,6 +8,7 @@ class MergeRequestTargetProjectFinder
@source_project = source_project
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
if @source_project.fork_network
@source_project.fork_network.projects
@@ -18,4 +19,5 @@ class MergeRequestTargetProjectFinder
Project.where(id: source_project)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/merge_requests_finder.rb b/app/finders/merge_requests_finder.rb
index 40089c082c1..c6403f8f25d 100644
--- a/app/finders/merge_requests_finder.rb
+++ b/app/finders/merge_requests_finder.rb
@@ -41,19 +41,23 @@ class MergeRequestsFinder < IssuableFinder
@source_branch ||= params[:source_branch].presence
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_source_branch(items)
return items unless source_branch
items.where(source_branch: source_branch)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def target_branch
@target_branch ||= params[:target_branch].presence
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_target_branch(items)
return items unless target_branch
items.where(target_branch: target_branch)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/milestones_finder.rb b/app/finders/milestones_finder.rb
index f5d2b9f253a..7dc2a5b0b66 100644
--- a/app/finders/milestones_finder.rb
+++ b/app/finders/milestones_finder.rb
@@ -18,6 +18,7 @@ class MilestonesFinder
@params = params
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
return Milestone.none if project_ids.empty? && group_ids.empty?
@@ -28,6 +29,7 @@ class MilestonesFinder
order(items)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -35,6 +37,7 @@ class MilestonesFinder
items.for_projects_and_groups(project_ids, group_ids)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_title(items)
if params[:title]
items.where(title: params[:title])
@@ -42,13 +45,16 @@ class MilestonesFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_state(items)
Milestone.filter_by_state(items, params[:state])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def order(items)
order_statement = Gitlab::Database.nulls_last_order('due_date', 'ASC')
items.reorder(order_statement).order('title ASC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb
index 9b7a35fb3b5..580984329a1 100644
--- a/app/finders/notes_finder.rb
+++ b/app/finders/notes_finder.rb
@@ -65,21 +65,23 @@ class NotesFinder
@params[:target_type]
end
+ # rubocop: disable CodeReuse/ActiveRecord
def notes_of_any_type
types = %w(commit issue merge_request snippet)
note_relations = types.map { |t| notes_for_type(t) }
note_relations.map! { |notes| search(notes) }
- UnionFinder.new.find_union(note_relations, Note.includes(:author))
+ UnionFinder.new.find_union(note_relations, Note.includes(:author)) # rubocop: disable CodeReuse/Finder
end
+ # rubocop: enable CodeReuse/ActiveRecord
def noteables_for_type(noteable_type)
case noteable_type
when "issue"
- IssuesFinder.new(@current_user, project_id: @project.id).execute
+ IssuesFinder.new(@current_user, project_id: @project.id).execute # rubocop: disable CodeReuse/Finder
when "merge_request"
- MergeRequestsFinder.new(@current_user, project_id: @project.id).execute
+ MergeRequestsFinder.new(@current_user, project_id: @project.id).execute # rubocop: disable CodeReuse/Finder
when "snippet", "project_snippet"
- SnippetsFinder.new(@current_user, project: @project).execute
+ SnippetsFinder.new(@current_user, project: @project).execute # rubocop: disable CodeReuse/Finder
when "personal_snippet"
PersonalSnippet.all
else
@@ -87,6 +89,7 @@ class NotesFinder
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def notes_for_type(noteable_type)
if noteable_type == "commit"
if Ability.allowed?(@current_user, :download_code, @project)
@@ -99,6 +102,7 @@ class NotesFinder
@project.notes.where(noteable_type: finder.base_class.name, noteable_id: finder.reorder(nil))
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def notes_on_target
if target.respond_to?(:related_notes)
diff --git a/app/finders/personal_access_tokens_finder.rb b/app/finders/personal_access_tokens_finder.rb
index d975f354a88..6b610ffc687 100644
--- a/app/finders/personal_access_tokens_finder.rb
+++ b/app/finders/personal_access_tokens_finder.rb
@@ -16,11 +16,13 @@ class PersonalAccessTokensFinder
private
+ # rubocop: disable CodeReuse/ActiveRecord
def by_user(tokens)
return tokens unless @params[:user]
tokens.where(user: @params[:user])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_impersonation(tokens)
case @params[:impersonation]
diff --git a/app/finders/personal_projects_finder.rb b/app/finders/personal_projects_finder.rb
index a56a3a1e1a9..16e4e060786 100644
--- a/app/finders/personal_projects_finder.rb
+++ b/app/finders/personal_projects_finder.rb
@@ -15,6 +15,7 @@ class PersonalProjectsFinder < UnionFinder
# min_access_level: integer
#
# Returns an ActiveRecord::Relation.
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(current_user = nil)
return Project.none unless can?(current_user, :read_user_profile, @user)
@@ -22,6 +23,7 @@ class PersonalProjectsFinder < UnionFinder
find_union(segments, Project).includes(:namespace).order_updated_desc
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/finders/pipeline_schedules_finder.rb b/app/finders/pipeline_schedules_finder.rb
index 2ac4289fbbe..d131e1659c1 100644
--- a/app/finders/pipeline_schedules_finder.rb
+++ b/app/finders/pipeline_schedules_finder.rb
@@ -6,6 +6,7 @@ class PipelineSchedulesFinder
@pipeline_schedules = project.pipeline_schedules
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(scope: nil)
scoped_schedules =
case scope
@@ -19,4 +20,5 @@ class PipelineSchedulesFinder
scoped_schedules.order(id: :desc)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb
index a99a889a7e9..b03d730f975 100644
--- a/app/finders/pipelines_finder.rb
+++ b/app/finders/pipelines_finder.rb
@@ -10,6 +10,7 @@ class PipelinesFinder
@params = params
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
unless Ability.allowed?(current_user, :read_pipeline, project)
return Ci::Pipeline.none
@@ -25,16 +26,21 @@ class PipelinesFinder
items = by_yaml_errors(items)
sort_items(items)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def ids_for_ref(refs)
pipelines.where(ref: refs).group(:ref).select('max(id)')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def from_ids(ids)
pipelines.unscoped.where(id: ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def branches
project.repository.branch_names
@@ -61,12 +67,15 @@ class PipelinesFinder
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_status(items)
return items unless HasStatus::AVAILABLE_STATUSES.include?(params[:status])
items.where(status: params[:status])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_ref(items)
if params[:ref].present?
items.where(ref: params[:ref])
@@ -74,7 +83,9 @@ class PipelinesFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_sha(items)
if params[:sha].present?
items.where(sha: params[:sha])
@@ -82,7 +93,9 @@ class PipelinesFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_name(items)
if params[:name].present?
items.joins(:user).where(users: { name: params[:name] })
@@ -90,7 +103,9 @@ class PipelinesFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_username(items)
if params[:username].present?
items.joins(:user).where(users: { username: params[:username] })
@@ -98,7 +113,9 @@ class PipelinesFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_yaml_errors(items)
case Gitlab::Utils.to_boolean(params[:yaml_errors])
when true
@@ -109,7 +126,9 @@ class PipelinesFinder
items
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def sort_items(items)
order_by = if ALLOWED_INDEXED_COLUMNS.include?(params[:order_by])
params[:order_by]
@@ -125,4 +144,5 @@ class PipelinesFinder
items.order(order_by => sort)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb
index cac6643eff3..99116c0d31a 100644
--- a/app/finders/projects_finder.rb
+++ b/app/finders/projects_finder.rb
@@ -35,7 +35,7 @@ class ProjectsFinder < UnionFinder
user = params.delete(:user)
collection =
if user
- PersonalProjectsFinder.new(user, finder_params).execute(current_user)
+ PersonalProjectsFinder.new(user, finder_params).execute(current_user) # rubocop: disable CodeReuse/Finder
else
init_collection
end
@@ -63,6 +63,7 @@ class ProjectsFinder < UnionFinder
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def collection_with_user
if owned_projects?
current_user.owned_projects
@@ -76,8 +77,10 @@ class ProjectsFinder < UnionFinder
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Builds a collection for an anonymous user.
+ # rubocop: disable CodeReuse/ActiveRecord
def collection_without_user
if private_only? || owned_projects? || min_access_level?
Project.none
@@ -85,6 +88,7 @@ class ProjectsFinder < UnionFinder
Project.public_to_user
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def owned_projects?
params[:owned].present?
@@ -98,9 +102,11 @@ class ProjectsFinder < UnionFinder
params[:min_access_level].present?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_ids(items)
project_ids_relation ? items.where(id: project_ids_relation) : items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def union(items)
find_union(items, Project).with_route
@@ -118,9 +124,11 @@ class ProjectsFinder < UnionFinder
params[:trending].present? ? items.trending : items
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_visibilty_level(items)
params[:visibility_level].present? ? items.where(visibility_level: params[:visibility_level]) : items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_tags(items)
params[:tag].present? ? items.tagged_with(params[:tag]) : items
diff --git a/app/finders/runner_jobs_finder.rb b/app/finders/runner_jobs_finder.rb
index 52340f94523..d4f2474197f 100644
--- a/app/finders/runner_jobs_finder.rb
+++ b/app/finders/runner_jobs_finder.rb
@@ -14,9 +14,11 @@ class RunnerJobsFinder
private
+ # rubocop: disable CodeReuse/ActiveRecord
def by_status(items)
return items unless HasStatus::AVAILABLE_STATUSES.include?(params[:status])
items.where(status: params[:status])
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb
index 9d3772d7541..32da3e8f404 100644
--- a/app/finders/snippets_finder.rb
+++ b/app/finders/snippets_finder.rb
@@ -41,6 +41,7 @@ class SnippetsFinder < UnionFinder
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def authorized_snippets_from_project
if can?(current_user, :read_project_snippet, project)
if project.team.member?(current_user)
@@ -52,7 +53,9 @@ class SnippetsFinder < UnionFinder
Snippet.none
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def authorized_snippets
# This query was intentionally converted to a raw one to get it work in Rails 5.0.
# In Rails 5.0 and 5.1 there's a bug: https://github.com/rails/arel/issues/531
@@ -60,6 +63,7 @@ class SnippetsFinder < UnionFinder
Snippet.where("#{feature_available_projects} OR #{not_project_related}")
.public_or_visible_to_user(current_user)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Returns a collection of projects that is either public or visible to the
# logged in user.
@@ -68,6 +72,7 @@ class SnippetsFinder < UnionFinder
# the query, e.g. to apply .with_feature_available_for_user on top of it.
# This is useful for performance as we can stick those additional filters
# at the bottom of e.g. the UNION.
+ # rubocop: disable CodeReuse/ActiveRecord
def projects_for_user
return yield(Project.public_to_user) unless current_user
@@ -86,6 +91,7 @@ class SnippetsFinder < UnionFinder
Project.from("(#{union.to_sql}) AS #{Project.table_name}")
end
+ # rubocop: enable CodeReuse/ActiveRecord
def feature_available_projects
# Don't return any project related snippets if the user cannot read cross project
@@ -109,6 +115,7 @@ class SnippetsFinder < UnionFinder
Snippet.arel_table
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_visibility(items)
visibility = params[:visibility] || visibility_from_scope
@@ -116,12 +123,15 @@ class SnippetsFinder < UnionFinder
items.where(visibility_level: visibility)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_author(items)
return items unless params[:author]
items.where(author_id: params[:author].id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def visibility_from_scope
case params[:scope].to_s
diff --git a/app/finders/template_finder.rb b/app/finders/template_finder.rb
index ea0251bffb6..7cdc7a32acc 100644
--- a/app/finders/template_finder.rb
+++ b/app/finders/template_finder.rb
@@ -8,7 +8,7 @@ class TemplateFinder
class << self
def build(type, params = {})
if type == :licenses
- LicenseTemplateFinder.new(params)
+ LicenseTemplateFinder.new(params) # rubocop: disable CodeReuse/Finder
else
new(type, params)
end
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index 6e9c8ea6fde..6481893a195 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -120,6 +120,7 @@ class TodosFinder
params[:sort] ? items.sort_by_attribute(params[:sort]) : items.order_id_desc
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_action(items)
if action?
items = items.where(action: to_action_id)
@@ -127,7 +128,9 @@ class TodosFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_action_id(items)
if action_id?
items = items.where(action: action_id)
@@ -135,7 +138,9 @@ class TodosFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_author(items)
if author?
items = items.where(author_id: author.try(:id))
@@ -143,7 +148,9 @@ class TodosFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_project(items)
if project?
items = items.where(project: project)
@@ -151,7 +158,9 @@ class TodosFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_group(items)
if group?
groups = group.self_and_descendants
@@ -164,6 +173,7 @@ class TodosFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_state(items)
case params[:state].to_s
@@ -174,6 +184,7 @@ class TodosFinder
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_type(items)
if type?
items = items.where(target_type: type)
@@ -181,4 +192,5 @@ class TodosFinder
items
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/union_finder.rb b/app/finders/union_finder.rb
index 33cd1a491f3..91b845871a8 100644
--- a/app/finders/union_finder.rb
+++ b/app/finders/union_finder.rb
@@ -1,4 +1,5 @@
class UnionFinder
+ # rubocop: disable CodeReuse/ActiveRecord
def find_union(segments, klass)
if segments.length > 1
union = Gitlab::SQL::Union.new(segments.map { |s| s.select(:id) })
@@ -8,4 +9,5 @@ class UnionFinder
segments.first
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/user_finder.rb b/app/finders/user_finder.rb
index 484a93c9873..815388c894e 100644
--- a/app/finders/user_finder.rb
+++ b/app/finders/user_finder.rb
@@ -14,9 +14,11 @@ class UserFinder
end
# Tries to find a User, returning nil if none could be found.
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
User.find_by(id: params[:id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Tries to find a User, raising a `ActiveRecord::RecordNotFound` if it could
# not be found.
diff --git a/app/finders/user_recent_events_finder.rb b/app/finders/user_recent_events_finder.rb
index b874f6959c9..7405d6d27d9 100644
--- a/app/finders/user_recent_events_finder.rb
+++ b/app/finders/user_recent_events_finder.rb
@@ -21,6 +21,7 @@ class UserRecentEventsFinder
@params = params
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
return Event.none unless can?(current_user, :read_user_profile, target_user)
@@ -29,9 +30,11 @@ class UserRecentEventsFinder
.with_associations
.limit_recent(LIMIT, params[:offset])
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def recent_events(offset)
sql = <<~SQL
(#{projects}) AS projects_for_join
@@ -42,10 +45,13 @@ class UserRecentEventsFinder
# Workaround for https://github.com/rails/rails/issues/24193
Event.from([Arel.sql(sql)])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def target_events
Event.where(author: target_user)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def projects
target_user.project_interactions.to_sql
diff --git a/app/finders/users_finder.rb b/app/finders/users_finder.rb
index 65824a51919..46672301851 100644
--- a/app/finders/users_finder.rb
+++ b/app/finders/users_finder.rb
@@ -41,11 +41,13 @@ class UsersFinder
private
+ # rubocop: disable CodeReuse/ActiveRecord
def by_username(users)
return users unless params[:username]
users.where(username: params[:username])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_search(users)
return users unless params[:search].present?
@@ -65,18 +67,22 @@ class UsersFinder
users.active
end
+ # rubocop: disable CodeReuse/ActiveRecord
def by_external_identity(users)
return users unless current_user&.admin? && params[:extern_uid] && params[:provider]
users.joins(:identities).merge(Identity.with_extern_uid(params[:provider], params[:extern_uid]))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def by_external(users)
return users = users.where.not(external: true) unless current_user&.admin?
return users unless params[:external]
users.external
end
+ # rubocop: enable CodeReuse/ActiveRecord
def by_2fa(users)
case params[:two_factor]
diff --git a/app/graphql/resolvers/merge_request_resolver.rb b/app/graphql/resolvers/merge_request_resolver.rb
index 9f2d348e95f..6b7d0ce6e24 100644
--- a/app/graphql/resolvers/merge_request_resolver.rb
+++ b/app/graphql/resolvers/merge_request_resolver.rb
@@ -8,6 +8,7 @@ module Resolvers
alias_method :project, :object
+ # rubocop: disable CodeReuse/ActiveRecord
def resolve(iid:)
return unless project.present?
@@ -16,5 +17,6 @@ module Resolvers
results.each { |mr| loader.call(mr.iid.to_s, mr) }
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index bb7ae03313c..bb401b03709 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -5,9 +5,11 @@ require 'uri'
module ApplicationHelper
# See https://docs.gitlab.com/ee/development/ee_features.html#code-in-app-views
+ # rubocop: disable CodeReuse/ActiveRecord
def render_if_exists(partial, locals = {})
render(partial, locals) if lookup_context.exists?(partial, [], true)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Check if a particular controller is the current one
#
@@ -51,6 +53,7 @@ module ApplicationHelper
# Define whenever show last push event
# with suggestion to create MR
+ # rubocop: disable CodeReuse/ActiveRecord
def show_last_push_widget?(event)
# Skip if event is not about added or modified non-master branch
return false unless event && event.last_push_to_non_root? && !event.rm_ref?
@@ -68,6 +71,7 @@ module ApplicationHelper
true
end
+ # rubocop: enable CodeReuse/ActiveRecord
def hexdigest(string)
Digest::SHA1.hexdigest string
diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb
index c17a54a6dff..c158cf20dd6 100644
--- a/app/helpers/auth_helper.rb
+++ b/app/helpers/auth_helper.rb
@@ -66,9 +66,11 @@ module AuthHelper
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def auth_active?(provider)
current_user.identities.exists?(provider: provider.to_s)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def unlink_allowed?(provider)
%w(saml cas3).exclude?(provider.to_s)
diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb
index 62fc6fb279f..516c8a353ea 100644
--- a/app/helpers/auto_devops_helper.rb
+++ b/app/helpers/auto_devops_helper.rb
@@ -26,6 +26,7 @@ module AutoDevopsHelper
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def cluster_ingress_ip(project)
project
.cluster_ingresses
@@ -34,6 +35,7 @@ module AutoDevopsHelper
.pluck(:external_ip)
.first
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 7684734c014..b6844d36052 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -213,9 +213,11 @@ module DiffHelper
params[:w] == '1'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def params_with_whitespace
hide_whitespace? ? request.query_parameters.except(:w) : request.query_parameters.merge(w: 1)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def toggle_whitespace_link(url, options)
options[:class] = [*options[:class], 'btn btn-default'].join(' ')
diff --git a/app/helpers/environment_helper.rb b/app/helpers/environment_helper.rb
index 4b3ef2de701..2b7320817ed 100644
--- a/app/helpers/environment_helper.rb
+++ b/app/helpers/environment_helper.rb
@@ -1,11 +1,13 @@
# frozen_string_literal: true
module EnvironmentHelper
+ # rubocop: disable CodeReuse/ActiveRecord
def environment_for_build(project, build)
return unless build.environment
project.environments.find_by(name: build.expanded_environment_name)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def environment_link_for_build(project, build)
environment = environment_for_build(project, build)
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index 8396cfe0ac8..1f67c045d1c 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -107,6 +107,7 @@ module IssuablesHelper
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def user_dropdown_label(user_id, default_label)
return default_label if user_id.nil?
return "Unassigned" if user_id == "0"
@@ -119,7 +120,9 @@ module IssuablesHelper
default_label
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def project_dropdown_label(project_id, default_label)
return default_label if project_id.nil?
return "Any project" if project_id == "0"
@@ -132,7 +135,9 @@ module IssuablesHelper
default_label
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def group_dropdown_label(group_id, default_label)
return default_label if group_id.nil?
return "Any group" if group_id == "0"
@@ -145,6 +150,7 @@ module IssuablesHelper
default_label
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def milestone_dropdown_label(milestone_title, default_label = "Milestone")
title =
@@ -191,11 +197,13 @@ module IssuablesHelper
output.join.html_safe
end
+ # rubocop: disable CodeReuse/ActiveRecord
def issuable_todo(issuable)
if current_user
current_user.todos.find_by(target: issuable, state: :pending)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index { |_, i| i < limit }
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb
index 999143002bb..94a030d9d57 100644
--- a/app/helpers/milestones_helper.rb
+++ b/app/helpers/milestones_helper.rb
@@ -53,6 +53,7 @@ module MilestonesHelper
# Returns count of milestones for different states
# Uses explicit hash keys as the 'opened' state URL params differs from the db value
# and we need to add the total
+ # rubocop: disable CodeReuse/ActiveRecord
def milestone_counts(milestones)
counts = milestones.reorder(nil).group(:state).count
@@ -62,6 +63,7 @@ module MilestonesHelper
all: counts.values.sum || 0
}
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Show 'active' class if provided GET param matches check
# `or_blank` allows the function to return 'active' when given an empty param
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index e7537ca5733..6c65e573307 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -5,6 +5,7 @@ module NamespacesHelper
params.dig(:project, :namespace_id) || params[:namespace_id]
end
+ # rubocop: disable CodeReuse/ActiveRecord
def namespaces_options(selected = :current_user, display_path: false, groups: nil, extra_group: nil, groups_only: false)
groups ||= current_user.manageable_groups
.eager_load(:route)
@@ -42,6 +43,7 @@ module NamespacesHelper
grouped_options_for_select(options, selected_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def namespace_icon(namespace, size = 40)
if namespace.is_a?(Group)
@@ -55,6 +57,7 @@ module NamespacesHelper
# Many importers create a temporary Group, so use the real
# group if one exists by that name to prevent duplicates.
+ # rubocop: disable CodeReuse/ActiveRecord
def dedup_extra_group(extra_group)
unless extra_group.persisted?
existing_group = Group.find_by(path: extra_group.path)
@@ -63,6 +66,7 @@ module NamespacesHelper
extra_group
end
+ # rubocop: enable CodeReuse/ActiveRecord
def options_for_group(namespaces, display_path:, type:)
group_label = type.pluralize
diff --git a/app/helpers/numbers_helper.rb b/app/helpers/numbers_helper.rb
index f609b6c0cec..3c0b11c4d32 100644
--- a/app/helpers/numbers_helper.rb
+++ b/app/helpers/numbers_helper.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
module NumbersHelper
+ # rubocop: disable CodeReuse/ActiveRecord
def limited_counter_with_delimiter(resource, **options)
limit = options.fetch(:limit, 1000).to_i
count = resource.limit(limit + 1).count(:all)
@@ -10,4 +11,5 @@ module NumbersHelper
number_with_delimiter(count, options)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 89fee06ee77..8b17e6ef75d 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -222,6 +222,7 @@ module ProjectsHelper
#
# If no limit is applied we'll just issue a COUNT since the result set could
# be too large to load into memory.
+ # rubocop: disable CodeReuse/ActiveRecord
def any_projects?(projects)
return projects.any? if projects.is_a?(Array)
@@ -231,6 +232,7 @@ module ProjectsHelper
projects.except(:offset).any?
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def show_projects?(projects, params)
!!(params[:personal] || params[:name] || any_projects?(projects))
diff --git a/app/helpers/safe_params_helper.rb b/app/helpers/safe_params_helper.rb
index 72bf1377b02..18bbf3347a8 100644
--- a/app/helpers/safe_params_helper.rb
+++ b/app/helpers/safe_params_helper.rb
@@ -3,6 +3,7 @@
module SafeParamsHelper
# Rails 5.0 requires to permit `params` if they're used in url helpers.
# Use this helper when generating links with `params.merge(...)`
+ # rubocop: disable CodeReuse/ActiveRecord
def safe_params
if params.respond_to?(:permit!)
params.except(:host, :port, :protocol).permit!
@@ -10,4 +11,5 @@ module SafeParamsHelper
params
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index c509cd592c4..4f9e1322b56 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -101,6 +101,7 @@ module SearchHelper
end
# Autocomplete results for the current user's groups
+ # rubocop: disable CodeReuse/ActiveRecord
def groups_autocomplete(term, limit = 5)
current_user.authorized_groups.order_id_desc.search(term).limit(limit).map do |group|
{
@@ -112,8 +113,10 @@ module SearchHelper
}
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Autocomplete results for the current user's projects
+ # rubocop: disable CodeReuse/ActiveRecord
def projects_autocomplete(term, limit = 5)
current_user.authorized_projects.order_id_desc.search_by_title(term)
.sorted_by_stars.non_archived.limit(limit).map do |p|
@@ -127,6 +130,7 @@ module SearchHelper
}
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def search_result_sanitize(str)
Sanitize.clean(str)
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index 80f61a371fd..6d2da5699fb 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -7,6 +7,7 @@ module TreeHelper
# their corresponding partials
#
# tree - A `Tree` object for the current tree
+ # rubocop: disable CodeReuse/ActiveRecord
def render_tree(tree)
# Sort submodules and folders together by name ahead of files
folders, files, submodules = tree.trees, tree.blobs, tree.submodules
@@ -22,6 +23,7 @@ module TreeHelper
tree << render(partial: 'projects/tree/tree_row', collection: items) if items.present?
tree.join.html_safe
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Return an image icon depending on the file type and mode
#
@@ -124,6 +126,7 @@ module TreeHelper
end
# returns the relative path of the first subdir that doesn't have only one directory descendant
+ # rubocop: disable CodeReuse/ActiveRecord
def flatten_tree(root_path, tree)
return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present?
@@ -134,6 +137,7 @@ module TreeHelper
return tree.name
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def selected_branch
@branch_name || tree_edit_branch
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb
index c8b1ab5033a..602e5afe26b 100644
--- a/app/mailers/emails/issues.rb
+++ b/app/mailers/emails/issues.rb
@@ -19,6 +19,7 @@ module Emails
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_ids, updated_by_user_id, reason = nil)
setup_issue_mail(issue_id, recipient_id)
@@ -27,6 +28,7 @@ module Emails
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason))
end
+ # rubocop: enable CodeReuse/ActiveRecord
def closed_issue_email(recipient_id, issue_id, updated_by_user_id, reason = nil)
setup_issue_mail(issue_id, recipient_id)
diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb
index 70f65d4e58d..67af0a4eb98 100644
--- a/app/mailers/emails/merge_requests.rb
+++ b/app/mailers/emails/merge_requests.rb
@@ -22,12 +22,14 @@ module Emails
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id, updated_by_user_id, reason = nil)
setup_merge_request_mail(merge_request_id, recipient_id)
@previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason))
end
+ # rubocop: enable CodeReuse/ActiveRecord
def relabeled_merge_request_email(recipient_id, merge_request_id, label_names, updated_by_user_id, reason = nil)
setup_merge_request_mail(merge_request_id, recipient_id)
diff --git a/app/mailers/emails/profile.rb b/app/mailers/emails/profile.rb
index 40d7b9ccd7a..2ea1aea1f51 100644
--- a/app/mailers/emails/profile.rb
+++ b/app/mailers/emails/profile.rb
@@ -9,6 +9,7 @@ module Emails
mail(to: @user.notification_email, subject: subject("Account was created for you"))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def new_ssh_key_email(key_id)
@key = Key.find_by(id: key_id)
@@ -18,7 +19,9 @@ module Emails
@target_url = user_url(@user)
mail(to: @user.notification_email, subject: subject("SSH key was added to your account"))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def new_gpg_key_email(gpg_key_id)
@gpg_key = GpgKey.find_by(id: gpg_key_id)
@@ -28,5 +31,6 @@ module Emails
@target_url = user_url(@user)
mail(to: @user.notification_email, subject: subject("GPG key was added to your account"))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/mailers/repository_check_mailer.rb b/app/mailers/repository_check_mailer.rb
index 4bcf371cfc0..145169be8a6 100644
--- a/app/mailers/repository_check_mailer.rb
+++ b/app/mailers/repository_check_mailer.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
class RepositoryCheckMailer < BaseMailer
+ # rubocop: disable CodeReuse/ActiveRecord
def notify(failed_count)
@message =
if failed_count == 1
@@ -14,4 +15,5 @@ class RepositoryCheckMailer < BaseMailer
subject: "GitLab Admin | #{@message}"
)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index faa160ad6ba..42d30d56aa2 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -139,9 +139,11 @@ module Ci
end
def retry(build, current_user)
+ # rubocop: disable CodeReuse/ServiceClass
Ci::RetryBuildService
.new(build.project, current_user)
.execute(build)
+ # rubocop: enable CodeReuse/ServiceClass
end
end
@@ -224,11 +226,13 @@ module Ci
self.when == 'manual'
end
+ # rubocop: disable CodeReuse/ServiceClass
def play(current_user)
Ci::PlayBuildService
.new(project, current_user)
.execute(self)
end
+ # rubocop: enable CodeReuse/ServiceClass
def cancelable?
active? || created?
@@ -385,9 +389,11 @@ module Ci
update(coverage: coverage) if coverage.present?
end
+ # rubocop: disable CodeReuse/ServiceClass
def parse_trace_sections!
ExtractSectionsFromBuildTraceService.new(project, user).execute(self)
end
+ # rubocop: enable CodeReuse/ServiceClass
def trace
Gitlab::Ci::Trace.new(self)
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 2955e0b2bca..4295c46e689 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -387,10 +387,12 @@ module Ci
end
end
+ # rubocop: disable CodeReuse/ServiceClass
def retry_failed(current_user)
Ci::RetryPipelineService.new(project, current_user)
.execute(self)
end
+ # rubocop: enable CodeReuse/ServiceClass
def mark_as_processable_after_stage(stage_idx)
builds.skipped.after_stage(stage_idx).find_each(&:process)
@@ -525,9 +527,11 @@ module Ci
project.notes.for_commit_id(sha)
end
+ # rubocop: disable CodeReuse/ServiceClass
def process!
Ci::ProcessPipelineService.new(project, user).execute(self)
end
+ # rubocop: enable CodeReuse/ServiceClass
def update_status
retry_optimistic_lock(self) do
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index b65d7672973..fe2f144ef03 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -58,9 +58,11 @@ class CommitStatus < ActiveRecord::Base
# These are pages deployments and external statuses.
#
before_create unless: :importing? do
+ # rubocop: disable CodeReuse/ServiceClass
Ci::EnsureStageService.new(project, user).execute(self) do |stage|
self.run_after_commit { StageUpdateWorker.perform_async(stage.id) }
end
+ # rubocop: enable CodeReuse/ServiceClass
end
state_machine :status do
@@ -130,10 +132,12 @@ class CommitStatus < ActiveRecord::Base
after_transition any => :failed do |commit_status|
next unless commit_status.project
+ # rubocop: disable CodeReuse/ServiceClass
commit_status.run_after_commit do
MergeRequests::AddTodoWhenBuildFailsService
.new(project, nil).execute(self)
end
+ # rubocop: enable CodeReuse/ServiceClass
end
end
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb
index 41413854d5c..93ca3a5daf4 100644
--- a/app/models/container_repository.rb
+++ b/app/models/container_repository.rb
@@ -10,6 +10,7 @@ class ContainerRepository < ActiveRecord::Base
before_destroy :delete_tags!
+ # rubocop: disable CodeReuse/ServiceClass
def registry
@registry ||= begin
token = Auth::ContainerRegistryAuthenticationService.full_access_token(path)
@@ -20,6 +21,7 @@ class ContainerRepository < ActiveRecord::Base
ContainerRegistry::Registry.new(url, token: token, path: host_port)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def path
@path ||= [project.full_path, name]
diff --git a/app/models/dashboard_group_milestone.rb b/app/models/dashboard_group_milestone.rb
index 13807d43265..4e39f60b0d2 100644
--- a/app/models/dashboard_group_milestone.rb
+++ b/app/models/dashboard_group_milestone.rb
@@ -13,7 +13,7 @@ class DashboardGroupMilestone < GlobalMilestone
end
def self.build_collection(groups)
- MilestonesFinder.new(group_ids: groups.pluck(:id)).execute.map { |m| new(m) }
+ MilestonesFinder.new(group_ids: groups.pluck(:id)).execute.map { |m| new(m) } # rubocop: disable CodeReuse/Finder
end
override :group_milestone?
diff --git a/app/models/environment.rb b/app/models/environment.rb
index c8d1d378ae0..309bd4f37c9 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -158,9 +158,11 @@ class Environment < ActiveRecord::Base
prometheus_adapter.query(:additional_metrics_environment, self) if has_metrics?
end
+ # rubocop: disable CodeReuse/ServiceClass
def prometheus_adapter
@prometheus_adapter ||= Prometheus::AdapterService.new(project, deployment_platform).prometheus_adapter
end
+ # rubocop: enable CodeReuse/ServiceClass
def slug
super.presence || generate_slug
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb
index 6e23e811b0e..a6cebabe089 100644
--- a/app/models/global_milestone.rb
+++ b/app/models/global_milestone.rb
@@ -17,7 +17,7 @@ class GlobalMilestone
params =
{ project_ids: projects.map(&:id), state: params[:state] }
- child_milestones = MilestonesFinder.new(params).execute
+ child_milestones = MilestonesFinder.new(params).execute # rubocop: disable CodeReuse/Finder
milestones = child_milestones.select(:id, :title).group_by(&:title).map do |title, grouped|
milestones_relation = Milestone.where(id: grouped.map(&:id))
@@ -48,7 +48,7 @@ class GlobalMilestone
params = { group_ids: [group.id], state: 'all' }
- relation = MilestonesFinder.new(params).execute
+ relation = MilestonesFinder.new(params).execute # rubocop: disable CodeReuse/Finder
grouped_by_state = relation.reorder(nil).group(:state).count
{
@@ -64,7 +64,7 @@ class GlobalMilestone
params = { project_ids: projects.map(&:id), state: 'all' }
- relation = MilestonesFinder.new(params).execute
+ relation = MilestonesFinder.new(params).execute # rubocop: disable CodeReuse/Finder
project_milestones_by_state_and_title = relation.reorder(nil).group(:state, :title).count
opened = count_by_state(project_milestones_by_state_and_title, 'active')
diff --git a/app/models/group.rb b/app/models/group.rb
index 106a1f4a94c..024e77188b8 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -236,14 +236,18 @@ class Group < Namespace
system_hook_service.execute_hooks_for(self, :destroy)
end
+ # rubocop: disable CodeReuse/ServiceClass
def system_hook_service
SystemHooksService.new
end
+ # rubocop: enable CodeReuse/ServiceClass
+ # rubocop: disable CodeReuse/ServiceClass
def refresh_members_authorized_projects(blocking: true)
UserProjectAccessChangedService.new(user_ids_for_project_authorizations)
.execute(blocking: blocking)
end
+ # rubocop: enable CodeReuse/ServiceClass
def user_ids_for_project_authorizations
members_with_parents.pluck(:user_id)
diff --git a/app/models/hooks/service_hook.rb b/app/models/hooks/service_hook.rb
index bda82a116a1..7d9f6d89d44 100644
--- a/app/models/hooks/service_hook.rb
+++ b/app/models/hooks/service_hook.rb
@@ -4,7 +4,9 @@ class ServiceHook < WebHook
belongs_to :service
validates :service, presence: true
+ # rubocop: disable CodeReuse/ServiceClass
def execute(data)
WebHookService.new(self, data, 'service_hook').execute
end
+ # rubocop: enable CodeReuse/ServiceClass
end
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index 20f15c15277..771a61b090f 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -11,13 +11,17 @@ class WebHook < ActiveRecord::Base
validates :token, format: { without: /\n/ }
validates :push_events_branch_filter, branch_filter: true
+ # rubocop: disable CodeReuse/ServiceClass
def execute(data, hook_name)
WebHookService.new(self, data, hook_name).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
+ # rubocop: disable CodeReuse/ServiceClass
def async_execute(data, hook_name)
WebHookService.new(self, data, hook_name).async_execute
end
+ # rubocop: enable CodeReuse/ServiceClass
# Allow urls pointing localhost and the local network
def allow_local_requests?
diff --git a/app/models/issue.rb b/app/models/issue.rb
index d0cd7461daa..d13fbcf002c 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -172,6 +172,7 @@ class Issue < ActiveRecord::Base
# All branches containing the current issue's ID, except for
# those with a merge request open referencing the current issue.
+ # rubocop: disable CodeReuse/ServiceClass
def related_branches(current_user)
branches_with_iid = project.repository.branch_names.select do |branch|
branch =~ /\A#{iid}-(?!\d+-stable)/i
@@ -185,6 +186,7 @@ class Issue < ActiveRecord::Base
branches_with_iid - branches_with_merge_request
end
+ # rubocop: enable CodeReuse/ServiceClass
def suggested_branch_name
return to_branch_name unless project.repository.branch_exists?(to_branch_name)
@@ -278,9 +280,11 @@ class Issue < ActiveRecord::Base
true
end
+ # rubocop: disable CodeReuse/ServiceClass
def update_project_counter_caches
Projects::OpenIssuesCountService.new(project).refresh_cache
end
+ # rubocop: enable CodeReuse/ServiceClass
private
diff --git a/app/models/key.rb b/app/models/key.rb
index 3bb0d2f6f9c..bdb83e12793 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -55,9 +55,11 @@ class Key < ActiveRecord::Base
"key-#{id}"
end
+ # rubocop: disable CodeReuse/ServiceClass
def update_last_used_at
Keys::LastUsedService.new(self).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
def add_to_shell
GitlabShellWorker.perform_async(
@@ -67,9 +69,11 @@ class Key < ActiveRecord::Base
)
end
+ # rubocop: disable CodeReuse/ServiceClass
def post_create_hook
SystemHooksService.new.execute_hooks_for(self, :create)
end
+ # rubocop: enable CodeReuse/ServiceClass
def remove_from_shell
GitlabShellWorker.perform_async(
@@ -79,15 +83,19 @@ class Key < ActiveRecord::Base
)
end
+ # rubocop: disable CodeReuse/ServiceClass
def refresh_user_cache
return unless user
Users::KeysCountService.new(user).refresh_cache
end
+ # rubocop: enable CodeReuse/ServiceClass
+ # rubocop: disable CodeReuse/ServiceClass
def post_destroy_hook
SystemHooksService.new.execute_hooks_for(self, :destroy)
end
+ # rubocop: enable CodeReuse/ServiceClass
def public_key
@public_key ||= Gitlab::SSHPublicKey.new(key)
diff --git a/app/models/member.rb b/app/models/member.rb
index d9b4e8d2ac6..0696ea46c8b 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -145,6 +145,7 @@ class Member < ActiveRecord::Base
end
def add_user(source, user, access_level, existing_members: nil, current_user: nil, expires_at: nil, ldap: false)
+ # rubocop: disable CodeReuse/ServiceClass
# `user` can be either a User object, User ID or an email to be invited
member = retrieve_member(source, user, existing_members)
access_level = retrieve_access_level(access_level)
@@ -171,6 +172,7 @@ class Member < ActiveRecord::Base
end
member
+ # rubocop: enable CodeReuse/ServiceClass
end
def add_users(source, users, access_level, current_user: nil, expires_at: nil)
@@ -339,12 +341,14 @@ class Member < ActiveRecord::Base
@notification_setting ||= user&.notification_settings_for(source)
end
+ # rubocop: disable CodeReuse/ServiceClass
def notifiable?(type, opts = {})
# always notify when there isn't a user yet
return true if user.blank?
NotificationRecipientService.notifiable?(user, type, notifiable_options.merge(opts))
end
+ # rubocop: enable CodeReuse/ServiceClass
private
@@ -374,6 +378,7 @@ class Member < ActiveRecord::Base
# in a transaction. Doing so can lead to the job running before the
# transaction has been committed, resulting in the job either throwing an
# error or not doing any meaningful work.
+ # rubocop: disable CodeReuse/ServiceClass
def refresh_member_authorized_projects
# If user/source is being destroyed, project access are going to be
# destroyed eventually because of DB foreign keys, so we shouldn't bother
@@ -382,6 +387,7 @@ class Member < ActiveRecord::Base
UserProjectAccessChangedService.new(user_id).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
def after_accept_invite
post_create_hook
@@ -395,13 +401,17 @@ class Member < ActiveRecord::Base
post_create_hook
end
+ # rubocop: disable CodeReuse/ServiceClass
def system_hook_service
SystemHooksService.new
end
+ # rubocop: enable CodeReuse/ServiceClass
+ # rubocop: disable CodeReuse/ServiceClass
def notification_service
NotificationService.new
end
+ # rubocop: enable CodeReuse/ServiceClass
def notifiable_options
{}
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb
index 0154fe5aeba..537f2a3a231 100644
--- a/app/models/members/project_member.rb
+++ b/app/models/members/project_member.rb
@@ -138,7 +138,9 @@ class ProjectMember < Member
super
end
+ # rubocop: disable CodeReuse/ServiceClass
def event_service
EventCreateService.new
end
+ # rubocop: enable CodeReuse/ServiceClass
end
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 396647a14ae..e19bf62dcd0 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -137,12 +137,14 @@ class MergeRequest < ActiveRecord::Base
Gitlab::Timeless.timeless(merge_request, &block)
end
+ # rubocop: disable CodeReuse/ServiceClass
after_transition unchecked: :cannot_be_merged do |merge_request, transition|
if merge_request.notify_conflict?
NotificationService.new.merge_request_unmergeable(merge_request)
TodoService.new.merge_request_became_unmergeable(merge_request)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def check_state?(merge_status)
[:unchecked, :cannot_be_merged_recheck].include?(merge_status.to_sym)
@@ -623,11 +625,13 @@ class MergeRequest < ActiveRecord::Base
end
end
+ # rubocop: disable CodeReuse/ServiceClass
def reload_diff(current_user = nil)
return unless open?
MergeRequests::ReloadDiffsService.new(self, current_user).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
def check_if_can_be_merged
return unless self.class.state_machines[:merge_status].check_state?(merge_status) && Gitlab::Database.read_write?
@@ -1036,6 +1040,7 @@ class MergeRequest < ActiveRecord::Base
actual_head_pipeline&.has_test_reports?
end
+ # rubocop: disable CodeReuse/ServiceClass
def compare_test_reports
unless has_test_reports?
return { status: :error, status_reason: 'This merge request does not have test reports' }
@@ -1050,7 +1055,9 @@ class MergeRequest < ActiveRecord::Base
data
end || { status: :parsing }
end
+ # rubocop: enable CodeReuse/ServiceClass
+ # rubocop: disable CodeReuse/ServiceClass
def calculate_reactive_cache(identifier, *args)
case identifier.to_sym
when :compare_test_results
@@ -1060,6 +1067,7 @@ class MergeRequest < ActiveRecord::Base
raise NotImplementedError, "Unknown identifier: #{identifier}"
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def all_commits
# MySQL doesn't support LIMIT in a subquery.
@@ -1125,6 +1133,7 @@ class MergeRequest < ActiveRecord::Base
diff_refs && diff_refs.complete?
end
+ # rubocop: disable CodeReuse/ServiceClass
def update_diff_discussion_positions(old_diff_refs:, new_diff_refs:, current_user: nil)
return unless has_complete_diff_refs?
return if new_diff_refs == old_diff_refs
@@ -1154,6 +1163,7 @@ class MergeRequest < ActiveRecord::Base
.execute(self)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def keep_around_commit
project.repository.keep_around(self.merge_commit_sha)
@@ -1189,9 +1199,11 @@ class MergeRequest < ActiveRecord::Base
true
end
+ # rubocop: disable CodeReuse/ServiceClass
def update_project_counter_caches
Projects::OpenMergeRequestsCountService.new(target_project).refresh_cache
end
+ # rubocop: enable CodeReuse/ServiceClass
def first_contribution?
return false if project.team.max_member_access(author_id) > Gitlab::Access::GUEST
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index bbe4f6f7969..02c6b650f33 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -219,12 +219,14 @@ class MergeRequestDiff < ActiveRecord::Base
self.id == merge_request.latest_merge_request_diff_id
end
+ # rubocop: disable CodeReuse/ServiceClass
def compare_with(sha)
# When compare merge request versions we want diff A..B instead of A...B
# so we handle cases when user does squash and rebase of the commits between versions.
# For this reason we set straight to true by default.
CompareService.new(project, head_commit_sha).execute(project, sha, straight: true)
end
+ # rubocop: enable CodeReuse/ServiceClass
private
diff --git a/app/models/note.rb b/app/models/note.rb
index 8f090cc31e6..4429c1dcb07 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -181,6 +181,7 @@ class Note < ActiveRecord::Base
end
end
+ # rubocop: disable CodeReuse/ServiceClass
def cross_reference?
return unless system?
@@ -190,6 +191,7 @@ class Note < ActiveRecord::Base
SystemNoteService.cross_reference?(note)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def diff_note?
false
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index 7739a3894d3..7a33ade826b 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -140,9 +140,11 @@ class PagesDomain < ActiveRecord::Base
self.verification_code = SecureRandom.hex(16)
end
+ # rubocop: disable CodeReuse/ServiceClass
def update_daemon
::Projects::UpdatePagesConfigurationService.new(project).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
def pages_config_changed?
project_id_changed? ||
diff --git a/app/models/project.rb b/app/models/project.rb
index 8928bffd36c..036335d7cd9 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1115,12 +1115,14 @@ class Project < ActiveRecord::Base
find_or_initialize_services.find { |service| service.to_param == name }
end
+ # rubocop: disable CodeReuse/ServiceClass
def create_labels
Label.templates.each do |label|
params = label.attributes.except('id', 'template', 'created_at', 'updated_at')
Labels::FindOrCreateService.new(nil, self, params).execute(skip_authorization: true)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def find_service(list, name)
list.find { |service| service.to_param == name }
@@ -1168,6 +1170,7 @@ class Project < ActiveRecord::Base
end
end
+ # rubocop: disable CodeReuse/ServiceClass
def send_move_instructions(old_path_with_namespace)
# New project path needs to be committed to the DB or notification will
# retrieve stale information
@@ -1175,6 +1178,7 @@ class Project < ActiveRecord::Base
NotificationService.new.project_was_moved(self, old_path_with_namespace)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def owner
if group
@@ -1184,6 +1188,7 @@ class Project < ActiveRecord::Base
end
end
+ # rubocop: disable CodeReuse/ServiceClass
def execute_hooks(data, hooks_scope = :push_hooks)
run_after_commit_or_now do
hooks.hooks_for(hooks_scope).select_active(hooks_scope, data).each do |hook|
@@ -1192,6 +1197,7 @@ class Project < ActiveRecord::Base
SystemHooksService.new.execute_hooks(data, hooks_scope)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def execute_services(data, hooks_scope = :push_hooks)
# Call only service hooks that are active for this scope
@@ -1506,13 +1512,17 @@ class Project < ActiveRecord::Base
self.runners_token && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.runners_token)
end
+ # rubocop: disable CodeReuse/ServiceClass
def open_issues_count(current_user = nil)
Projects::OpenIssuesCountService.new(self, current_user).count
end
+ # rubocop: enable CodeReuse/ServiceClass
+ # rubocop: disable CodeReuse/ServiceClass
def open_merge_requests_count
Projects::OpenMergeRequestsCountService.new(self).count
end
+ # rubocop: enable CodeReuse/ServiceClass
def visibility_level_allowed_as_fork?(level = self.visibility_level)
return true unless forked?
@@ -1593,6 +1603,7 @@ class Project < ActiveRecord::Base
end
# TODO: what to do here when not using Legacy Storage? Do we still need to rename and delay removal?
+ # rubocop: disable CodeReuse/ServiceClass
def remove_pages
# Projects with a missing namespace cannot have their pages removed
return unless namespace
@@ -1608,6 +1619,7 @@ class Project < ActiveRecord::Base
PagesWorker.perform_in(5.minutes, :remove, namespace.full_path, temp_path)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def rename_repo
path_before = previous_changes['path'].first
@@ -1668,6 +1680,7 @@ class Project < ActiveRecord::Base
end
end
+ # rubocop: disable CodeReuse/ServiceClass
def after_create_default_branch
return unless default_branch
@@ -1688,6 +1701,7 @@ class Project < ActiveRecord::Base
ProtectedBranches::CreateService.new(self, creator, params).execute(skip_authorization: true)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def remove_import_jid
return unless import_jid
@@ -1918,9 +1932,11 @@ class Project < ActiveRecord::Base
# @deprecated cannot remove yet because it has an index with its name in elasticsearch
alias_method :path_with_namespace, :full_path
+ # rubocop: disable CodeReuse/ServiceClass
def forks_count
Projects::ForksCountService.new(self).count
end
+ # rubocop: enable CodeReuse/ServiceClass
def legacy_storage?
[nil, 0].include?(self.storage_version)
@@ -2071,6 +2087,7 @@ class Project < ActiveRecord::Base
private
+ # rubocop: disable CodeReuse/ServiceClass
def rename_or_migrate_repository!
if Gitlab::CurrentSettings.hashed_storage_enabled? &&
storage_upgradable? &&
@@ -2080,6 +2097,7 @@ class Project < ActiveRecord::Base
storage.rename_repo
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def storage_upgradable?
storage_version != LATEST_STORAGE_VERSION
@@ -2104,6 +2122,7 @@ class Project < ActiveRecord::Base
self.project_feature.untrack_statistics_for_deletion!
end
+ # rubocop: disable CodeReuse/ServiceClass
def execute_rename_repository_hooks!(full_path_before)
# When we import a project overwriting the original project, there
# is a move operation. In that case we don't want to send the instructions.
@@ -2114,6 +2133,7 @@ class Project < ActiveRecord::Base
reload_repository!
end
+ # rubocop: enable CodeReuse/ServiceClass
def storage
@storage ||=
diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb
index 89ed09af96a..d59cb43dea4 100644
--- a/app/models/project_import_state.rb
+++ b/app/models/project_import_state.rb
@@ -48,9 +48,11 @@ class ProjectImportState < ActiveRecord::Base
project.reset_cache_and_import_attrs
if Gitlab::ImportSources.importer_names.include?(project.import_type) && project.repo_exists?
+ # rubocop: disable CodeReuse/ServiceClass
state.run_after_commit do
Projects::AfterImportService.new(project).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
end
end
end
diff --git a/app/models/project_services/slash_commands_service.rb b/app/models/project_services/slash_commands_service.rb
index e3ab60adefd..bfabc6d262c 100644
--- a/app/models/project_services/slash_commands_service.rb
+++ b/app/models/project_services/slash_commands_service.rb
@@ -44,11 +44,15 @@ class SlashCommandsService < Service
private
+ # rubocop: disable CodeReuse/ServiceClass
def find_chat_user(params)
ChatNames::FindUserService.new(self, params).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
+ # rubocop: disable CodeReuse/ServiceClass
def authorize_chat_name_url(params)
ChatNames::AuthorizeUserService.new(self, params).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 568ec101016..dac8779488d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -61,6 +61,7 @@ class User < ActiveRecord::Base
# Override Devise::Models::Trackable#update_tracked_fields!
# to limit database writes to at most once every hour
+ # rubocop: disable CodeReuse/ServiceClass
def update_tracked_fields!(request)
return if Gitlab::Database.read_only?
@@ -71,6 +72,7 @@ class User < ActiveRecord::Base
Users::UpdateService.new(self, user: self).execute(validate: false)
end
+ # rubocop: enable CodeReuse/ServiceClass
attr_accessor :force_random_password
@@ -455,7 +457,7 @@ class User < ActiveRecord::Base
def find_by_personal_access_token(token_string)
return unless token_string
- PersonalAccessTokensFinder.new(state: 'active').find_by(token: token_string)&.user
+ PersonalAccessTokensFinder.new(state: 'active').find_by(token: token_string)&.user # rubocop: disable CodeReuse/Finder
end
# Returns a user for the given SSH key.
@@ -627,6 +629,7 @@ class User < ActiveRecord::Base
# hash and `_was` variables getting munged.
# By using an `after_commit` instead of `after_update`, we avoid the recursive callback
# scenario, though it then requires us to use the `previous_changes` hash
+ # rubocop: disable CodeReuse/ServiceClass
def update_emails_with_primary_email(previous_email)
primary_email_record = emails.find_by(email: email)
Emails::DestroyService.new(self, user: self).execute(primary_email_record) if primary_email_record
@@ -635,6 +638,7 @@ class User < ActiveRecord::Base
# have access to the original confirmation values at this point, so just set confirmed_at
Emails::CreateService.new(self, user: self, email: previous_email).execute(confirmed_at: confirmed_at)
end
+ # rubocop: enable CodeReuse/ServiceClass
def update_invalid_gpg_signatures
gpg_keys.each(&:update_invalid_gpg_signatures)
@@ -663,9 +667,11 @@ class User < ActiveRecord::Base
all_expanded_groups.where(require_two_factor_authentication: true)
end
+ # rubocop: disable CodeReuse/ServiceClass
def refresh_authorized_projects
Users::RefreshAuthorizedProjectsService.new(self).execute
end
+ # rubocop: enable CodeReuse/ServiceClass
def remove_project_authorizations(project_ids)
project_authorizations.where(project_id: project_ids).delete_all
@@ -718,11 +724,13 @@ class User < ActiveRecord::Base
authorized_projects(Gitlab::Access::REPORTER).non_archived.with_issues_enabled
end
+ # rubocop: disable CodeReuse/ServiceClass
def require_ssh_key?
count = Users::KeysCountService.new(self).count
count.zero? && Gitlab::ProtocolAccess.allowed?('ssh')
end
+ # rubocop: enable CodeReuse/ServiceClass
def require_password_creation_for_web?
allow_password_authentication_for_web? && password_automatically_set?
@@ -786,6 +794,7 @@ class User < ActiveRecord::Base
projects_limit - personal_projects_count
end
+ # rubocop: disable CodeReuse/ServiceClass
def recent_push(project = nil)
service = Users::LastPushEventService.new(self)
@@ -795,6 +804,7 @@ class User < ActiveRecord::Base
service.last_event_for_user
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def several_namespaces?
owned_groups.any? || maintainers_groups.any?
@@ -932,9 +942,11 @@ class User < ActiveRecord::Base
email.start_with?('temp-email-for-oauth')
end
+ # rubocop: disable CodeReuse/ServiceClass
def avatar_url(size: nil, scale: 2, **args)
GravatarService.new.execute(email, size, scale, username: username)
end
+ # rubocop: enable CodeReuse/ServiceClass
def primary_email_verified?
confirmed? && !temp_oauth_email?
@@ -1000,26 +1012,32 @@ class User < ActiveRecord::Base
system_hook_service.execute_hooks_for(self, :destroy)
end
+ # rubocop: disable CodeReuse/ServiceClass
def remove_key_cache
Users::KeysCountService.new(self).delete_cache
end
+ # rubocop: enable CodeReuse/ServiceClass
def delete_async(deleted_by:, params: {})
block if params[:hard_delete]
DeleteUserWorker.perform_async(deleted_by.id, id, params.to_h)
end
+ # rubocop: disable CodeReuse/ServiceClass
def notification_service
NotificationService.new
end
+ # rubocop: enable CodeReuse/ServiceClass
def log_info(message)
Gitlab::AppLogger.info message
end
+ # rubocop: disable CodeReuse/ServiceClass
def system_hook_service
SystemHooksService.new
end
+ # rubocop: enable CodeReuse/ServiceClass
def starred?(project)
starred_projects.exists?(project.id)
@@ -1188,6 +1206,7 @@ class User < ActiveRecord::Base
# See:
# <https://github.com/plataformatec/devise/blob/v4.0.0/lib/devise/models/lockable.rb#L92>
#
+ # rubocop: disable CodeReuse/ServiceClass
def increment_failed_attempts!
return if ::Gitlab::Database.read_only?
@@ -1200,6 +1219,7 @@ class User < ActiveRecord::Base
Users::UpdateService.new(self, user: self).execute(validate: false)
end
end
+ # rubocop: enable CodeReuse/ServiceClass
def access_level
if admin?
@@ -1440,7 +1460,7 @@ class User < ActiveRecord::Base
&creation_block
)
- Users::UpdateService.new(user, user: user).execute(validate: false)
+ Users::UpdateService.new(user, user: user).execute(validate: false) # rubocop: disable CodeReuse/ServiceClass
user
ensure
Gitlab::ExclusiveLease.cancel(lease_key, uuid)
diff --git a/app/policies/application_setting/term_policy.rb b/app/policies/application_setting/term_policy.rb
index 17f00f33d35..c0d2ceaa349 100644
--- a/app/policies/application_setting/term_policy.rb
+++ b/app/policies/application_setting/term_policy.rb
@@ -19,6 +19,7 @@ class ApplicationSetting
rule { terms_accepted }.prevent :accept_terms
+ # rubocop: disable CodeReuse/ActiveRecord
def agreement
strong_memoize(:agreement) do
next nil if @user.nil? || @subject.nil?
@@ -26,5 +27,6 @@ class ApplicationSetting
@user.term_agreements.find_by(term: @subject)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/policies/ci/runner_policy.rb b/app/policies/ci/runner_policy.rb
index c44f22b6ad3..de76b7b2b5b 100644
--- a/app/policies/ci/runner_policy.rb
+++ b/app/policies/ci/runner_policy.rb
@@ -5,7 +5,9 @@ module Ci
with_options scope: :subject, score: 0
condition(:locked, scope: :subject) { @subject.locked? }
+ # rubocop: disable CodeReuse/ActiveRecord
condition(:owned_runner) { @user.ci_owned_runners.exists?(@subject.id) }
+ # rubocop: enable CodeReuse/ActiveRecord
rule { anonymous }.prevent_all
diff --git a/app/policies/deploy_key_policy.rb b/app/policies/deploy_key_policy.rb
index 204c54a5b20..7f0ec011e79 100644
--- a/app/policies/deploy_key_policy.rb
+++ b/app/policies/deploy_key_policy.rb
@@ -4,7 +4,9 @@ class DeployKeyPolicy < BasePolicy
with_options scope: :subject, score: 0
condition(:private_deploy_key) { @subject.private? }
+ # rubocop: disable CodeReuse/ActiveRecord
condition(:has_deploy_key) { @user.project_deploy_keys.exists?(id: @subject.id) }
+ # rubocop: enable CodeReuse/ActiveRecord
rule { anonymous }.prevent_all
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb
index 273a93a1423..d0e84b1aa38 100644
--- a/app/policies/project_policy.rb
+++ b/app/policies/project_policy.rb
@@ -398,6 +398,7 @@ class ProjectPolicy < BasePolicy
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def project_group_member?
return false if @user.nil?
@@ -407,6 +408,7 @@ class ProjectPolicy < BasePolicy
project.group.requesters.exists?(user_id: @user.id)
)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def team_access_level
return -1 if @user.nil?
diff --git a/app/presenters/conversational_development_index/metric_presenter.rb b/app/presenters/conversational_development_index/metric_presenter.rb
index e0312c6f431..9639b84cf56 100644
--- a/app/presenters/conversational_development_index/metric_presenter.rb
+++ b/app/presenters/conversational_development_index/metric_presenter.rb
@@ -139,8 +139,10 @@ module ConversationalDevelopmentIndex
]
end
+ # rubocop: disable CodeReuse/ActiveRecord
def average_percentage_score
cards.sum(&:percentage_score) / cards.size.to_f
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb
index 8c4eac3c31d..3f565b826dd 100644
--- a/app/presenters/merge_request_presenter.rb
+++ b/app/presenters/merge_request_presenter.rb
@@ -142,6 +142,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
end
def assign_to_closing_issues_link
+ # rubocop: disable CodeReuse/ServiceClass
issues = MergeRequests::AssignIssuesService.new(project,
current_user,
merge_request: merge_request,
@@ -152,6 +153,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
pluralize_this_issue = issues.count > 1 ? "these issues" : "this issue"
link_to "Assign yourself to #{pluralize_this_issue}", path, method: :post
end
+ # rubocop: enable CodeReuse/ServiceClass
end
def can_revert_on_current_merge_request?
@@ -202,7 +204,9 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
end
def conflicts
+ # rubocop: disable CodeReuse/ServiceClass
@conflicts ||= MergeRequests::Conflicts::ListService.new(merge_request)
+ # rubocop: enable CodeReuse/ServiceClass
end
def closing_issues
diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb
index 6a54054badc..d2434d96fd7 100644
--- a/app/presenters/project_presenter.rb
+++ b/app/presenters/project_presenter.rb
@@ -319,7 +319,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
def tags_to_show
- project.tag_list.take(MAX_TAGS_TO_SHOW)
+ project.tag_list.take(MAX_TAGS_TO_SHOW) # rubocop: disable CodeReuse/ActiveRecord
end
def count_of_extra_tags_not_shown
diff --git a/app/presenters/projects/settings/deploy_keys_presenter.rb b/app/presenters/projects/settings/deploy_keys_presenter.rb
index 28eaef00a12..85518c9a3a4 100644
--- a/app/presenters/projects/settings/deploy_keys_presenter.rb
+++ b/app/presenters/projects/settings/deploy_keys_presenter.rb
@@ -12,9 +12,11 @@ module Projects
@key ||= DeployKey.new.tap { |dk| dk.deploy_keys_projects.build }
end
+ # rubocop: disable CodeReuse/ActiveRecord
def enabled_keys
@enabled_keys ||= project.deploy_keys.includes(:projects)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def any_keys_enabled?
enabled_keys.any?
@@ -24,14 +26,17 @@ module Projects
@available_keys ||= current_user.accessible_deploy_keys - enabled_keys
end
+ # rubocop: disable CodeReuse/ActiveRecord
def available_project_keys
@available_project_keys ||= current_user.project_deploy_keys.includes(:projects) - enabled_keys
end
+ # rubocop: enable CodeReuse/ActiveRecord
def key_available?(deploy_key)
available_keys.include?(deploy_key)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def available_public_keys
return @available_public_keys if defined?(@available_public_keys)
@@ -41,9 +46,10 @@ module Projects
# in @available_project_keys.
@available_public_keys -= available_project_keys
end
+ # rubocop: enable CodeReuse/ActiveRecord
def as_json
- serializer = DeployKeySerializer.new
+ serializer = DeployKeySerializer.new # rubocop: disable CodeReuse/Serializer
opts = { user: current_user }
{
diff --git a/app/serializers/commit_entity.rb b/app/serializers/commit_entity.rb
index b3287c66554..ce76659fa46 100644
--- a/app/serializers/commit_entity.rb
+++ b/app/serializers/commit_entity.rb
@@ -6,7 +6,7 @@ class CommitEntity < API::Entities::Commit
expose :author, using: UserEntity
expose :author_gravatar_url do |commit|
- GravatarService.new.execute(commit.author_email)
+ GravatarService.new.execute(commit.author_email) # rubocop: disable CodeReuse/ServiceClass
end
expose :commit_url do |commit|
diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb
index f75ace14d9c..878cc5290bd 100644
--- a/app/serializers/diffs_entity.rb
+++ b/app/serializers/diffs_entity.rb
@@ -35,13 +35,17 @@ class DiffsEntity < Grape::Entity
diffs_project_merge_request_path(merge_request&.project, merge_request)
end
+ # rubocop: disable CodeReuse/ActiveRecord
expose :added_lines do |diffs|
diffs.diff_files.sum(&:added_lines)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
expose :removed_lines do |diffs|
diffs.diff_files.sum(&:removed_lines)
end
+ # rubocop: enable CodeReuse/ActiveRecord
expose :render_overflow_warning do |diffs|
render_overflow_warning?(diffs.diff_files)
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb
index dc1686c30c4..598ce5f9e4f 100644
--- a/app/serializers/environment_serializer.rb
+++ b/app/serializers/environment_serializer.rb
@@ -29,6 +29,7 @@ class EnvironmentSerializer < BaseSerializer
private
+ # rubocop: disable CodeReuse/ActiveRecord
def itemize(resource)
items = resource.order('folder ASC')
.group('COALESCE(environment_type, name)')
@@ -46,4 +47,5 @@ class EnvironmentSerializer < BaseSerializer
Item.new(item.folder, item.size, environments[item.last_id])
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/serializers/group_child_entity.rb b/app/serializers/group_child_entity.rb
index f6804fe7f6a..20d7032c970 100644
--- a/app/serializers/group_child_entity.rb
+++ b/app/serializers/group_child_entity.rb
@@ -66,11 +66,13 @@ class GroupChildEntity < Grape::Entity
private
+ # rubocop: disable CodeReuse/ActiveRecord
def membership
return unless request.current_user
@membership ||= request.current_user.members.find_by(source: object)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def project?
object.is_a?(Project)
diff --git a/app/serializers/group_entity.rb b/app/serializers/group_entity.rb
index c46c342ee5d..0e1bc9a6b3d 100644
--- a/app/serializers/group_entity.rb
+++ b/app/serializers/group_entity.rb
@@ -17,9 +17,11 @@ class GroupEntity < Grape::Entity
end
expose :permissions do
+ # rubocop: disable CodeReuse/ActiveRecord
expose :human_group_access do |group, options|
group.group_members.find_by(user_id: request.current_user)&.human_access
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
expose :edit_path do |group|
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index f55d448235a..380e8804f51 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -243,7 +243,7 @@ class MergeRequestWidgetEntity < IssuableEntity
def presenter(merge_request)
@presenters ||= {}
- @presenters[merge_request] ||= MergeRequestPresenter.new(merge_request, current_user: current_user)
+ @presenters[merge_request] ||= MergeRequestPresenter.new(merge_request, current_user: current_user) # rubocop: disable CodeReuse/Presenter
end
# Once SchedulePopulateMergeRequestMetricsWithEventsData fully runs,
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb
index 3205578b83e..4f31af3c46d 100644
--- a/app/serializers/pipeline_serializer.rb
+++ b/app/serializers/pipeline_serializer.rb
@@ -4,6 +4,7 @@ class PipelineSerializer < BaseSerializer
include WithPagination
entity PipelineDetailsEntity
+ # rubocop: disable CodeReuse/ActiveRecord
def represent(resource, opts = {})
if resource.is_a?(ActiveRecord::Relation)
resource = resource.preload([
@@ -33,6 +34,7 @@ class PipelineSerializer < BaseSerializer
super(resource, opts)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def represent_status(resource)
return {} unless resource.present?
diff --git a/app/services/applications/create_service.rb b/app/services/applications/create_service.rb
index 7db90c0b3c6..3d88c4f064e 100644
--- a/app/services/applications/create_service.rb
+++ b/app/services/applications/create_service.rb
@@ -2,10 +2,12 @@
module Applications
class CreateService
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(current_user, params)
@current_user = current_user
@params = params.except(:ip_address)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def execute(request)
Doorkeeper::Application.create(@params)
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 0db1418b37a..4e352f2dc63 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -9,6 +9,7 @@ module Boards
fetch_issues.order_by_position_and_priority
end
+ # rubocop: disable CodeReuse/ActiveRecord
def metadata
keys = metadata_fields.keys
columns = metadata_fields.values_at(*keys).join(', ')
@@ -16,6 +17,7 @@ module Boards
Hash[keys.zip(results.flatten)]
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -24,6 +26,7 @@ module Boards
end
# We memoize the query here since the finder methods we use are quite complex. This does not memoize the result of the query.
+ # rubocop: disable CodeReuse/ActiveRecord
def fetch_issues
strong_memoize(:fetch_issues) do
issues = IssuesFinder.new(current_user, filter_params).execute
@@ -31,6 +34,7 @@ module Boards
filter(issues).reorder(nil)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def filter(issues)
issues = without_board_labels(issues) unless list&.movable? || list&.closed?
@@ -72,24 +76,32 @@ module Boards
params[:include_subgroups] = board.group_board?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def board_label_ids
@board_label_ids ||= board.lists.movable.pluck(:label_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def without_board_labels(issues)
return issues unless board_label_ids.any?
issues.where.not('EXISTS (?)', issues_label_links.limit(1))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def issues_label_links
LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id").where(label_id: board_label_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def with_list_label(issues)
issues.where('EXISTS (?)', LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
.where("label_links.label_id = ?", list.label_id).limit(1))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 6fd8a23b2a1..7dd87034410 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -21,13 +21,17 @@ module Boards
moving_from_list != moving_to_list
end
+ # rubocop: disable CodeReuse/ActiveRecord
def moving_from_list
@moving_from_list ||= board.lists.find_by(id: params[:from_list_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def moving_to_list
@moving_to_list ||= board.lists.find_by(id: params[:to_list_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update(issue)
::Issues::UpdateService.new(issue.project, current_user, issue_params(issue)).execute(issue)
@@ -61,6 +65,7 @@ module Boards
[moving_to_list.label_id].compact
end
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_label_ids
label_ids =
if moving_to_list.movable?
@@ -73,6 +78,7 @@ module Boards
Array(label_ids).compact
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_between_ids
return unless params[:move_after_id] || params[:move_before_id]
diff --git a/app/services/boards/lists/destroy_service.rb b/app/services/boards/lists/destroy_service.rb
index e12d4f46e19..609c430caed 100644
--- a/app/services/boards/lists/destroy_service.rb
+++ b/app/services/boards/lists/destroy_service.rb
@@ -18,10 +18,12 @@ module Boards
attr_reader :board
+ # rubocop: disable CodeReuse/ActiveRecord
def decrement_higher_lists(list)
board.lists.movable.where('position > ?', list.position)
.update_all('position = position - 1')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def remove_list(list)
list.destroy
diff --git a/app/services/boards/lists/move_service.rb b/app/services/boards/lists/move_service.rb
index 27a36051662..93f81837d1a 100644
--- a/app/services/boards/lists/move_service.rb
+++ b/app/services/boards/lists/move_service.rb
@@ -34,17 +34,21 @@ module Boards
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def decrement_intermediate_lists
board.lists.movable.where('position > ?', old_position)
.where('position <= ?', new_position)
.update_all('position = position - 1')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def increment_intermediate_lists
board.lists.movable.where('position >= ?', new_position)
.where('position < ?', old_position)
.update_all('position = position + 1')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update_list_position(list)
list.update_attribute(:position, new_position)
diff --git a/app/services/chat_names/find_user_service.rb b/app/services/chat_names/find_user_service.rb
index 854b191c45c..c91738fa4c7 100644
--- a/app/services/chat_names/find_user_service.rb
+++ b/app/services/chat_names/find_user_service.rb
@@ -17,6 +17,7 @@ module ChatNames
private
+ # rubocop: disable CodeReuse/ActiveRecord
def find_chat_name
ChatName.find_by(
service: @service,
@@ -24,5 +25,6 @@ module ChatNames
chat_id: @params[:user_id]
)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/ci/compare_test_reports_service.rb b/app/services/ci/compare_test_reports_service.rb
index ec25e934a27..2293f95f56b 100644
--- a/app/services/ci/compare_test_reports_service.rb
+++ b/app/services/ci/compare_test_reports_service.rb
@@ -3,6 +3,7 @@
module Ci
class CompareTestReportsService < ::BaseService
def execute(base_pipeline, head_pipeline)
+ # rubocop: disable CodeReuse/Serializer
comparer = Gitlab::Ci::Reports::TestReportsComparer
.new(base_pipeline&.test_reports, head_pipeline.test_reports)
@@ -19,6 +20,7 @@ module Ci
key: key(base_pipeline, head_pipeline),
status_reason: e.message
}
+ # rubocop: enable CodeReuse/Serializer
end
def latest?(base_pipeline, head_pipeline, data)
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index 85df8bcff8c..92a8438ab2f 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -65,6 +65,7 @@ module Ci
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def auto_cancelable_pipelines
project.pipelines
.where(ref: pipeline.ref)
@@ -72,6 +73,7 @@ module Ci
.where.not(sha: project.commit(pipeline.ref).try(:id))
.created_or_pending
end
+ # rubocop: enable CodeReuse/ActiveRecord
def pipeline_created_counter
@pipeline_created_counter ||= Gitlab::Metrics
@@ -84,8 +86,10 @@ module Ci
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def related_merge_requests
pipeline.project.source_of_merge_requests.opened.where(source_branch: pipeline.ref)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/ci/ensure_stage_service.rb b/app/services/ci/ensure_stage_service.rb
index 3d0e39d1b9f..cbb3a2e4709 100644
--- a/app/services/ci/ensure_stage_service.rb
+++ b/app/services/ci/ensure_stage_service.rb
@@ -38,9 +38,11 @@ module Ci
EOS
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_stage
@build.pipeline.stages.find_by(name: @build.stage)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create_stage
Ci::Stage.create!(name: @build.stage,
diff --git a/app/services/ci/extract_sections_from_build_trace_service.rb b/app/services/ci/extract_sections_from_build_trace_service.rb
index 693f6d55be3..97f9918fdb7 100644
--- a/app/services/ci/extract_sections_from_build_trace_service.rb
+++ b/app/services/ci/extract_sections_from_build_trace_service.rb
@@ -11,11 +11,13 @@ module Ci
private
+ # rubocop: disable CodeReuse/ActiveRecord
def find_or_create_name(name)
project.build_trace_section_names.find_or_create_by!(name: name)
rescue ActiveRecord::RecordInvalid
project.build_trace_section_names.find_by!(name: name)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def extract_sections(build)
build.trace.extract_sections.map do |attr|
diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb
index cafee76a33c..69341a6c263 100644
--- a/app/services/ci/process_pipeline_service.rb
+++ b/app/services/ci/process_pipeline_service.rb
@@ -60,17 +60,23 @@ module Ci
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status_for_prior_stages(index)
pipeline.builds.where('stage_idx < ?', index).latest.status || 'success'
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def stage_indexes_of_created_builds
created_builds.order(:stage_idx).pluck('distinct stage_idx')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def created_builds_in_stage(index)
created_builds.where(stage_idx: index)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def created_builds
pipeline.builds.created
@@ -80,6 +86,7 @@ module Ci
# This replicates what is db/post_migrate/20170416103934_upate_retried_for_ci_build.rb
# and ensures that functionality will not be broken before migration is run
# this updates only when there are data that needs to be updated, there are two groups with no retried flag
+ # rubocop: disable CodeReuse/ActiveRecord
def update_retried
# find the latest builds for each name
latest_statuses = pipeline.statuses.latest
@@ -93,6 +100,7 @@ module Ci
.where.not(id: latest_statuses.map(&:first))
.update_all(retried: true) if latest_statuses.any?
end
+ # rubocop: enable CodeReuse/ActiveRecord
def enqueue_build(build)
Ci::EnqueueBuildService.new(project, @user).execute(build)
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb
index 11f85627faf..5a7be921389 100644
--- a/app/services/ci/register_job_service.rb
+++ b/app/services/ci/register_job_service.rb
@@ -15,6 +15,7 @@ module Ci
@runner = runner
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(params = {})
builds =
if runner.instance_type?
@@ -63,6 +64,7 @@ module Ci
register_failure
Result.new(nil, valid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -84,6 +86,7 @@ module Ci
true
end
+ # rubocop: disable CodeReuse/ActiveRecord
def builds_for_shared_runner
new_builds.
# don't run projects which have not enabled shared runners and builds
@@ -97,11 +100,15 @@ module Ci
joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.project_id=project_builds.project_id")
.order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def builds_for_project_runner
new_builds.where(project: runner.projects.without_deleted.with_builds_enabled).order('id ASC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def builds_for_group_runner
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
groups = ::Group.joins(:runner_namespaces).merge(runner.runner_namespaces)
@@ -113,11 +120,14 @@ module Ci
.without_deleted
new_builds.where(project: projects).order('id ASC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def running_builds_for_shared_runners
Ci::Build.running.where(runner: Ci::Runner.instance_type)
.group(:project_id).select(:project_id, 'count(*) AS running_builds')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def new_builds
builds = Ci::Build.pending.unstarted
@@ -138,6 +148,7 @@ module Ci
attempt_counter.increment
end
+ # rubocop: disable CodeReuse/ActiveRecord
def jobs_running_for_project(job)
return '+Inf' unless runner.instance_type?
@@ -146,6 +157,7 @@ module Ci
.limit(JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET + 1).count - 1
running_jobs_count < JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET ? running_jobs_count : "#{JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET}+"
end
+ # rubocop: enable CodeReuse/ActiveRecord
def failed_attempt_counter
@failed_attempt_counter ||= Gitlab::Metrics.counter(:job_register_attempts_failed_total, "Counts the times a runner tries to register a job")
diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb
index 6ceb59e4780..218f1e63d08 100644
--- a/app/services/ci/retry_build_service.rb
+++ b/app/services/ci/retry_build_service.rb
@@ -19,6 +19,7 @@ module Ci
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def reprocess!(build)
unless can?(current_user, :update_build, build)
raise Gitlab::Access::AccessDeniedError
@@ -41,5 +42,6 @@ module Ci
project.builds.create!(Hash[attributes])
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/cohorts_service.rb b/app/services/cohorts_service.rb
index 7a14e97f749..6d466c2fc9c 100644
--- a/app/services/cohorts_service.rb
+++ b/app/services/cohorts_service.rb
@@ -78,6 +78,7 @@ class CohortsService
# created_at_month can never be nil, but last_activity_on_month can (when a
# user has never logged in, just been created). This covers the last
# MONTHS_INCLUDED months.
+ # rubocop: disable CodeReuse/ActiveRecord
def counts_by_month
@counts_by_month ||=
begin
@@ -91,6 +92,7 @@ class CohortsService
.count
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def column_to_date(column)
if Gitlab::Database.postgresql?
diff --git a/app/services/concerns/issues/resolve_discussions.rb b/app/services/concerns/issues/resolve_discussions.rb
index 1563ed965df..f0e9862ca30 100644
--- a/app/services/concerns/issues/resolve_discussions.rb
+++ b/app/services/concerns/issues/resolve_discussions.rb
@@ -13,12 +13,14 @@ module Issues
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_request_to_resolve_discussions_of
strong_memoize(:merge_request_to_resolve_discussions_of) do
MergeRequestsFinder.new(current_user, project_id: project.id)
.find_by(iid: merge_request_to_resolve_discussions_of_iid)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def discussions_to_resolve
return [] unless merge_request_to_resolve_discussions_of
diff --git a/app/services/create_release_service.rb b/app/services/create_release_service.rb
index 09c68390007..8d1fdbe11c3 100644
--- a/app/services/create_release_service.rb
+++ b/app/services/create_release_service.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
class CreateReleaseService < BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(tag_name, release_description)
repository = project.repository
existing_tag = repository.find_tag(tag_name)
@@ -21,6 +22,7 @@ class CreateReleaseService < BaseService
error('Tag does not exist', 404)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def success(release)
super().merge(release: release)
diff --git a/app/services/delete_merged_branches_service.rb b/app/services/delete_merged_branches_service.rb
index ff3e4783fe3..ced87a1c37a 100644
--- a/app/services/delete_merged_branches_service.rb
+++ b/app/services/delete_merged_branches_service.rb
@@ -21,10 +21,12 @@ class DeleteMergedBranchesService < BaseService
private
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_request_branch_names
# reorder(nil) is necessary for SELECT DISTINCT because default scope adds an ORDER BY
source_names = project.origin_merge_requests.opened.reorder(nil).uniq.pluck(:source_branch)
target_names = project.merge_requests.opened.reorder(nil).uniq.pluck(:target_branch)
(source_names + target_names).uniq
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index 26e90e8cf8c..f1883877d56 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -94,6 +94,7 @@ class GitPushService < BaseService
ProjectCacheWorker.perform_async(project.id, types, [:commit_count, :repository_size])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def update_signatures
commit_shas = last_pushed_commits.map(&:sha)
@@ -108,6 +109,7 @@ class GitPushService < BaseService
CreateGpgSignatureWorker.perform_async(commit_shas, project.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Schedules processing of commit messages.
def process_commit_messages
diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb
index 93d84bd8a9c..641111aeadc 100644
--- a/app/services/groups/destroy_service.rb
+++ b/app/services/groups/destroy_service.rb
@@ -9,6 +9,7 @@ module Groups
Rails.logger.info("User #{current_user.id} scheduled a deletion of group ID #{group.id} with job ID #{job_id}")
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
group.prepare_for_destroy
@@ -30,5 +31,6 @@ module Groups
group.destroy
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb
index ea7576077f3..5efa746dfb9 100644
--- a/app/services/groups/transfer_service.rb
+++ b/app/services/groups/transfer_service.rb
@@ -64,9 +64,11 @@ module Groups
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def namespace_with_same_path?
Namespace.exists?(path: @group.path, parent: @new_parent_group)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update_group_attributes
if @new_parent_group && @new_parent_group.visibility_level < @group.visibility_level
@@ -78,6 +80,7 @@ module Groups
@group.save!
end
+ # rubocop: disable CodeReuse/ActiveRecord
def update_children_and_projects_visibility
descendants = @group.descendants.where("visibility_level > ?", @new_parent_group.visibility_level)
@@ -90,6 +93,7 @@ module Groups
.where("visibility_level > ?", @new_parent_group.visibility_level)
.update_all(visibility_level: @new_parent_group.visibility_level)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def raise_transfer_error(message)
raise TransferError, ERROR_MESSAGES[message]
diff --git a/app/services/import_export_clean_up_service.rb b/app/services/import_export_clean_up_service.rb
index e75a951944e..3ecb51b60d0 100644
--- a/app/services/import_export_clean_up_service.rb
+++ b/app/services/import_export_clean_up_service.rb
@@ -26,10 +26,12 @@ class ImportExportCleanUpService
Gitlab::Popen.popen(%W(find #{path} -not -path #{path} -mmin +#{mmin} -delete))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def clean_up_export_object_files
ImportExportUpload.where('updated_at < ?', mmin.minutes.ago).each do |upload|
upload.remove_export_file!
upload.save!
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/issuable/bulk_update_service.rb b/app/services/issuable/bulk_update_service.rb
index 051d5ba881d..c4beddf2294 100644
--- a/app/services/issuable/bulk_update_service.rb
+++ b/app/services/issuable/bulk_update_service.rb
@@ -2,6 +2,7 @@
module Issuable
class BulkUpdateService < IssuableBaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(type)
model_class = type.classify.constantize
update_class = type.classify.pluralize.constantize::UpdateService
@@ -28,6 +29,7 @@ module Issuable
success: !items.count.zero?
}
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index 1259c2c2b3d..3e8b9f84042 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -68,11 +68,13 @@ class IssuableBaseService < BaseService
find_or_create_label_ids
end
+ # rubocop: disable CodeReuse/ActiveRecord
def filter_labels_in_param(key)
return if params[key].to_a.empty?
params[key] = available_labels.where(id: params[key]).pluck(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_or_create_label_ids
labels = params.delete(:labels)
@@ -247,6 +249,7 @@ class IssuableBaseService < BaseService
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def change_todo(issuable)
case params.delete(:todo_event)
when 'add'
@@ -256,6 +259,7 @@ class IssuableBaseService < BaseService
todo_service.mark_todos_as_done_by_ids(todo, current_user) if todo
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def toggle_award(issuable)
award = params.delete(:emoji_award)
diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb
index 25389a946bb..ef08adf4f92 100644
--- a/app/services/issues/base_service.rb
+++ b/app/services/issues/base_service.rb
@@ -31,6 +31,7 @@ module Issues
issue.project.execute_services(issue_data, hooks_scope)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def filter_assignee(issuable)
return if params[:assignee_ids].blank?
@@ -48,6 +49,7 @@ module Issues
params.delete(:assignee_ids)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update_project_counter_caches?(issue)
super || issue.confidential_changed?
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb
index ec9d8944e4e..d2bdba1e627 100644
--- a/app/services/issues/move_service.rb
+++ b/app/services/issues/move_service.rb
@@ -58,6 +58,7 @@ module Issues
CreateService.new(@new_project, @current_user, new_params).execute
end
+ # rubocop: disable CodeReuse/ActiveRecord
def cloneable_label_ids
params = {
project_id: @new_project.id,
@@ -67,6 +68,7 @@ module Issues
LabelsFinder.new(current_user, params).execute.pluck(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def cloneable_milestone_id
title = @old_issue.milestone&.title
@@ -97,6 +99,7 @@ module Issues
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def copy_resource_label_events
@old_issue.resource_label_events.find_in_batches do |batch|
events = batch.map do |event|
@@ -108,6 +111,7 @@ module Issues
Gitlab::Database.bulk_insert(ResourceLabelEvent.table_name, events)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def rewrite_issue_award_emoji
rewrite_award_emoji(@old_issue, @new_issue)
diff --git a/app/services/issues/referenced_merge_requests_service.rb b/app/services/issues/referenced_merge_requests_service.rb
index 40d78502697..a69cd324b1e 100644
--- a/app/services/issues/referenced_merge_requests_service.rb
+++ b/app/services/issues/referenced_merge_requests_service.rb
@@ -2,6 +2,7 @@
module Issues
class ReferencedMergeRequestsService < Issues::BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(issue)
referenced = referenced_merge_requests(issue)
closed_by = closed_by_merge_requests(issue)
@@ -12,6 +13,7 @@ module Issues
[sort_by_iid(referenced), sort_by_iid(closed_by)]
end
+ # rubocop: enable CodeReuse/ActiveRecord
def referenced_merge_requests(issue)
merge_requests = extract_merge_requests(issue)
@@ -29,6 +31,7 @@ module Issues
)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def closed_by_merge_requests(issue)
return [] unless issue.open?
@@ -39,6 +42,7 @@ module Issues
ids = MergeRequestsClosingIssues.where(merge_request_id: merge_requests.map(&:id), issue_id: issue.id).pluck(:merge_request_id)
merge_requests.select { |mr| mr.id.in?(ids) }
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -54,10 +58,12 @@ module Issues
ext.merge_requests
end
+ # rubocop: disable CodeReuse/ActiveRecord
def issue_notes(issue)
@issue_notes ||= {}
@issue_notes[issue] ||= issue.notes.includes(:author)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def sort_by_iid(merge_requests)
Gitlab::IssuableSorter.sort(project, merge_requests) { |mr| mr.iid.to_s }
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index faa4c8a5a4f..b54b0bf6ef6 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -67,6 +67,7 @@ module Issues
issue.move_between(issue_before, issue_after)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def change_issue_duplicate(issue)
canonical_issue_id = params.delete(:canonical_issue_id)
canonical_issue = IssuesFinder.new(current_user).find_by(id: canonical_issue_id)
@@ -75,6 +76,7 @@ module Issues
Issues::DuplicateService.new(project, current_user).execute(issue, canonical_issue)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_issue_to_new_project(issue)
target_project = params.delete(:target_project)
@@ -89,6 +91,7 @@ module Issues
private
+ # rubocop: disable CodeReuse/ActiveRecord
def get_issue_if_allowed(id, board_group_id = nil)
return unless id
@@ -101,6 +104,7 @@ module Issues
issue if can?(current_user, :update_issue, issue)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create_confidentiality_note(issue)
SystemNoteService.change_issue_confidentiality(issue, issue.project, current_user)
diff --git a/app/services/labels/find_or_create_service.rb b/app/services/labels/find_or_create_service.rb
index e4486764a4d..628873519d7 100644
--- a/app/services/labels/find_or_create_service.rb
+++ b/app/services/labels/find_or_create_service.rb
@@ -29,6 +29,7 @@ module Labels
# Only creates the label if current_user can do so, if the label does not exist
# and the user can not create the label, nil is returned
+ # rubocop: disable CodeReuse/ActiveRecord
def find_or_create_label
new_label = available_labels.find_by(title: title)
@@ -39,6 +40,7 @@ module Labels
new_label
end
+ # rubocop: enable CodeReuse/ActiveRecord
def title
params[:title] || params[:name]
diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb
index fcdcea2d0ea..f30ad706c63 100644
--- a/app/services/labels/promote_service.rb
+++ b/app/services/labels/promote_service.rb
@@ -4,6 +4,7 @@ module Labels
class PromoteService < BaseService
BATCH_SIZE = 1000
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(label)
return unless project.group &&
label.is_a?(ProjectLabel)
@@ -27,9 +28,11 @@ module Labels
new_label
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def subscribe_users(new_label, label_ids)
# users can be subscribed to multiple labels that will be merged into the group one
# we want to keep only one subscription / user
@@ -38,7 +41,9 @@ module Labels
.pluck('MAX(id)')
Subscription.where(id: ids_to_update).update_all(subscribable_id: new_label.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def label_ids_for_merge(new_label)
LabelsFinder
.new(current_user, title: new_label.title, group_id: project.group.id)
@@ -46,34 +51,45 @@ module Labels
.where.not(id: new_label)
.select(:id) # Can't use pluck() to avoid object-creation because of the batching
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_issuables(new_label, label_ids)
LabelLink
.where(label: label_ids)
.update_all(label_id: new_label)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_resource_label_events(new_label, label_ids)
ResourceLabelEvent
.where(label: label_ids)
.update_all(label_id: new_label)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_issue_board_lists(new_label, label_ids)
List
.where(label: label_ids)
.update_all(label_id: new_label)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_priorities(new_label, label_ids)
LabelPriority
.where(label: label_ids)
.update_all(label_id: new_label)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_project_labels(label_ids)
Label.where(id: label_ids).destroy_all # rubocop: disable DestroyAll
end
+ # rubocop: enable CodeReuse/ActiveRecord
def clone_label_to_group_label(label)
params = label.attributes.slice('title', 'description', 'color')
diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb
index 1bd8d9fc325..aec0282b31b 100644
--- a/app/services/labels/transfer_service.rb
+++ b/app/services/labels/transfer_service.rb
@@ -32,6 +32,7 @@ module Labels
attr_reader :current_user, :old_group, :project
+ # rubocop: disable CodeReuse/ActiveRecord
def labels_to_transfer
label_ids = []
label_ids << group_labels_applied_to_issues.select(:id)
@@ -41,7 +42,9 @@ module Labels
Label.where("labels.id IN (#{union.to_sql})").reorder(nil).uniq # rubocop:disable GitlabSecurity/SqlInjection
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def group_labels_applied_to_issues
Label.joins(:issues)
.where(
@@ -49,7 +52,9 @@ module Labels
labels: { type: 'GroupLabel', group_id: old_group.id }
)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def group_labels_applied_to_merge_requests
Label.joins(:merge_requests)
.where(
@@ -57,6 +62,7 @@ module Labels
labels: { type: 'GroupLabel', group_id: old_group.id }
)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_or_create_label!(label)
params = label.attributes.slice('title', 'description', 'color')
@@ -65,6 +71,7 @@ module Labels
new_label.id
end
+ # rubocop: disable CodeReuse/ActiveRecord
def update_label_links(labels, old_label_id:, new_label_id:)
# use 'labels' relation to get label_link ids only of issues/MRs
# in the project being transferred.
@@ -76,10 +83,13 @@ module Labels
LabelLink.where(id: link_ids, label_id: old_label_id)
.update_all(label_id: new_label_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_label_priorities(old_label_id:, new_label_id:)
LabelPriority.where(project_id: project.id, label_id: old_label_id)
.update_all(label_id: new_label_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/lfs/file_transformer.rb b/app/services/lfs/file_transformer.rb
index c8eccb8e6cd..6ecf583cb6a 100644
--- a/app/services/lfs/file_transformer.rb
+++ b/app/services/lfs/file_transformer.rb
@@ -55,11 +55,13 @@ module Lfs
@cached_attributes ||= Gitlab::Git::AttributesAtRefParser.new(repository, branch_name)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def create_lfs_object!(lfs_pointer_file, file_content)
LfsObject.find_or_create_by(oid: lfs_pointer_file.sha256, size: lfs_pointer_file.size) do |lfs_object|
lfs_object.file = CarrierWaveStringFile.new(file_content)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def link_lfs_object!(lfs_object)
project.lfs_objects << lfs_object
diff --git a/app/services/lfs/lock_file_service.rb b/app/services/lfs/lock_file_service.rb
index 78434909d68..c7730d24bdc 100644
--- a/app/services/lfs/lock_file_service.rb
+++ b/app/services/lfs/lock_file_service.rb
@@ -18,9 +18,11 @@ module Lfs
private
+ # rubocop: disable CodeReuse/ActiveRecord
def current_lock
project.lfs_file_locks.find_by(path: params[:path])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create_lock!
lock = project.lfs_file_locks.create!(user: current_user,
diff --git a/app/services/lfs/locks_finder_service.rb b/app/services/lfs/locks_finder_service.rb
index d52cf0e3cc4..4a5b2a52921 100644
--- a/app/services/lfs/locks_finder_service.rb
+++ b/app/services/lfs/locks_finder_service.rb
@@ -10,10 +10,12 @@ module Lfs
private
+ # rubocop: disable CodeReuse/ActiveRecord
def find_locks
options = params.slice(:id, :path).compact.symbolize_keys
project.lfs_file_locks.where(options)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/lfs/unlock_file_service.rb b/app/services/lfs/unlock_file_service.rb
index 4d1443bf772..a42916d86bb 100644
--- a/app/services/lfs/unlock_file_service.rb
+++ b/app/services/lfs/unlock_file_service.rb
@@ -32,6 +32,7 @@ module Lfs
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def lock
return @lock if defined?(@lock)
@@ -41,5 +42,6 @@ module Lfs
project.lfs_file_locks.find_by!(path: params[:path])
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb
index e6dd0e12a3a..aa5d8406d0f 100644
--- a/app/services/merge_requests/base_service.rb
+++ b/app/services/merge_requests/base_service.rb
@@ -55,6 +55,7 @@ module MergeRequests
end
# Returns all origin and fork merge requests from `@project` satisfying passed arguments.
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_requests_for(source_branch, mr_states: [:opened])
MergeRequest
.with_state(mr_states)
@@ -62,6 +63,7 @@ module MergeRequests
.preload(:source_project) # we don't need a #includes since we're just preloading for the #select
.select(&:source_project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def pipeline_merge_requests(pipeline)
merge_requests_for(pipeline.ref).each do |merge_request|
diff --git a/app/services/merge_requests/create_from_issue_service.rb b/app/services/merge_requests/create_from_issue_service.rb
index d9a29693987..020af0bb950 100644
--- a/app/services/merge_requests/create_from_issue_service.rb
+++ b/app/services/merge_requests/create_from_issue_service.rb
@@ -32,9 +32,11 @@ module MergeRequests
private
+ # rubocop: disable CodeReuse/ActiveRecord
def issue
@issue ||= IssuesFinder.new(current_user, project_id: project.id).find_by(iid: @issue_iid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def branch_name
@branch ||= @branch_name || issue.to_branch_name
diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb
index c36a2ecbfe3..6081a7d1de0 100644
--- a/app/services/merge_requests/create_service.rb
+++ b/app/services/merge_requests/create_service.rb
@@ -49,6 +49,7 @@ module MergeRequests
merge_request.update(head_pipeline_id: pipeline.id) if pipeline
end
+ # rubocop: disable CodeReuse/ActiveRecord
def head_pipeline_for(merge_request)
return unless merge_request.source_project
@@ -59,6 +60,7 @@ module MergeRequests
pipelines.order(id: :desc).first
end
+ # rubocop: enable CodeReuse/ActiveRecord
def set_projects!
# @project is used to determine whether the user can set the merge request's
diff --git a/app/services/merge_requests/delete_non_latest_diffs_service.rb b/app/services/merge_requests/delete_non_latest_diffs_service.rb
index 2a8ea316921..d5929446122 100644
--- a/app/services/merge_requests/delete_non_latest_diffs_service.rb
+++ b/app/services/merge_requests/delete_non_latest_diffs_service.rb
@@ -8,6 +8,7 @@ module MergeRequests
@merge_request = merge_request
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
diffs = @merge_request.non_latest_diffs.with_files
@@ -16,5 +17,6 @@ module MergeRequests
DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index 48da796505f..bcdd752ddc4 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -51,6 +51,7 @@ module MergeRequests
# and close if push to master include last commit from merge request
# We need this to close(as merged) merge requests that were merged into
# target branch manually
+ # rubocop: disable CodeReuse/ActiveRecord
def post_merge_manually_merged
commit_ids = @commits.map(&:id)
merge_requests = @project.merge_requests.preload(:latest_merge_request_diff).opened.where(target_branch: @branch_name).to_a
@@ -67,6 +68,7 @@ module MergeRequests
.execute(merge_request)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def force_push?
Gitlab::Checks::ForcePush.force_push?(@project, @oldrev, @newrev)
@@ -74,6 +76,7 @@ module MergeRequests
# Refresh merge request diff if we push to source or target branch of merge request
# Note: we should update merge requests from forks too
+ # rubocop: disable CodeReuse/ActiveRecord
def reload_merge_requests
merge_requests = @project.merge_requests.opened
.by_source_or_target_branch(@branch_name).to_a
@@ -101,6 +104,7 @@ module MergeRequests
# @source_merge_requests diffs (for MergeRequest#commit_shas for instance).
merge_requests_for_source_branch(reload: true)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def reset_merge_when_pipeline_succeeds
merge_requests_for_source_branch.each(&:reset_merge_when_pipeline_succeeds)
@@ -197,11 +201,13 @@ module MergeRequests
# If the merge requests closes any issues, save this information in the
# `MergeRequestsClosingIssues` model (as a performance optimization).
+ # rubocop: disable CodeReuse/ActiveRecord
def cache_merge_requests_closing_issues
@project.merge_requests.where(source_branch: @branch_name).each do |merge_request|
merge_request.cache_merge_request_closes_issues!(@current_user)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def filter_merge_requests(merge_requests)
merge_requests.uniq.select(&:source_project)
diff --git a/app/services/merge_requests/reload_diffs_service.rb b/app/services/merge_requests/reload_diffs_service.rb
index 1390ae0e199..c350b14d12b 100644
--- a/app/services/merge_requests/reload_diffs_service.rb
+++ b/app/services/merge_requests/reload_diffs_service.rb
@@ -27,6 +27,7 @@ module MergeRequests
current_user: current_user)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def clear_cache(new_diff)
# Executing the iteration we cache highlighted diffs for each diff file of
# MergeRequestDiff.
@@ -41,5 +42,6 @@ module MergeRequests
merge_request_diff.diffs_collection.clear_cache
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/milestones/promote_service.rb b/app/services/milestones/promote_service.rb
index 660b4faaec0..39071b5dc14 100644
--- a/app/services/milestones/promote_service.rb
+++ b/app/services/milestones/promote_service.rb
@@ -26,6 +26,7 @@ module Milestones
private
+ # rubocop: disable CodeReuse/ActiveRecord
def milestone_ids_for_merge(group_milestone)
# Pluck need to be used here instead of select so the array of ids
# is persistent after old milestones gets deleted.
@@ -35,6 +36,7 @@ module Milestones
milestones.pluck(:id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_children_to_group_milestone(group_milestone)
milestone_ids_for_merge(group_milestone).in_groups_of(100, false) do |milestone_ids|
@@ -59,6 +61,7 @@ module Milestones
milestone
end
+ # rubocop: disable CodeReuse/ActiveRecord
def update_children(group_milestone, milestone_ids)
issues = Issue.where(project_id: group_project_ids, milestone_id: milestone_ids)
merge_requests = MergeRequest.where(source_project_id: group_project_ids, milestone_id: milestone_ids)
@@ -67,18 +70,23 @@ module Milestones
issuable_collection.update_all(milestone_id: group_milestone.id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def group
@group ||= parent.group || raise_error('Project does not belong to a group.')
end
+ # rubocop: disable CodeReuse/ActiveRecord
def destroy_old_milestones(milestone)
Milestone.where(id: milestone_ids_for_merge(milestone)).destroy_all # rubocop: disable DestroyAll
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def group_project_ids
@group_project_ids ||= group.projects.pluck(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def raise_error(message)
raise PromoteMilestoneError, "Promotion failed - #{message}"
diff --git a/app/services/milestones/update_service.rb b/app/services/milestones/update_service.rb
index 81b20943bab..01ab8b37bac 100644
--- a/app/services/milestones/update_service.rb
+++ b/app/services/milestones/update_service.rb
@@ -2,6 +2,7 @@
module Milestones
class UpdateService < Milestones::BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(milestone)
state = params[:state_event]
@@ -18,5 +19,6 @@ module Milestones
milestone
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb
index 5c0e8a35cb0..9c236d7f41d 100644
--- a/app/services/notification_recipient_service.rb
+++ b/app/services/notification_recipient_service.rb
@@ -58,6 +58,7 @@ module NotificationRecipientService
@recipients ||= []
end
+ # rubocop: disable CodeReuse/ActiveRecord
def add_recipients(users, type, reason)
if users.is_a?(ActiveRecord::Relation)
users = users.includes(:notification_settings)
@@ -66,10 +67,13 @@ module NotificationRecipientService
users = Array(users).compact
recipients.concat(users.map { |u| make_recipient(u, type, reason) })
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def user_scope
User.includes(:notification_settings)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def make_recipient(user, type, reason)
NotificationRecipient.new(
@@ -112,6 +116,7 @@ module NotificationRecipientService
end
# Get project/group users with CUSTOM notification level
+ # rubocop: disable CodeReuse/ActiveRecord
def add_custom_notifications
user_ids = []
@@ -128,6 +133,7 @@ module NotificationRecipientService
add_recipients(user_scope.where(id: user_ids), :watch, nil)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def add_project_watchers
add_recipients(project_watchers, :watch, nil) if project
@@ -138,6 +144,7 @@ module NotificationRecipientService
end
# Get project users with WATCH notification level
+ # rubocop: disable CodeReuse/ActiveRecord
def project_watchers
project_members_ids = user_ids_notifiable_on(project)
@@ -151,7 +158,9 @@ module NotificationRecipientService
user_scope.where(id: user_ids_with_project_setting.concat(user_ids_with_group_setting).uniq)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def group_watchers
user_ids_with_group_global = user_ids_notifiable_on(group, :global)
user_ids = user_ids_with_global_level_watch(user_ids_with_group_global)
@@ -159,6 +168,7 @@ module NotificationRecipientService
user_scope.where(id: user_ids_with_group_setting)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def add_subscribed_users
return unless target.respond_to? :subscribers
@@ -166,6 +176,7 @@ module NotificationRecipientService
add_recipients(target.subscribers(project), :subscription, nil)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def user_ids_notifiable_on(resource, notification_level = nil)
return [] unless resource
@@ -177,6 +188,7 @@ module NotificationRecipientService
scope.pluck(:user_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Build a list of user_ids based on project notification settings
def select_project_members_ids(global_setting, user_ids_global_level_watch)
@@ -194,14 +206,19 @@ module NotificationRecipientService
uids + (global_setting & user_ids_global_level_watch) - project_members
end
+ # rubocop: disable CodeReuse/ActiveRecord
def user_ids_with_global_level_watch(ids)
settings_with_global_level_of(:watch, ids).pluck(:user_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def user_ids_with_global_level_custom(ids, action)
settings_with_global_level_of(:custom, ids).pluck(:user_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def settings_with_global_level_of(level, ids)
NotificationSetting.where(
user_id: ids,
@@ -209,6 +226,7 @@ module NotificationRecipientService
level: NotificationSetting.levels[level]
)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def add_labels_subscribers(labels: nil)
return unless target.respond_to? :labels
diff --git a/app/services/projects/auto_devops/disable_service.rb b/app/services/projects/auto_devops/disable_service.rb
index 9745ab67dbd..1b578a3c5ce 100644
--- a/app/services/projects/auto_devops/disable_service.rb
+++ b/app/services/projects/auto_devops/disable_service.rb
@@ -21,10 +21,12 @@ module Projects
# is an expensive operation. See
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21172#note_99037378
# for more context.
+ # rubocop: disable CodeReuse/ActiveRecord
def first_pipeline_failure?
auto_devops_pipelines.success.limit(1).count.zero? &&
auto_devops_pipelines.failed.limit(1).count.nonzero?
end
+ # rubocop: enable CodeReuse/ActiveRecord
def disable_auto_devops
project.auto_devops_attributes = { enabled: false }
diff --git a/app/services/projects/base_move_relations_service.rb b/app/services/projects/base_move_relations_service.rb
index 78cc2869b72..24dec1f3a45 100644
--- a/app/services/projects/base_move_relations_service.rb
+++ b/app/services/projects/base_move_relations_service.rb
@@ -13,6 +13,7 @@ module Projects
private
+ # rubocop: disable CodeReuse/ActiveRecord
def prepare_relation(relation, id_param = :id)
if Gitlab::Database.postgresql?
relation
@@ -20,5 +21,6 @@ module Projects
relation.model.where("#{id_param}": relation.pluck(id_param))
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/batch_forks_count_service.rb b/app/services/projects/batch_forks_count_service.rb
index 9bf369df999..6467744a435 100644
--- a/app/services/projects/batch_forks_count_service.rb
+++ b/app/services/projects/batch_forks_count_service.rb
@@ -5,6 +5,7 @@
# because the service use maps to retrieve the project ids
module Projects
class BatchForksCountService < Projects::BatchCountService
+ # rubocop: disable CodeReuse/ActiveRecord
def global_count
@global_count ||= begin
count_service.query(project_ids)
@@ -12,6 +13,7 @@ module Projects
.count
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def count_service
::Projects::ForksCountService
diff --git a/app/services/projects/batch_open_issues_count_service.rb b/app/services/projects/batch_open_issues_count_service.rb
index d375fcf9dbd..d6ff2291af8 100644
--- a/app/services/projects/batch_open_issues_count_service.rb
+++ b/app/services/projects/batch_open_issues_count_service.rb
@@ -5,11 +5,13 @@
# because the service use maps to retrieve the project ids
module Projects
class BatchOpenIssuesCountService < Projects::BatchCountService
+ # rubocop: disable CodeReuse/ActiveRecord
def global_count
@global_count ||= begin
count_service.query(project_ids).group(:project_id).count
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def count_service
::Projects::OpenIssuesCountService
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 02a3a3eb096..0e6a7e8da54 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -79,17 +79,21 @@ module Projects
@project.errors.add(:namespace, "is not valid")
end
+ # rubocop: disable CodeReuse/ActiveRecord
def allowed_fork?(source_project_id)
return true if source_project_id.nil?
source_project = Project.find_by(id: source_project_id)
current_user.can?(:fork_project, source_project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def allowed_namespace?(user, namespace_id)
namespace = Namespace.find_by(id: namespace_id)
current_user.can?(:create_projects, namespace)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def after_create_actions
log_info("#{@project.owner.name} created a new project \"#{@project.full_name}\"")
@@ -167,12 +171,14 @@ module Projects
@project
end
+ # rubocop: disable CodeReuse/ActiveRecord
def create_services_from_active_templates(project)
Service.where(template: true, active: true).each do |template|
service = Service.build_from_template(project.id, template)
service.save!
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def set_project_name_from_path
# Set project name from path
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb
index 01de6afcd8e..5090ebf8f51 100644
--- a/app/services/projects/destroy_service.rb
+++ b/app/services/projects/destroy_service.rb
@@ -107,15 +107,19 @@ module Projects
mv_repository(old_path, new_path)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def repo_exists?(path)
gitlab_shell.exists?(project.repository_storage, path + '.git')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def mv_repository(from_path, to_path)
return true unless gitlab_shell.exists?(project.repository_storage, from_path + '.git')
gitlab_shell.mv_repository(project.repository_storage, from_path, to_path)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def attempt_rollback(project, message)
return unless project
diff --git a/app/services/projects/detect_repository_languages_service.rb b/app/services/projects/detect_repository_languages_service.rb
index 3488b9ce47e..4a837a4fb6a 100644
--- a/app/services/projects/detect_repository_languages_service.rb
+++ b/app/services/projects/detect_repository_languages_service.rb
@@ -4,6 +4,7 @@ module Projects
class DetectRepositoryLanguagesService < BaseService
attr_reader :detected_repository_languages, :programming_languages
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
repository_languages = project.repository_languages
detection = Gitlab::LanguageDetection.new(repository, repository_languages)
@@ -28,9 +29,11 @@ module Projects
project.repository_languages.reload
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def ensure_programming_languages(detection)
existing_languages = ProgrammingLanguage.where(name: detection.languages)
return existing_languages if detection.languages.size == existing_languages.size
@@ -42,7 +45,9 @@ module Projects
existing_languages + created_languages
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def create_language(name, color)
ProgrammingLanguage.transaction do
ProgrammingLanguage.where(name: name).first_or_create(color: color)
@@ -50,5 +55,6 @@ module Projects
rescue ActiveRecord::RecordNotUnique
retry
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/enable_deploy_key_service.rb b/app/services/projects/enable_deploy_key_service.rb
index b7c172028e9..102088e9557 100644
--- a/app/services/projects/enable_deploy_key_service.rb
+++ b/app/services/projects/enable_deploy_key_service.rb
@@ -2,6 +2,7 @@
module Projects
class EnableDeployKeyService < BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
key = accessible_keys.find_by(id: params[:key_id] || params[:id])
return unless key
@@ -12,6 +13,7 @@ module Projects
key
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/services/projects/forks_count_service.rb b/app/services/projects/forks_count_service.rb
index b570c6d4754..00e73148358 100644
--- a/app/services/projects/forks_count_service.rb
+++ b/app/services/projects/forks_count_service.rb
@@ -7,11 +7,13 @@ module Projects
'forks_count'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def self.query(project_ids)
# We can't directly change ForkedProjectLink to ForkNetworkMember here
# Nowadays, when a call using v3 to projects/:id/fork is made,
# the relationship to ForkNetworkMember is not updated
ForkedProjectLink.where(forked_from_project: project_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/gitlab_projects_import_service.rb b/app/services/projects/gitlab_projects_import_service.rb
index 044afa1d5e1..a315adf42f0 100644
--- a/app/services/projects/gitlab_projects_import_service.rb
+++ b/app/services/projects/gitlab_projects_import_service.rb
@@ -32,11 +32,13 @@ module Projects
Project.find_by_full_path("#{current_namespace.full_path}/#{params[:path]}").present?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def current_namespace
strong_memoize(:current_namespace) do
Namespace.find_by(id: params[:namespace_id])
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def overwrite?
strong_memoize(:overwrite) do
diff --git a/app/services/projects/hashed_storage/migrate_repository_service.rb b/app/services/projects/hashed_storage/migrate_repository_service.rb
index 641d46e6591..4462d504071 100644
--- a/app/services/projects/hashed_storage/migrate_repository_service.rb
+++ b/app/services/projects/hashed_storage/migrate_repository_service.rb
@@ -47,10 +47,13 @@ module Projects
private
+ # rubocop: disable CodeReuse/ActiveRecord
def has_wiki?
gitlab_shell.exists?(project.repository_storage, "#{old_wiki_disk_path}.git")
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def move_repository(from_name, to_name)
from_exists = gitlab_shell.exists?(project.repository_storage, "#{from_name}.git")
to_exists = gitlab_shell.exists?(project.repository_storage, "#{to_name}.git")
@@ -67,6 +70,7 @@ module Projects
gitlab_shell.mv_repository(project.repository_storage, from_name, to_name)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def rollback_folder_move
move_repository(new_disk_path, old_disk_path)
diff --git a/app/services/projects/lfs_pointers/lfs_download_service.rb b/app/services/projects/lfs_pointers/lfs_download_service.rb
index 7d4fa4e08df..1c4a8d05be6 100644
--- a/app/services/projects/lfs_pointers/lfs_download_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_download_service.rb
@@ -4,6 +4,7 @@
module Projects
module LfsPointers
class LfsDownloadService < BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(oid, url)
return unless project&.lfs_enabled? && oid.present? && url.present?
@@ -20,6 +21,7 @@ module Projects
rescue StandardError => e
Rails.logger.error("LFS file with oid #{oid} could't be downloaded from #{sanitized_uri.sanitized_url}: #{e.message}")
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/services/projects/lfs_pointers/lfs_import_service.rb b/app/services/projects/lfs_pointers/lfs_import_service.rb
index 97ce681a911..9215fa0a7bf 100644
--- a/app/services/projects/lfs_pointers/lfs_import_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_import_service.rb
@@ -41,6 +41,7 @@ module Projects
project.update(lfs_enabled: false)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def get_download_links
existent_lfs = LfsListService.new(project).execute
linked_oids = LfsLinkService.new(project).execute(existent_lfs.keys)
@@ -50,6 +51,7 @@ module Projects
LfsDownloadLinkListService.new(project, remote_uri: current_endpoint_uri).execute(not_linked_lfs)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def lfsconfig_endpoint_uri
strong_memoize(:lfsconfig_endpoint_uri) do
diff --git a/app/services/projects/lfs_pointers/lfs_link_service.rb b/app/services/projects/lfs_pointers/lfs_link_service.rb
index a2eba8e124e..8401f3d1d89 100644
--- a/app/services/projects/lfs_pointers/lfs_link_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_link_service.rb
@@ -16,6 +16,7 @@ module Projects
private
+ # rubocop: disable CodeReuse/ActiveRecord
def link_existing_lfs_objects(oids)
existent_lfs_objects = LfsObject.where(oid: oids)
@@ -26,6 +27,7 @@ module Projects
existent_lfs_objects.pluck(:oid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/services/projects/move_deploy_keys_projects_service.rb b/app/services/projects/move_deploy_keys_projects_service.rb
index 9f3f44f30ea..b6a3af8c7b8 100644
--- a/app/services/projects/move_deploy_keys_projects_service.rb
+++ b/app/services/projects/move_deploy_keys_projects_service.rb
@@ -20,11 +20,13 @@ module Projects
.update_all(project_id: @project.id)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def non_existent_deploy_keys_projects
source_project.deploy_keys_projects
.joins(:deploy_key)
.where.not(keys: { fingerprint: @project.deploy_keys.select(:fingerprint) })
end
+ # rubocop: enable CodeReuse/ActiveRecord
def remove_remaining_deploy_keys_projects
source_project.deploy_keys_projects.destroy_all # rubocop: disable DestroyAll
diff --git a/app/services/projects/move_forks_service.rb b/app/services/projects/move_forks_service.rb
index 076a7a50aa9..2948555a17c 100644
--- a/app/services/projects/move_forks_service.rb
+++ b/app/services/projects/move_forks_service.rb
@@ -17,6 +17,7 @@ module Projects
private
+ # rubocop: disable CodeReuse/ActiveRecord
def move_forked_project_links
# Update ancestor
ForkedProjectLink.where(forked_to_project: source_project)
@@ -26,16 +27,21 @@ module Projects
ForkedProjectLink.where(forked_from_project: source_project)
.update_all(forked_from_project_id: @project.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def move_fork_network_members
ForkNetworkMember.where(project: source_project).update_all(project_id: @project.id)
ForkNetworkMember.where(forked_from_project: source_project).update_all(forked_from_project_id: @project.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_root_project
# Update root network project
ForkNetwork.where(root_project: source_project).update_all(root_project_id: @project.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def refresh_forks_count
Projects::ForksCountService.new(@project).refresh_cache
diff --git a/app/services/projects/move_lfs_objects_projects_service.rb b/app/services/projects/move_lfs_objects_projects_service.rb
index f78546a1e9c..308a54ad06e 100644
--- a/app/services/projects/move_lfs_objects_projects_service.rb
+++ b/app/services/projects/move_lfs_objects_projects_service.rb
@@ -24,8 +24,10 @@ module Projects
source_project.lfs_objects_projects.destroy_all # rubocop: disable DestroyAll
end
+ # rubocop: disable CodeReuse/ActiveRecord
def non_existent_lfs_objects_projects
source_project.lfs_objects_projects.where.not(lfs_object: @project.lfs_objects)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/move_notification_settings_service.rb b/app/services/projects/move_notification_settings_service.rb
index 109a00dd6d9..e740c44bd26 100644
--- a/app/services/projects/move_notification_settings_service.rb
+++ b/app/services/projects/move_notification_settings_service.rb
@@ -31,10 +31,12 @@ module Projects
end
# Look for notification_settings in source_project that are not in the target project
+ # rubocop: disable CodeReuse/ActiveRecord
def non_existent_notifications
source_project.notification_settings
.select(:id)
.where.not(user_id: users_in_target_project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/move_project_authorizations_service.rb b/app/services/projects/move_project_authorizations_service.rb
index 60f2af88e99..2060a263751 100644
--- a/app/services/projects/move_project_authorizations_service.rb
+++ b/app/services/projects/move_project_authorizations_service.rb
@@ -33,10 +33,12 @@ module Projects
end
# Look for authorizations in source_project that are not in the target project
+ # rubocop: disable CodeReuse/ActiveRecord
def non_existent_authorization
source_project.project_authorizations
.select(:user_id)
.where.not(user: @project.authorized_users)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/move_project_group_links_service.rb b/app/services/projects/move_project_group_links_service.rb
index 1efafdce36d..fb395ecb9a1 100644
--- a/app/services/projects/move_project_group_links_service.rb
+++ b/app/services/projects/move_project_group_links_service.rb
@@ -34,9 +34,11 @@ module Projects
end
# Look for groups in source_project that are not in the target project
+ # rubocop: disable CodeReuse/ActiveRecord
def non_existent_group_links
source_project.project_group_links
.where.not(group_id: group_links_in_target_project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/move_project_members_service.rb b/app/services/projects/move_project_members_service.rb
index ec983582d94..f28f44adc03 100644
--- a/app/services/projects/move_project_members_service.rb
+++ b/app/services/projects/move_project_members_service.rb
@@ -33,10 +33,12 @@ module Projects
end
# Look for members in source_project that are not in the target project
+ # rubocop: disable CodeReuse/ActiveRecord
def non_existent_members
source_project.members
.select(:id)
.where.not(user_id: @project.project_members.select(:user_id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/open_issues_count_service.rb b/app/services/projects/open_issues_count_service.rb
index 5d6620c3c54..ee9884e9042 100644
--- a/app/services/projects/open_issues_count_service.rb
+++ b/app/services/projects/open_issues_count_service.rb
@@ -42,6 +42,7 @@ module Projects
cache_key(TOTAL_COUNT_KEY)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def refresh_cache(&block)
if block_given?
super(&block)
@@ -59,11 +60,13 @@ module Projects
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# We only show total issues count for reporters
# which are allowed to view confidential issues
# This will still show a discrepancy on issues number but should be less than before.
# Check https://gitlab.com/gitlab-org/gitlab-ce/issues/38418 description.
+ # rubocop: disable CodeReuse/ActiveRecord
def self.query(projects, public_only: true)
if public_only
Issue.opened.public_only.where(project: projects)
@@ -71,5 +74,6 @@ module Projects
Issue.opened.where(project: projects)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/projects/propagate_service_template.rb b/app/services/projects/propagate_service_template.rb
index fdfa91801ab..633a263af7b 100644
--- a/app/services/projects/propagate_service_template.rb
+++ b/app/services/projects/propagate_service_template.rb
@@ -70,6 +70,7 @@ module Projects
)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def service_hash
@service_hash ||=
begin
@@ -83,7 +84,9 @@ module Projects
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def run_callbacks(batch)
if active_external_issue_tracker?
Project.where(id: batch).update_all(has_external_issue_tracker: true)
@@ -93,6 +96,7 @@ module Projects
Project.where(id: batch).update_all(has_external_wiki: true)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def active_external_issue_tracker?
@template.issue_tracker? && !@template.default
diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb
index 3746cfef702..9d40ab166ff 100644
--- a/app/services/projects/transfer_service.rb
+++ b/app/services/projects/transfer_service.rb
@@ -37,6 +37,7 @@ module Projects
private
+ # rubocop: disable CodeReuse/ActiveRecord
def transfer(project)
@old_path = project.full_path
@old_group = project.group
@@ -54,6 +55,7 @@ module Projects
attempt_transfer_transaction
end
+ # rubocop: enable CodeReuse/ActiveRecord
def attempt_transfer_transaction
Project.transaction do
diff --git a/app/services/projects/unlink_fork_service.rb b/app/services/projects/unlink_fork_service.rb
index 2c0d91fe34f..a8b7c7f136a 100644
--- a/app/services/projects/unlink_fork_service.rb
+++ b/app/services/projects/unlink_fork_service.rb
@@ -2,6 +2,7 @@
module Projects
class UnlinkForkService < BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
return unless @project.forked?
@@ -26,6 +27,7 @@ module Projects
@project.fork_network_member.destroy
@project.forked_project_link.destroy
end
+ # rubocop: enable CodeReuse/ActiveRecord
def refresh_forks_count(project)
Projects::ForksCountService.new(project).refresh_cache
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb
index e390d7a04c3..d6d9bacf232 100644
--- a/app/services/projects/update_service.rb
+++ b/app/services/projects/update_service.rb
@@ -6,6 +6,7 @@ module Projects
ValidationError = Class.new(StandardError)
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
validate!
@@ -26,6 +27,7 @@ module Projects
rescue ValidationError => e
error(e.message)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def run_auto_devops_pipeline?
return false if project.repository.gitlab_ci_yml || !project.auto_devops&.previous_changes&.include?('enabled')
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb
index be9d1e48435..02d68c3add3 100644
--- a/app/services/quick_actions/interpret_service.rb
+++ b/app/services/quick_actions/interpret_service.rb
@@ -111,10 +111,12 @@ module QuickActions
end
desc 'Assign'
+ # rubocop: disable CodeReuse/ActiveRecord
explanation do |users|
users = issuable.allows_multiple_assignees? ? users : users.take(1)
"Assigns #{users.map(&:to_reference).to_sentence}."
end
+ # rubocop: enable CodeReuse/ActiveRecord
params do
issuable.allows_multiple_assignees? ? '@user1 @user2' : '@user'
end
@@ -124,6 +126,7 @@ module QuickActions
parse_params do |assignee_param|
extract_users(assignee_param)
end
+ # rubocop: disable CodeReuse/ActiveRecord
command :assign do |users|
next if users.empty?
@@ -134,6 +137,7 @@ module QuickActions
[users.first.id]
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc do
if issuable.allows_multiple_assignees?
@@ -160,6 +164,7 @@ module QuickActions
# When multiple users are assigned, all will be unassigned if multiple assignees are no longer allowed
extract_users(unassign_param) if issuable.allows_multiple_assignees?
end
+ # rubocop: disable CodeReuse/ActiveRecord
command :unassign do |users = nil|
@updates[:assignee_ids] =
if users&.any?
@@ -168,6 +173,7 @@ module QuickActions
[]
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Set milestone'
explanation do |milestone|
@@ -546,6 +552,7 @@ module QuickActions
current_user.can?(:"update_#{issuable.to_ability_name}", issuable) &&
issuable.project.boards.count == 1
end
+ # rubocop: disable CodeReuse/ActiveRecord
command :board_move do |target_list_name|
label_ids = find_label_ids(target_list_name)
@@ -560,6 +567,7 @@ module QuickActions
@updates[:add_label_ids] = [label_id]
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Mark this issue as a duplicate of another issue'
explanation do |duplicate_reference|
@@ -625,6 +633,7 @@ module QuickActions
@updates[:tag_message] = message
end
+ # rubocop: disable CodeReuse/ActiveRecord
def extract_users(params)
return [] if params.nil?
@@ -641,6 +650,7 @@ module QuickActions
users
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_milestones(project, params = {})
MilestonesFinder.new(params.merge(project_ids: [project.id], group_ids: [project.group&.id])).execute
@@ -677,6 +687,7 @@ module QuickActions
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def extract_references(arg, type)
ext = Gitlab::ReferenceExtractor.new(project, current_user)
@@ -684,5 +695,6 @@ module QuickActions
ext.references(type)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/quick_actions/target_service.rb b/app/services/quick_actions/target_service.rb
index d8ba52c6e50..69464c3c1ae 100644
--- a/app/services/quick_actions/target_service.rb
+++ b/app/services/quick_actions/target_service.rb
@@ -15,13 +15,17 @@ module QuickActions
private
+ # rubocop: disable CodeReuse/ActiveRecord
def issue(type_id)
IssuesFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.issues.build
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_request(type_id)
MergeRequestsFinder.new(current_user, project_id: project.id).find_by(iid: type_id) || project.merge_requests.build
end
+ # rubocop: enable CodeReuse/ActiveRecord
def commit(type_id)
project.commit(type_id)
diff --git a/app/services/resource_events/merge_into_notes_service.rb b/app/services/resource_events/merge_into_notes_service.rb
index 1b02a1602e2..596c0105ea0 100644
--- a/app/services/resource_events/merge_into_notes_service.rb
+++ b/app/services/resource_events/merge_into_notes_service.rb
@@ -30,6 +30,7 @@ module ResourceEvents
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def label_events_by_discussion_id
return [] unless resource.respond_to?(:resource_label_events)
@@ -38,6 +39,7 @@ module ResourceEvents
events.group_by { |event| event.discussion_id }
end
+ # rubocop: enable CodeReuse/ActiveRecord
def since_fetch_at(events)
return events unless params[:last_fetched_at].present?
diff --git a/app/services/search/group_service.rb b/app/services/search/group_service.rb
index 34803d005e3..00372887985 100644
--- a/app/services/search/group_service.rb
+++ b/app/services/search/group_service.rb
@@ -11,11 +11,13 @@ module Search
@group = group
end
+ # rubocop: disable CodeReuse/ActiveRecord
def projects
return Project.none unless group
return @projects if defined? @projects
@projects = super.inside_path(group.full_path)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/services/search_service.rb b/app/services/search_service.rb
index 1b707d79b43..e0cbfac2420 100644
--- a/app/services/search_service.rb
+++ b/app/services/search_service.rb
@@ -8,6 +8,7 @@ class SearchService
@params = params.dup
end
+ # rubocop: disable CodeReuse/ActiveRecord
def project
return @project if defined?(@project)
@@ -19,7 +20,9 @@ class SearchService
nil
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def group
return @group if defined?(@group)
@@ -31,6 +34,7 @@ class SearchService
nil
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def show_snippets?
return @show_snippets if defined?(@show_snippets)
diff --git a/app/services/spam_check_service.rb b/app/services/spam_check_service.rb
index 895261925ba..51d300d4f1d 100644
--- a/app/services/spam_check_service.rb
+++ b/app/services/spam_check_service.rb
@@ -22,6 +22,7 @@ module SpamCheckService
# a dirty instance, which means it should be already assigned with the new
# attribute values.
# rubocop:disable Gitlab/ModuleWithInstanceVariables
+ # rubocop: disable CodeReuse/ActiveRecord
def spam_check(spammable, user)
spam_service = SpamService.new(spammable, @request)
@@ -29,5 +30,6 @@ module SpamCheckService
user.spam_logs.find_by(id: @spam_log_id)&.update!(recaptcha_verified: true)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# rubocop:enable Gitlab/ModuleWithInstanceVariables
end
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index c5d05992575..575678da1fa 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -580,6 +580,7 @@ module SystemNoteService
private
+ # rubocop: disable CodeReuse/ActiveRecord
def notes_for_mentioner(mentioner, noteable, notes)
if mentioner.is_a?(Commit)
text = "#{cross_reference_note_prefix}%#{mentioner.to_reference(nil)}"
@@ -590,6 +591,7 @@ module SystemNoteService
notes.where(note: [text, text.capitalize])
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create_note(note_summary)
note = Note.create(note_summary.note.merge(system: true))
diff --git a/app/services/tags/destroy_service.rb b/app/services/tags/destroy_service.rb
index 800268485a4..6bfef09ac54 100644
--- a/app/services/tags/destroy_service.rb
+++ b/app/services/tags/destroy_service.rb
@@ -2,6 +2,7 @@
module Tags
class DestroyService < BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(tag_name)
repository = project.repository
tag = repository.find_tag(tag_name)
@@ -26,6 +27,7 @@ module Tags
rescue Gitlab::Git::PreReceiveError => ex
error(ex.message)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def error(message, return_code = 400)
super(message).merge(return_code: return_code)
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb
index 0df61ad3bce..4fe6c1ec986 100644
--- a/app/services/todo_service.rb
+++ b/app/services/todo_service.rb
@@ -41,6 +41,7 @@ class TodoService
# collects the todo users before the todos themselves are deleted, then
# updates the todo counts for those users.
#
+ # rubocop: disable CodeReuse/ActiveRecord
def destroy_target(target)
todo_users = User.where(id: target.todos.pending.select(:user_id)).to_a
@@ -48,6 +49,7 @@ class TodoService
todo_users.each(&:update_todos_count_cache)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# When we reassign an issue we should:
#
@@ -198,16 +200,21 @@ class TodoService
create_todos(current_user, attributes)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def todo_exist?(issuable, current_user)
TodosFinder.new(current_user).execute.exists?(target: issuable)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def todos_by_ids(ids, current_user)
current_user.todos.where(id: Array(ids))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def update_todos_state(todos, current_user, state)
# Only update those that are not really on that state
todos = todos.where.not(state: state)
@@ -216,6 +223,7 @@ class TodoService
current_user.update_todos_count_cache
todos_ids
end
+ # rubocop: enable CodeReuse/ActiveRecord
def create_todos(users, attributes)
Array(users).map do |user|
@@ -340,8 +348,10 @@ class TodoService
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def pending_todos(user, criteria = {})
valid_keys = [:project_id, :target_id, :target_type, :commit_id]
user.todos.pending.where(criteria.slice(*valid_keys))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/todos/destroy/base_service.rb b/app/services/todos/destroy/base_service.rb
index aeb60e50c64..f3f1dbb5698 100644
--- a/app/services/todos/destroy/base_service.rb
+++ b/app/services/todos/destroy/base_service.rb
@@ -11,13 +11,17 @@ module Todos
private
+ # rubocop: disable CodeReuse/ActiveRecord
def without_authorized(items)
items.where('user_id NOT IN (?)', authorized_users)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def authorized_users
ProjectAuthorization.select(:user_id).where(project_id: project_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def todos
raise NotImplementedError
diff --git a/app/services/todos/destroy/confidential_issue_service.rb b/app/services/todos/destroy/confidential_issue_service.rb
index efec0f22da5..6276e332448 100644
--- a/app/services/todos/destroy/confidential_issue_service.rb
+++ b/app/services/todos/destroy/confidential_issue_service.rb
@@ -7,18 +7,22 @@ module Todos
attr_reader :issue
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(issue_id)
@issue = Issue.find_by(id: issue_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
override :todos
+ # rubocop: disable CodeReuse/ActiveRecord
def todos
Todo.where(target: issue)
.where('user_id != ?', issue.author_id)
.where('user_id NOT IN (?)', issue.assignees.select(:id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
override :todos_to_remove?
def todos_to_remove?
@@ -31,11 +35,13 @@ module Todos
end
override :authorized_users
+ # rubocop: disable CodeReuse/ActiveRecord
def authorized_users
ProjectAuthorization.select(:user_id)
.where(project_id: project_ids)
.where('access_level >= ?', Gitlab::Access::REPORTER)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/services/todos/destroy/entity_leave_service.rb b/app/services/todos/destroy/entity_leave_service.rb
index 4cb9d08713d..e8d1bcdd142 100644
--- a/app/services/todos/destroy/entity_leave_service.rb
+++ b/app/services/todos/destroy/entity_leave_service.rb
@@ -7,6 +7,7 @@ module Todos
attr_reader :user, :entity
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(user_id, entity_id, entity_type)
unless %w(Group Project).include?(entity_type)
raise ArgumentError.new("#{entity_type} is not an entity user can leave")
@@ -15,6 +16,7 @@ module Todos
@user = User.find_by(id: user_id)
@entity = entity_type.constantize.find_by(id: entity_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def execute
return unless entity && user
@@ -40,21 +42,28 @@ module Todos
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_confidential_issue_todos
Todo.where(
target_id: confidential_issues.select(:id), target_type: Issue, user_id: user.id
).delete_all
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_project_todos
Todo.where(project_id: non_authorized_projects, user_id: user.id).delete_all
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_group_todos
Todo.where(group_id: non_authorized_groups, user_id: user.id).delete_all
end
+ # rubocop: enable CodeReuse/ActiveRecord
override :project_ids
+ # rubocop: disable CodeReuse/ActiveRecord
def project_ids
condition = case entity
when Project
@@ -65,22 +74,29 @@ module Todos
Project.where(condition).select(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def non_authorized_projects
project_ids.where('id NOT IN (?)', user.authorized_projects.select(:id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def non_authorized_groups
return [] unless entity.is_a?(Namespace)
entity.self_and_descendants.select(:id)
.where('id NOT IN (?)', GroupsFinder.new(user).execute.select(:id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def non_member_groups
entity.self_and_descendants.select(:id)
.where('id NOT IN (?)', user.membership_groups.select(:id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
def user_has_reporter_access?
return unless entity.is_a?(Namespace)
@@ -88,6 +104,7 @@ module Todos
entity.member?(User.find(user.id), Gitlab::Access::REPORTER)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def confidential_issues
assigned_ids = IssueAssignee.select(:issue_id).where(user_id: user.id)
authorized_reporter_projects = user
@@ -98,6 +115,7 @@ module Todos
.where('author_id != ?', user.id)
.where('id NOT IN (?)', assigned_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/services/todos/destroy/group_private_service.rb b/app/services/todos/destroy/group_private_service.rb
index f67f1d40597..d7ecbb952aa 100644
--- a/app/services/todos/destroy/group_private_service.rb
+++ b/app/services/todos/destroy/group_private_service.rb
@@ -7,16 +7,20 @@ module Todos
attr_reader :group
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(group_id)
@group = Group.find_by(id: group_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
override :todos
+ # rubocop: disable CodeReuse/ActiveRecord
def todos
Todo.where(group_id: group.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
override :authorized_users
def authorized_users
diff --git a/app/services/todos/destroy/private_features_service.rb b/app/services/todos/destroy/private_features_service.rb
index 7e204885b31..a8c3fe0ef5a 100644
--- a/app/services/todos/destroy/private_features_service.rb
+++ b/app/services/todos/destroy/private_features_service.rb
@@ -10,6 +10,7 @@ module Todos
@user_id = user_id
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute
ProjectFeature.where(project_id: project_ids).each do |project_features|
target_types = []
@@ -22,6 +23,7 @@ module Todos
remove_todos(project_features.project_id, target_types)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -29,6 +31,7 @@ module Todos
feature_level == ProjectFeature::PRIVATE
end
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_todos(project_id, target_types)
items = Todo.where(project_id: project_id)
items = items.where(user_id: user_id) if user_id
@@ -37,6 +40,7 @@ module Todos
.where(target_type: target_types)
.delete_all
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/services/todos/destroy/project_private_service.rb b/app/services/todos/destroy/project_private_service.rb
index ae8fab3ffca..e00d10c3780 100644
--- a/app/services/todos/destroy/project_private_service.rb
+++ b/app/services/todos/destroy/project_private_service.rb
@@ -7,16 +7,20 @@ module Todos
attr_reader :project
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(project_id)
@project = Project.find_by(id: project_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
override :todos
+ # rubocop: disable CodeReuse/ActiveRecord
def todos
Todo.where(project_id: project.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
override :project_ids
def project_ids
diff --git a/app/services/update_release_service.rb b/app/services/update_release_service.rb
index 422ba668e35..e2228ca026c 100644
--- a/app/services/update_release_service.rb
+++ b/app/services/update_release_service.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
class UpdateReleaseService < BaseService
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(tag_name, release_description)
repository = project.repository
existing_tag = repository.find_tag(tag_name)
@@ -19,6 +20,7 @@ class UpdateReleaseService < BaseService
error('Tag does not exist', 404)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def success(release)
super().merge(release: release)
diff --git a/app/services/users/last_push_event_service.rb b/app/services/users/last_push_event_service.rb
index a9c9497520b..b3980b8e32c 100644
--- a/app/services/users/last_push_event_service.rb
+++ b/app/services/users/last_push_event_service.rb
@@ -58,11 +58,13 @@ module Users
private
+ # rubocop: disable CodeReuse/ActiveRecord
def find_event_in_database(id)
PushEvent
.without_existing_merge_requests
.find_by(id: id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def user_cache_key
"last-push-event/#{@user.id}"
diff --git a/app/services/users/migrate_to_ghost_user_service.rb b/app/services/users/migrate_to_ghost_user_service.rb
index 4d47078bf43..04fd6e37501 100644
--- a/app/services/users/migrate_to_ghost_user_service.rb
+++ b/app/services/users/migrate_to_ghost_user_service.rb
@@ -54,15 +54,19 @@ module Users
migrate_award_emoji
end
+ # rubocop: disable CodeReuse/ActiveRecord
def migrate_issues
user.issues.update_all(author_id: ghost_user.id)
Issue.where(last_edited_by_id: user.id).update_all(last_edited_by_id: ghost_user.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def migrate_merge_requests
user.merge_requests.update_all(author_id: ghost_user.id)
MergeRequest.where(merge_user_id: user.id).update_all(merge_user_id: ghost_user.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def migrate_notes
user.notes.update_all(author_id: ghost_user.id)
diff --git a/app/services/users/respond_to_terms_service.rb b/app/services/users/respond_to_terms_service.rb
index 9efa3b285a8..254480304f9 100644
--- a/app/services/users/respond_to_terms_service.rb
+++ b/app/services/users/respond_to_terms_service.rb
@@ -6,6 +6,7 @@ module Users
@user, @term = user, term
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(accepted:)
agreement = @user.term_agreements.find_or_initialize_by(term: @term)
agreement.accepted = accepted
@@ -16,6 +17,7 @@ module Users
agreement
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/uploaders/records_uploads.rb b/app/uploaders/records_uploads.rb
index 5795065ae11..0efca895a50 100644
--- a/app/uploaders/records_uploads.rb
+++ b/app/uploaders/records_uploads.rb
@@ -18,6 +18,7 @@ module RecordsUploads
# `Tempfile` object the callback gets.
#
# Called `after :store`
+ # rubocop: disable CodeReuse/ActiveRecord
def record_upload(_tempfile = nil)
return unless model
return unless file && file.exists?
@@ -29,6 +30,7 @@ module RecordsUploads
self.upload = build_upload.tap(&:save!)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def upload_path
File.join(store_dir, filename.to_s)
@@ -36,9 +38,11 @@ module RecordsUploads
private
+ # rubocop: disable CodeReuse/ActiveRecord
def uploads
Upload.order(id: :desc).where(uploader: self.class.to_s)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def build_upload
Upload.new(
@@ -53,11 +57,13 @@ module RecordsUploads
# Before removing an attachment, destroy any Upload records at the same path
#
# Called `before :remove`
+ # rubocop: disable CodeReuse/ActiveRecord
def destroy_upload(*args)
return unless file && file.exists?
self.upload = nil
uploads.where(path: upload_path).delete_all
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/validators/variable_duplicates_validator.rb b/app/validators/variable_duplicates_validator.rb
index 90193e85f2a..d36a56e81b9 100644
--- a/app/validators/variable_duplicates_validator.rb
+++ b/app/validators/variable_duplicates_validator.rb
@@ -21,6 +21,7 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
private
+ # rubocop: disable CodeReuse/ActiveRecord
def validate_duplicates(record, attribute, values)
duplicates = values.reject(&:marked_for_destruction?).group_by(&:key).select { |_, v| v.many? }.map(&:first)
if duplicates.any?
@@ -29,4 +30,5 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
record.errors.add(attribute, error_message)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/views/admin/users/projects.html.haml b/app/views/admin/users/projects.html.haml
index 3d39c1da408..e6da81831ab 100644
--- a/app/views/admin/users/projects.html.haml
+++ b/app/views/admin/users/projects.html.haml
@@ -7,7 +7,7 @@
.card
.card-header Group projects
%ul.hover-list
- - @user.group_members.includes(:source).each do |group_member|
+ - @user.group_members.includes(:source).each do |group_member| # rubocop: disable CodeReuse/ActiveRecord
- group = group_member.group
%li.group_member
%strong= link_to group.name, admin_group_path(group)
diff --git a/app/views/dashboard/issues.atom.builder b/app/views/dashboard/issues.atom.builder
index d7b6fb9a4a1..6034389b897 100644
--- a/app/views/dashboard/issues.atom.builder
+++ b/app/views/dashboard/issues.atom.builder
@@ -1,3 +1,4 @@
+# rubocop: disable CodeReuse/ActiveRecord
xml.title "#{current_user.name} issues"
xml.link href: url_for(safe_params), rel: "self", type: "application/atom+xml"
xml.link href: issues_dashboard_url, rel: "alternate", type: "text/html"
@@ -5,3 +6,4 @@ xml.id issues_dashboard_url
xml.updated @issues.first.updated_at.xmlschema if @issues.reorder(nil).any?
xml << render(partial: 'issues/issue', collection: @issues) if @issues.reorder(nil).any?
+# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/views/doorkeeper/applications/index.html.haml b/app/views/doorkeeper/applications/index.html.haml
index ab3a1b100ce..b11f441b3ba 100644
--- a/app/views/doorkeeper/applications/index.html.haml
+++ b/app/views/doorkeeper/applications/index.html.haml
@@ -62,7 +62,7 @@
%th
%tbody
- @authorized_apps.each do |app|
- - token = app.authorized_tokens.order('created_at desc').first
+ - token = app.authorized_tokens.order('created_at desc').first # rubocop: disable CodeReuse/ActiveRecord
%tr{ id: "application_#{app.id}" }
%td= app.name
%td= token.created_at
diff --git a/app/views/groups/issues.atom.builder b/app/views/groups/issues.atom.builder
index 2a385b661e5..2fd96c9d158 100644
--- a/app/views/groups/issues.atom.builder
+++ b/app/views/groups/issues.atom.builder
@@ -1,3 +1,4 @@
+# rubocop: disable CodeReuse/ActiveRecord
xml.title "#{@group.name} issues"
xml.link href: url_for(safe_params), rel: "self", type: "application/atom+xml"
xml.link href: issues_group_url, rel: "alternate", type: "text/html"
@@ -5,3 +6,4 @@ xml.id issues_group_url
xml.updated @issues.first.updated_at.xmlschema if @issues.reorder(nil).any?
xml << render(partial: 'issues/issue', collection: @issues) if @issues.reorder(nil).any?
+# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/views/issues/_issues_calendar.ics.ruby b/app/views/issues/_issues_calendar.ics.ruby
index 3563635d33d..73ab8489e0c 100644
--- a/app/views/issues/_issues_calendar.ics.ruby
+++ b/app/views/issues/_issues_calendar.ics.ruby
@@ -2,6 +2,7 @@ cal = Icalendar::Calendar.new
cal.prodid = '-//GitLab//NONSGML GitLab//EN'
cal.x_wr_calname = 'GitLab Issues'
+# rubocop: disable CodeReuse/ActiveRecord
@issues.includes(project: :namespace).each do |issue|
cal.event do |event|
event.dtstart = Icalendar::Values::Date.new(issue.due_date)
@@ -11,5 +12,6 @@ cal.x_wr_calname = 'GitLab Issues'
event.transp = 'TRANSPARENT'
end
end
+# rubocop: enable CodeReuse/ActiveRecord
cal.to_ical
diff --git a/app/views/projects/diffs/_stats.html.haml b/app/views/projects/diffs/_stats.html.haml
index aa1112c3313..229a4574eeb 100644
--- a/app/views/projects/diffs/_stats.html.haml
+++ b/app/views/projects/diffs/_stats.html.haml
@@ -1,5 +1,5 @@
-- sum_added_lines = diff_files.sum(&:added_lines)
-- sum_removed_lines = diff_files.sum(&:removed_lines)
+- sum_added_lines = diff_files.sum(&:added_lines) # rubocop: disable CodeReuse/ActiveRecord
+- sum_removed_lines = diff_files.sum(&:removed_lines) # rubocop: disable CodeReuse/ActiveRecord
.commit-stat-summary.dropdown
Showing
%button.diff-stats-summary-toggler.js-diff-stats-dropdown{ type: "button", data: { toggle: "dropdown", display: "static" } }<
diff --git a/app/views/projects/issues/index.atom.builder b/app/views/projects/issues/index.atom.builder
index 6330245954e..6566866be82 100644
--- a/app/views/projects/issues/index.atom.builder
+++ b/app/views/projects/issues/index.atom.builder
@@ -1,3 +1,4 @@
+# rubocop: disable CodeReuse/ActiveRecord
xml.title "#{@project.name} issues"
xml.link href: url_for(safe_params), rel: "self", type: "application/atom+xml"
xml.link href: project_issues_url(@project), rel: "alternate", type: "text/html"
@@ -5,3 +6,4 @@ xml.id project_issues_url(@project)
xml.updated @issues.first.updated_at.xmlschema if @issues.reorder(nil).any?
xml << render(partial: 'issues/issue', collection: @issues) if @issues.reorder(nil).any?
+# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/views/projects/jobs/index.html.haml b/app/views/projects/jobs/index.html.haml
index fe1c338b634..59592abcf6a 100644
--- a/app/views/projects/jobs/index.html.haml
+++ b/app/views/projects/jobs/index.html.haml
@@ -8,7 +8,7 @@
.nav-controls
- if can?(current_user, :update_build, @project)
- - if @all_builds.running_or_pending.limit(1).any?
+ - if @all_builds.running_or_pending.limit(1).any? # rubocop: disable CodeReuse/ActiveRecord
= link_to 'Cancel running', cancel_all_project_jobs_path(@project),
data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post
diff --git a/app/views/projects/runners/_runner.html.haml b/app/views/projects/runners/_runner.html.haml
index 6ee83fae25e..548977d6a80 100644
--- a/app/views/projects/runners/_runner.html.haml
+++ b/app/views/projects/runners/_runner.html.haml
@@ -24,7 +24,7 @@
- if runner.belongs_to_one_project?
= link_to _('Remove Runner'), project_runner_path(@project, runner), data: { confirm: _("Are you sure?") }, method: :delete, class: 'btn btn-danger btn-sm'
- else
- - runner_project = @project.runner_projects.find_by(runner_id: runner)
+ - runner_project = @project.runner_projects.find_by(runner_id: runner) # rubocop: disable CodeReuse/ActiveRecord
= link_to _('Disable for this project'), project_runner_project_path(@project, runner_project), data: { confirm: _("Are you sure?") }, method: :delete, class: 'btn btn-danger btn-sm'
- elsif runner.project_type?
= form_for [@project.namespace.becomes(Namespace), @project, @project.runner_projects.new] do |f|
diff --git a/app/views/shared/issuable/_assignees.html.haml b/app/views/shared/issuable/_assignees.html.haml
index fc86f855865..ef3d44a9241 100644
--- a/app/views/shared/issuable/_assignees.html.haml
+++ b/app/views/shared/issuable/_assignees.html.haml
@@ -3,7 +3,7 @@
- render_count = assignees_rendering_overflow ? max_render - 1 : max_render
- more_assignees_count = issue.assignees.size - render_count
-- issue.assignees.take(render_count).each do |assignee|
+- issue.assignees.take(render_count).each do |assignee| # rubocop: disable CodeReuse/ActiveRecord
= link_to_member(@project, assignee, name: false, title: "Assigned to :name")
- if more_assignees_count.positive?
diff --git a/app/views/shared/members/_access_request_buttons.html.haml b/app/views/shared/members/_access_request_buttons.html.haml
index 40224cec9e8..ebae58f28ba 100644
--- a/app/views/shared/members/_access_request_buttons.html.haml
+++ b/app/views/shared/members/_access_request_buttons.html.haml
@@ -1,13 +1,13 @@
- model_name = source.model_name.to_s.downcase
-- if can?(current_user, :"destroy_#{model_name}_member", source.members.find_by(user_id: current_user.id))
+- if can?(current_user, :"destroy_#{model_name}_member", source.members.find_by(user_id: current_user.id)) # rubocop: disable CodeReuse/ActiveRecord
.project-action-button.inline
- link_text = source.is_a?(Group) ? _('Leave group') : _('Leave project')
= link_to link_text, polymorphic_path([:leave, source, :members]),
method: :delete,
data: { confirm: leave_confirmation_message(source) },
class: 'btn'
-- elsif requester = source.requesters.find_by(user_id: current_user.id)
+- elsif requester = source.requesters.find_by(user_id: current_user.id) # rubocop: disable CodeReuse/ActiveRecord
.project-action-button.inline
= link_to _('Withdraw Access Request'), polymorphic_path([:leave, source, :members]),
method: :delete,
diff --git a/app/workers/admin_email_worker.rb b/app/workers/admin_email_worker.rb
index 06324575ffc..f69e74b2674 100644
--- a/app/workers/admin_email_worker.rb
+++ b/app/workers/admin_email_worker.rb
@@ -10,10 +10,12 @@ class AdminEmailWorker
private
+ # rubocop: disable CodeReuse/ActiveRecord
def send_repository_check_mail
repository_check_failed_count = Project.where(last_repository_check_failed: true).count
return if repository_check_failed_count.zero?
RepositoryCheckMailer.notify(repository_check_failed_count).deliver_now
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/archive_trace_worker.rb b/app/workers/archive_trace_worker.rb
index c6f89a17729..c1283e9b2fc 100644
--- a/app/workers/archive_trace_worker.rb
+++ b/app/workers/archive_trace_worker.rb
@@ -4,9 +4,11 @@ class ArchiveTraceWorker
include ApplicationWorker
include PipelineBackgroundQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(job_id)
Ci::Build.without_archived_trace.find_by(id: job_id).try do |job|
job.trace.archive!
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/authorized_projects_worker.rb b/app/workers/authorized_projects_worker.rb
index dd62bb0f33d..c9ddeb08613 100644
--- a/app/workers/authorized_projects_worker.rb
+++ b/app/workers/authorized_projects_worker.rb
@@ -12,9 +12,11 @@ class AuthorizedProjectsWorker
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(user_id)
user = User.find_by(id: user_id)
user&.refresh_authorized_projects
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/build_coverage_worker.rb b/app/workers/build_coverage_worker.rb
index 53d77dc4524..912c53e11f8 100644
--- a/app/workers/build_coverage_worker.rb
+++ b/app/workers/build_coverage_worker.rb
@@ -4,7 +4,9 @@ class BuildCoverageWorker
include ApplicationWorker
include PipelineQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id)&.update_coverage
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/build_finished_worker.rb b/app/workers/build_finished_worker.rb
index 9dc2c7f3601..51cbbe8882e 100644
--- a/app/workers/build_finished_worker.rb
+++ b/app/workers/build_finished_worker.rb
@@ -6,6 +6,7 @@ class BuildFinishedWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
# We execute that in sync as this access the files in order to access local file, and reduce IO
@@ -17,4 +18,5 @@ class BuildFinishedWorker
ArchiveTraceWorker.perform_async(build.id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/build_hooks_worker.rb b/app/workers/build_hooks_worker.rb
index f1f71dc589c..b0c3676714c 100644
--- a/app/workers/build_hooks_worker.rb
+++ b/app/workers/build_hooks_worker.rb
@@ -6,8 +6,10 @@ class BuildHooksWorker
queue_namespace :pipeline_hooks
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id)
.try(:execute_hooks)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/build_queue_worker.rb b/app/workers/build_queue_worker.rb
index 1b3f1fd3c2a..67d5b0f5f5b 100644
--- a/app/workers/build_queue_worker.rb
+++ b/app/workers/build_queue_worker.rb
@@ -6,9 +6,11 @@ class BuildQueueWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
Ci::UpdateBuildQueueService.new.execute(build)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/build_success_worker.rb b/app/workers/build_success_worker.rb
index e1c1cc24a94..c17608f7378 100644
--- a/app/workers/build_success_worker.rb
+++ b/app/workers/build_success_worker.rb
@@ -6,11 +6,13 @@ class BuildSuccessWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
create_deployment(build) if build.has_environment?
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/workers/build_trace_sections_worker.rb b/app/workers/build_trace_sections_worker.rb
index f4114b3353c..0641130fd64 100644
--- a/app/workers/build_trace_sections_worker.rb
+++ b/app/workers/build_trace_sections_worker.rb
@@ -4,7 +4,9 @@ class BuildTraceSectionsWorker
include ApplicationWorker
include PipelineQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id)&.parse_trace_sections!
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/ci/archive_traces_cron_worker.rb b/app/workers/ci/archive_traces_cron_worker.rb
index 7d4e9660a4e..7443aad1380 100644
--- a/app/workers/ci/archive_traces_cron_worker.rb
+++ b/app/workers/ci/archive_traces_cron_worker.rb
@@ -5,6 +5,7 @@ module Ci
include ApplicationWorker
include CronjobQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
# Archive stale live traces which still resides in redis or database
# This could happen when ArchiveTraceWorker sidekiq jobs were lost by receiving SIGKILL
@@ -19,6 +20,7 @@ module Ci
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/workers/ci/build_trace_chunk_flush_worker.rb b/app/workers/ci/build_trace_chunk_flush_worker.rb
index 9dbf2e5e1ac..23a11c28f9b 100644
--- a/app/workers/ci/build_trace_chunk_flush_worker.rb
+++ b/app/workers/ci/build_trace_chunk_flush_worker.rb
@@ -5,10 +5,12 @@ module Ci
include ApplicationWorker
include PipelineBackgroundQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_trace_chunk_id)
::Ci::BuildTraceChunk.find_by(id: build_trace_chunk_id).try do |build_trace_chunk|
build_trace_chunk.persist_data!
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb b/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
index 692ca6b7f42..1c6413674a0 100644
--- a/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
+++ b/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
@@ -8,6 +8,7 @@ module Gitlab
# project_id - The ID of the GitLab project to import the note into.
# hash - A Hash containing the details of the GitHub object to imoprt.
# notify_key - The Redis key to notify upon completion, if any.
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, hash, notify_key = nil)
project = Project.find_by(id: project_id)
@@ -24,6 +25,7 @@ module Gitlab
.perform_in(client.rate_limit_resets_in, project.id, hash, notify_key)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def try_import(*args)
import(*args)
diff --git a/app/workers/concerns/gitlab/github_import/stage_methods.rb b/app/workers/concerns/gitlab/github_import/stage_methods.rb
index 147c8c8d683..59e6bc2c97d 100644
--- a/app/workers/concerns/gitlab/github_import/stage_methods.rb
+++ b/app/workers/concerns/gitlab/github_import/stage_methods.rb
@@ -20,11 +20,13 @@ module Gitlab
self.class.perform_in(client.rate_limit_resets_in, project.id)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_project(id)
# If the project has been marked as failed we want to bail out
# automatically.
Project.import_started.find_by(id: id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/workers/concerns/new_issuable.rb b/app/workers/concerns/new_issuable.rb
index 7735dec5e6b..a89451a4475 100644
--- a/app/workers/concerns/new_issuable.rb
+++ b/app/workers/concerns/new_issuable.rb
@@ -10,17 +10,21 @@ module NewIssuable
user && issuable
end
+ # rubocop: disable CodeReuse/ActiveRecord
def set_user(user_id)
@user = User.find_by(id: user_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
log_error(User, user_id) unless @user # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def set_issuable(issuable_id)
@issuable = issuable_class.find_by(id: issuable_id) # rubocop:disable Gitlab/ModuleWithInstanceVariables
log_error(issuable_class, issuable_id) unless @issuable # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
+ # rubocop: enable CodeReuse/ActiveRecord
def log_error(record_class, record_id)
Rails.logger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job")
diff --git a/app/workers/create_gpg_signature_worker.rb b/app/workers/create_gpg_signature_worker.rb
index a1aeeb7c4fc..49c7a403838 100644
--- a/app/workers/create_gpg_signature_worker.rb
+++ b/app/workers/create_gpg_signature_worker.rb
@@ -3,6 +3,7 @@
class CreateGpgSignatureWorker
include ApplicationWorker
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(commit_shas, project_id)
# Older versions of GitPushService may push a single commit ID on the stack.
# We need this to be backwards compatible.
@@ -26,4 +27,5 @@ class CreateGpgSignatureWorker
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/delete_container_repository_worker.rb b/app/workers/delete_container_repository_worker.rb
index b703530d3a0..e8fe9d82797 100644
--- a/app/workers/delete_container_repository_worker.rb
+++ b/app/workers/delete_container_repository_worker.rb
@@ -8,6 +8,7 @@ class DeleteContainerRepositoryWorker
attr_reader :container_repository
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(current_user_id, container_repository_id)
current_user = User.find_by(id: current_user_id)
@container_repository = ContainerRepository.find_by(id: container_repository_id)
@@ -21,6 +22,7 @@ class DeleteContainerRepositoryWorker
Projects::ContainerRepository::DestroyService.new(project, current_user).execute(container_repository)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# For ExclusiveLeaseGuard concern
def lease_key
diff --git a/app/workers/delete_diff_files_worker.rb b/app/workers/delete_diff_files_worker.rb
index 0874a0b75e8..f518dfe871c 100644
--- a/app/workers/delete_diff_files_worker.rb
+++ b/app/workers/delete_diff_files_worker.rb
@@ -3,6 +3,7 @@
class DeleteDiffFilesWorker
include ApplicationWorker
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(merge_request_diff_id)
merge_request_diff = MergeRequestDiff.find(merge_request_diff_id)
@@ -16,4 +17,5 @@ class DeleteDiffFilesWorker
.delete_all
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/detect_repository_languages_worker.rb b/app/workers/detect_repository_languages_worker.rb
index 854b74b884a..64bc9776d48 100644
--- a/app/workers/detect_repository_languages_worker.rb
+++ b/app/workers/detect_repository_languages_worker.rb
@@ -11,6 +11,7 @@ class DetectRepositoryLanguagesWorker
attr_reader :project
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id)
@project = Project.find_by(id: project_id)
user = User.find_by(id: user_id)
@@ -20,6 +21,7 @@ class DetectRepositoryLanguagesWorker
::Projects::DetectRepositoryLanguagesService.new(project, user).execute
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/workers/expire_build_artifacts_worker.rb b/app/workers/expire_build_artifacts_worker.rb
index 5d3a9a39b93..dce812d1ae2 100644
--- a/app/workers/expire_build_artifacts_worker.rb
+++ b/app/workers/expire_build_artifacts_worker.rb
@@ -4,6 +4,7 @@ class ExpireBuildArtifactsWorker
include ApplicationWorker
include CronjobQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
Rails.logger.info 'Scheduling removal of build artifacts'
@@ -12,4 +13,5 @@ class ExpireBuildArtifactsWorker
ExpireBuildInstanceArtifactsWorker.bulk_perform_async(build_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/expire_build_instance_artifacts_worker.rb b/app/workers/expire_build_instance_artifacts_worker.rb
index 3b57ecb36e3..4fcd1e5bd24 100644
--- a/app/workers/expire_build_instance_artifacts_worker.rb
+++ b/app/workers/expire_build_instance_artifacts_worker.rb
@@ -3,6 +3,7 @@
class ExpireBuildInstanceArtifactsWorker
include ApplicationWorker
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
build = Ci::Build
.with_expired_artifacts
@@ -14,4 +15,5 @@ class ExpireBuildInstanceArtifactsWorker
Rails.logger.info "Removing artifacts for build #{build.id}..."
build.erase_artifacts!
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/expire_job_cache_worker.rb b/app/workers/expire_job_cache_worker.rb
index 14a57b90114..b09d0a5d121 100644
--- a/app/workers/expire_job_cache_worker.rb
+++ b/app/workers/expire_job_cache_worker.rb
@@ -6,6 +6,7 @@ class ExpireJobCacheWorker
queue_namespace :pipeline_cache
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(job_id)
job = CommitStatus.joins(:pipeline, :project).find_by(id: job_id)
return unless job
@@ -18,6 +19,7 @@ class ExpireJobCacheWorker
store.touch(project_job_path(project, job))
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb
index 992fc63c451..c96e8a0379b 100644
--- a/app/workers/expire_pipeline_cache_worker.rb
+++ b/app/workers/expire_pipeline_cache_worker.rb
@@ -6,6 +6,7 @@ class ExpirePipelineCacheWorker
queue_namespace :pipeline_cache
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
return unless pipeline
@@ -23,6 +24,7 @@ class ExpirePipelineCacheWorker
Gitlab::Cache::Ci::ProjectPipelineStatus.update_for_pipeline(pipeline)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/workers/gitlab/github_import/advance_stage_worker.rb b/app/workers/gitlab/github_import/advance_stage_worker.rb
index be0b6c180b0..cd2ceb8dcdf 100644
--- a/app/workers/gitlab/github_import/advance_stage_worker.rb
+++ b/app/workers/gitlab/github_import/advance_stage_worker.rb
@@ -63,12 +63,14 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_project(id)
# TODO: Only select the JID
# This is due to the fact that the JID could be present in either the project record or
# its associated import_state record
Project.import_started.find_by(id: id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/workers/gitlab/github_import/refresh_import_jid_worker.rb b/app/workers/gitlab/github_import/refresh_import_jid_worker.rb
index 68d2c5c4331..65473026b4c 100644
--- a/app/workers/gitlab/github_import/refresh_import_jid_worker.rb
+++ b/app/workers/gitlab/github_import/refresh_import_jid_worker.rb
@@ -30,12 +30,14 @@ module Gitlab
# stage, if it died there's nothing we can do anyway.
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_project(id)
# TODO: Only select the JID
# This is due to the fact that the JID could be present in either the project record or
# its associated import_state record
Project.import_started.find_by(id: id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/workers/invalid_gpg_signature_update_worker.rb b/app/workers/invalid_gpg_signature_update_worker.rb
index 4724ab7ad98..fc8a731b427 100644
--- a/app/workers/invalid_gpg_signature_update_worker.rb
+++ b/app/workers/invalid_gpg_signature_update_worker.rb
@@ -3,6 +3,7 @@
class InvalidGpgSignatureUpdateWorker
include ApplicationWorker
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(gpg_key_id)
gpg_key = GpgKey.find_by(id: gpg_key_id)
@@ -10,4 +11,5 @@ class InvalidGpgSignatureUpdateWorker
Gitlab::Gpg::InvalidGpgSignatureUpdater.new(gpg_key).run
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/issue_due_scheduler_worker.rb b/app/workers/issue_due_scheduler_worker.rb
index c04a2d75e0b..476cba47ad7 100644
--- a/app/workers/issue_due_scheduler_worker.rb
+++ b/app/workers/issue_due_scheduler_worker.rb
@@ -4,9 +4,11 @@ class IssueDueSchedulerWorker
include ApplicationWorker
include CronjobQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
project_ids = Issue.opened.due_tomorrow.group(:project_id).pluck(:project_id).map { |id| [id] }
MailScheduler::IssueDueWorker.bulk_perform_async(project_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/mail_scheduler/issue_due_worker.rb b/app/workers/mail_scheduler/issue_due_worker.rb
index 8794ad7a82c..1e1dde1e829 100644
--- a/app/workers/mail_scheduler/issue_due_worker.rb
+++ b/app/workers/mail_scheduler/issue_due_worker.rb
@@ -5,10 +5,12 @@ module MailScheduler
include ApplicationWorker
include MailSchedulerQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id)
Issue.opened.due_tomorrow.in_projects(project_id).preload(:project).find_each do |issue|
notification_service.issue_due(issue)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/workers/new_note_worker.rb b/app/workers/new_note_worker.rb
index 74f34dcf9aa..42f5b945a75 100644
--- a/app/workers/new_note_worker.rb
+++ b/app/workers/new_note_worker.rb
@@ -5,6 +5,7 @@ class NewNoteWorker
# Keep extra parameter to preserve backwards compatibility with
# old `NewNoteWorker` jobs (can remove later)
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(note_id, _params = {})
if note = Note.find_by(id: note_id)
NotificationService.new.new_note(note)
@@ -13,4 +14,5 @@ class NewNoteWorker
Rails.logger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job")
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/object_storage/migrate_uploads_worker.rb b/app/workers/object_storage/migrate_uploads_worker.rb
index 01d03ec7888..fe5d27b087d 100644
--- a/app/workers/object_storage/migrate_uploads_worker.rb
+++ b/app/workers/object_storage/migrate_uploads_worker.rb
@@ -57,11 +57,13 @@ module ObjectStorage
include Report
+ # rubocop: disable CodeReuse/ActiveRecord
def self.enqueue!(uploads, model_class, mounted_as, to_store)
sanity_check!(uploads, model_class, mounted_as)
perform_async(uploads.ids, model_class.to_s, mounted_as, to_store)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# We need to be sure all the uploads are for the same uploader and model type
# and that the mount point exists if provided.
@@ -78,6 +80,7 @@ module ObjectStorage
raise(SanityCheckError, "Mount point #{mounted_as} not found in #{model_class}.") unless model_has_mount
end
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(*args)
args_check!(args)
@@ -97,6 +100,7 @@ module ObjectStorage
# do not retry: the job is insane
Rails.logger.warn "#{self.class}: Sanity check error (#{e.message})"
end
+ # rubocop: enable CodeReuse/ActiveRecord
def sanity_check!(uploads)
self.class.sanity_check!(uploads, @model_class, @mounted_as)
diff --git a/app/workers/pages_domain_verification_worker.rb b/app/workers/pages_domain_verification_worker.rb
index 4610b688189..b3319ff5a13 100644
--- a/app/workers/pages_domain_verification_worker.rb
+++ b/app/workers/pages_domain_verification_worker.rb
@@ -3,6 +3,7 @@
class PagesDomainVerificationWorker
include ApplicationWorker
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(domain_id)
domain = PagesDomain.find_by(id: domain_id)
@@ -10,4 +11,5 @@ class PagesDomainVerificationWorker
VerifyPagesDomainService.new(domain).execute
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/pages_worker.rb b/app/workers/pages_worker.rb
index 13a6576a301..fa0dfa2ff4b 100644
--- a/app/workers/pages_worker.rb
+++ b/app/workers/pages_worker.rb
@@ -9,6 +9,7 @@ class PagesWorker
send(action, *arg) # rubocop:disable GitlabSecurity/PublicSend
end
+ # rubocop: disable CodeReuse/ActiveRecord
def deploy(build_id)
build = Ci::Build.find_by(id: build_id)
result = Projects::UpdatePagesService.new(build.project, build).execute
@@ -18,6 +19,7 @@ class PagesWorker
result
end
+ # rubocop: enable CodeReuse/ActiveRecord
def remove(namespace_path, project_path)
full_path = File.join(Settings.pages.path, namespace_path, project_path)
diff --git a/app/workers/pipeline_hooks_worker.rb b/app/workers/pipeline_hooks_worker.rb
index 58023e0af1b..eae1115e60c 100644
--- a/app/workers/pipeline_hooks_worker.rb
+++ b/app/workers/pipeline_hooks_worker.rb
@@ -6,8 +6,10 @@ class PipelineHooksWorker
queue_namespace :pipeline_hooks
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id)
.try(:execute_hooks)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/pipeline_metrics_worker.rb b/app/workers/pipeline_metrics_worker.rb
index a97019b100a..c2fbfd2b3a5 100644
--- a/app/workers/pipeline_metrics_worker.rb
+++ b/app/workers/pipeline_metrics_worker.rb
@@ -4,12 +4,14 @@ class PipelineMetricsWorker
include ApplicationWorker
include PipelineQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
update_metrics_for_active_pipeline(pipeline) if pipeline.active?
update_metrics_for_succeeded_pipeline(pipeline) if pipeline.success?
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -21,9 +23,11 @@ class PipelineMetricsWorker
metrics(pipeline).update_all(latest_build_started_at: pipeline.started_at, latest_build_finished_at: pipeline.finished_at, pipeline_id: pipeline.id)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def metrics(pipeline)
MergeRequest::Metrics.where(merge_request_id: merge_requests(pipeline))
end
+ # rubocop: enable CodeReuse/ActiveRecord
def merge_requests(pipeline)
pipeline.merge_requests.map(&:id)
diff --git a/app/workers/pipeline_notification_worker.rb b/app/workers/pipeline_notification_worker.rb
index 3a8846b3747..e4a18573d20 100644
--- a/app/workers/pipeline_notification_worker.rb
+++ b/app/workers/pipeline_notification_worker.rb
@@ -4,6 +4,7 @@ class PipelineNotificationWorker
include ApplicationWorker
include PipelineQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id, recipients = nil)
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
@@ -11,4 +12,5 @@ class PipelineNotificationWorker
NotificationService.new.pipeline_finished(pipeline, recipients)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/pipeline_process_worker.rb b/app/workers/pipeline_process_worker.rb
index 83744c5338a..f2aa17acb51 100644
--- a/app/workers/pipeline_process_worker.rb
+++ b/app/workers/pipeline_process_worker.rb
@@ -6,8 +6,10 @@ class PipelineProcessWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id)
.try(:process!)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/pipeline_schedule_worker.rb b/app/workers/pipeline_schedule_worker.rb
index a1815757735..85d1ffe0fa9 100644
--- a/app/workers/pipeline_schedule_worker.rb
+++ b/app/workers/pipeline_schedule_worker.rb
@@ -4,6 +4,7 @@ class PipelineScheduleWorker
include ApplicationWorker
include CronjobQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
Ci::PipelineSchedule.active.where("next_run_at < ?", Time.now)
.preload(:owner, :project).find_each do |schedule|
@@ -21,4 +22,5 @@ class PipelineScheduleWorker
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/pipeline_success_worker.rb b/app/workers/pipeline_success_worker.rb
index 68e9af6a619..4f349ed922c 100644
--- a/app/workers/pipeline_success_worker.rb
+++ b/app/workers/pipeline_success_worker.rb
@@ -6,6 +6,7 @@ class PipelineSuccessWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline|
MergeRequests::MergeWhenPipelineSucceedsService
@@ -13,4 +14,5 @@ class PipelineSuccessWorker
.trigger(pipeline)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/pipeline_update_worker.rb b/app/workers/pipeline_update_worker.rb
index c33468c1f14..13a748e1551 100644
--- a/app/workers/pipeline_update_worker.rb
+++ b/app/workers/pipeline_update_worker.rb
@@ -6,8 +6,10 @@ class PipelineUpdateWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
Ci::Pipeline.find_by(id: pipeline_id)
.try(:update_status)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb
index c9f6df9b56d..7b167c95c29 100644
--- a/app/workers/process_commit_worker.rb
+++ b/app/workers/process_commit_worker.rb
@@ -14,6 +14,7 @@ class ProcessCommitWorker
# commit_hash - Hash containing commit details to use for constructing a
# Commit object without having to use the Git repository.
# default - The data was pushed to the default branch.
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id, commit_hash, default = false)
project = Project.find_by(id: project_id)
@@ -30,6 +31,7 @@ class ProcessCommitWorker
process_commit_message(project, commit, user, author, default)
update_issue_metrics(commit, author)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def process_commit_message(project, commit, user, author, default = false)
# Ignore closing references from GitLab-generated commit messages.
@@ -50,6 +52,7 @@ class ProcessCommitWorker
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def update_issue_metrics(commit, author)
mentioned_issues = commit.all_references(author).issues
@@ -58,6 +61,7 @@ class ProcessCommitWorker
Issue::Metrics.where(issue_id: mentioned_issues.map(&:id), first_mentioned_in_commit_at: nil)
.update_all(first_mentioned_in_commit_at: commit.committed_date)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def build_commit(project, hash)
date_suffix = '_date'
diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb
index b0e1d8837d9..d27b5e62574 100644
--- a/app/workers/project_cache_worker.rb
+++ b/app/workers/project_cache_worker.rb
@@ -12,6 +12,7 @@ class ProjectCacheWorker
# CHANGELOG.
# statistics - An Array containing columns from ProjectStatistics to
# refresh, if empty all columns will be refreshed
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, files = [], statistics = [])
project = Project.find_by(id: project_id)
@@ -23,6 +24,7 @@ class ProjectCacheWorker
project.cleanup
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update_statistics(project, statistics = [])
return unless try_obtain_lease_for(project.id, :update_statistics)
diff --git a/app/workers/project_migrate_hashed_storage_worker.rb b/app/workers/project_migrate_hashed_storage_worker.rb
index ad0003e7bff..4c6339f7701 100644
--- a/app/workers/project_migrate_hashed_storage_worker.rb
+++ b/app/workers/project_migrate_hashed_storage_worker.rb
@@ -5,6 +5,7 @@ class ProjectMigrateHashedStorageWorker
LEASE_TIMEOUT = 30.seconds.to_i
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, old_disk_path = nil)
project = Project.find_by(id: project_id)
return if project.nil? || project.pending_delete?
@@ -19,6 +20,7 @@ class ProjectMigrateHashedStorageWorker
cancel_lease_for(project_id, uuid) if uuid
raise ex
end
+ # rubocop: enable CodeReuse/ActiveRecord
def lease_for(project_id)
Gitlab::ExclusiveLease.new(lease_key(project_id), timeout: LEASE_TIMEOUT)
diff --git a/app/workers/propagate_service_template_worker.rb b/app/workers/propagate_service_template_worker.rb
index c9da1cae255..3ccd7615697 100644
--- a/app/workers/propagate_service_template_worker.rb
+++ b/app/workers/propagate_service_template_worker.rb
@@ -6,11 +6,13 @@ class PropagateServiceTemplateWorker
LEASE_TIMEOUT = 4.hours.to_i
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(template_id)
return unless try_obtain_lease_for(template_id)
Projects::PropagateServiceTemplate.propagate(Service.find_by(id: template_id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb
index c1d05ebbcfd..d44ad0d8030 100644
--- a/app/workers/prune_old_events_worker.rb
+++ b/app/workers/prune_old_events_worker.rb
@@ -4,6 +4,7 @@ class PruneOldEventsWorker
include ApplicationWorker
include CronjobQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
# Contribution calendar shows maximum 12 months of events.
# Double nested query is used because MySQL doesn't allow DELETE subqueries
@@ -17,4 +18,5 @@ class PruneOldEventsWorker
.limit(10_000))
.delete_all
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/prune_web_hook_logs_worker.rb b/app/workers/prune_web_hook_logs_worker.rb
index 45c7d32f7eb..38054069f4e 100644
--- a/app/workers/prune_web_hook_logs_worker.rb
+++ b/app/workers/prune_web_hook_logs_worker.rb
@@ -9,6 +9,7 @@ class PruneWebHookLogsWorker
# The maximum number of rows to remove in a single job.
DELETE_LIMIT = 50_000
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
# MySQL doesn't allow "DELETE FROM ... WHERE id IN ( ... )" if the inner
# query refers to the same table. To work around this we wrap the IN body in
@@ -23,4 +24,5 @@ class PruneWebHookLogsWorker
)
.delete_all
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/reactive_caching_worker.rb b/app/workers/reactive_caching_worker.rb
index 9b331f15dc5..96ff8cd6222 100644
--- a/app/workers/reactive_caching_worker.rb
+++ b/app/workers/reactive_caching_worker.rb
@@ -3,6 +3,7 @@
class ReactiveCachingWorker
include ApplicationWorker
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(class_name, id, *args)
klass = begin
Kernel.const_get(class_name)
@@ -13,4 +14,5 @@ class ReactiveCachingWorker
klass.find_by(id: id).try(:exclusively_update_reactive_cache!, *args)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb
index 07559ea479b..c1bb1adc9cc 100644
--- a/app/workers/repository_check/batch_worker.rb
+++ b/app/workers/repository_check/batch_worker.rb
@@ -59,22 +59,28 @@ module RepositoryCheck
never_checked_project_ids(BATCH_SIZE) + old_checked_project_ids(BATCH_SIZE)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def never_checked_project_ids(batch_size)
projects_on_shard.where(last_repository_check_at: nil)
.where('created_at < ?', 24.hours.ago)
.limit(batch_size).pluck(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def old_checked_project_ids(batch_size)
projects_on_shard.where.not(last_repository_check_at: nil)
.where('last_repository_check_at < ?', 1.month.ago)
.reorder(last_repository_check_at: :asc)
.limit(batch_size).pluck(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def projects_on_shard
Project.where(repository_storage: shard_name)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def try_obtain_lease_for_project(id)
# Use a 24-hour timeout because on servers/projects where 'git fsck' is
diff --git a/app/workers/repository_check/clear_worker.rb b/app/workers/repository_check/clear_worker.rb
index 81e1a4b63bb..01964c69fb2 100644
--- a/app/workers/repository_check/clear_worker.rb
+++ b/app/workers/repository_check/clear_worker.rb
@@ -5,6 +5,7 @@ module RepositoryCheck
include ApplicationWorker
include RepositoryCheckQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
# Do small batched updates because these updates will be slow and locking
Project.select(:id).find_in_batches(batch_size: 100) do |batch|
@@ -14,5 +15,6 @@ module RepositoryCheck
)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/app/workers/repository_check/single_repository_worker.rb b/app/workers/repository_check/single_repository_worker.rb
index f44e5693b25..a8097af321f 100644
--- a/app/workers/repository_check/single_repository_worker.rb
+++ b/app/workers/repository_check/single_repository_worker.rb
@@ -48,9 +48,11 @@ module RepositoryCheck
false
end
+ # rubocop: disable CodeReuse/ActiveRecord
def has_changes?(project)
Project.with_push.exists?(project.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def has_wiki_changes?(project)
return false unless project.wiki_enabled?
diff --git a/app/workers/run_pipeline_schedule_worker.rb b/app/workers/run_pipeline_schedule_worker.rb
index 1f6cb18c812..f72331c003a 100644
--- a/app/workers/run_pipeline_schedule_worker.rb
+++ b/app/workers/run_pipeline_schedule_worker.rb
@@ -6,6 +6,7 @@ class RunPipelineScheduleWorker
queue_namespace :pipeline_creation
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(schedule_id, user_id)
schedule = Ci::PipelineSchedule.find_by(id: schedule_id)
user = User.find_by(id: user_id)
@@ -14,6 +15,7 @@ class RunPipelineScheduleWorker
run_pipeline_schedule(schedule, user)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def run_pipeline_schedule(schedule, user)
Ci::CreatePipelineService.new(schedule.project,
diff --git a/app/workers/stage_update_worker.rb b/app/workers/stage_update_worker.rb
index ec8c8e3689f..ea587789d03 100644
--- a/app/workers/stage_update_worker.rb
+++ b/app/workers/stage_update_worker.rb
@@ -6,9 +6,11 @@ class StageUpdateWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(stage_id)
Ci::Stage.find_by(id: stage_id).try do |stage|
stage.update_status
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index c78b7fac589..f6bca1176d1 100644
--- a/app/workers/stuck_ci_jobs_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -46,6 +46,7 @@ class StuckCiJobsWorker
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def search(status, timeout)
loop do
jobs = Ci::Build.where(status: status)
@@ -60,6 +61,7 @@ class StuckCiJobsWorker
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def drop_build(type, build, status, timeout)
Rails.logger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout})"
diff --git a/app/workers/stuck_import_jobs_worker.rb b/app/workers/stuck_import_jobs_worker.rb
index 79ce06dd66e..de92f3eca6a 100644
--- a/app/workers/stuck_import_jobs_worker.rb
+++ b/app/workers/stuck_import_jobs_worker.rb
@@ -23,6 +23,7 @@ class StuckImportJobsWorker
end.count
end
+ # rubocop: disable CodeReuse/ActiveRecord
def mark_projects_with_jid_as_failed!
# TODO: Rollback this change to use SQL through #pluck
jids_and_ids = enqueued_projects_with_jid.map { |project| [project.import_jid, project.id] }.to_h
@@ -43,18 +44,25 @@ class StuckImportJobsWorker
project.mark_import_as_failed(error_message)
end.count
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def enqueued_projects
Project.joins_import_state.where("(import_state.status = 'scheduled' OR import_state.status = 'started') OR (projects.import_status = 'scheduled' OR projects.import_status = 'started')")
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def enqueued_projects_with_jid
enqueued_projects.where.not("import_state.jid IS NULL AND projects.import_jid IS NULL")
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def enqueued_projects_without_jid
enqueued_projects.where("import_state.jid IS NULL AND projects.import_jid IS NULL")
end
+ # rubocop: enable CodeReuse/ActiveRecord
def error_message
"Import timed out. Import took longer than #{IMPORT_JOBS_EXPIRATION} seconds"
diff --git a/app/workers/stuck_merge_jobs_worker.rb b/app/workers/stuck_merge_jobs_worker.rb
index b0a62f76e94..98c81956cba 100644
--- a/app/workers/stuck_merge_jobs_worker.rb
+++ b/app/workers/stuck_merge_jobs_worker.rb
@@ -4,6 +4,7 @@ class StuckMergeJobsWorker
include ApplicationWorker
include CronjobQueue
+ # rubocop: disable CodeReuse/ActiveRecord
def perform
stuck_merge_requests.find_in_batches(batch_size: 100) do |group|
jids = group.map(&:merge_jid)
@@ -18,9 +19,11 @@ class StuckMergeJobsWorker
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def apply_current_state!(completed_jids, completed_ids)
merge_requests = MergeRequest.where(id: completed_ids)
@@ -34,8 +37,11 @@ class StuckMergeJobsWorker
Rails.logger.info("Updated state of locked merge jobs. JIDs: #{completed_jids.join(', ')}")
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def stuck_merge_requests
MergeRequest.select('id, merge_jid').with_state(:locked).where.not(merge_jid: nil).reorder(nil)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/update_head_pipeline_for_merge_request_worker.rb b/app/workers/update_head_pipeline_for_merge_request_worker.rb
index 0487a393566..9ce51662969 100644
--- a/app/workers/update_head_pipeline_for_merge_request_worker.rb
+++ b/app/workers/update_head_pipeline_for_merge_request_worker.rb
@@ -6,6 +6,7 @@ class UpdateHeadPipelineForMergeRequestWorker
queue_namespace :pipeline_processing
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(merge_request_id)
merge_request = MergeRequest.find(merge_request_id)
pipeline = Ci::Pipeline.where(project: merge_request.source_project, ref: merge_request.source_branch).last
@@ -20,6 +21,7 @@ class UpdateHeadPipelineForMergeRequestWorker
merge_request.update_attribute(:head_pipeline_id, pipeline.id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def log_error_message_for(merge_request)
Rails.logger.error(
diff --git a/app/workers/update_merge_requests_worker.rb b/app/workers/update_merge_requests_worker.rb
index 742841219b3..c7213df652a 100644
--- a/app/workers/update_merge_requests_worker.rb
+++ b/app/workers/update_merge_requests_worker.rb
@@ -5,6 +5,7 @@ class UpdateMergeRequestsWorker
LOG_TIME_THRESHOLD = 90 # seconds
+ # rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, user_id, oldrev, newrev, ref)
project = Project.find_by(id: project_id)
return unless project
@@ -28,4 +29,5 @@ class UpdateMergeRequestsWorker
Rails.logger.info("UpdateMergeRequestsWorker#perform #{args_log}") if time.real > LOG_TIME_THRESHOLD
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb
index ae13c248171..18063fb20a2 100644
--- a/lib/api/access_requests.rb
+++ b/lib/api/access_requests.rb
@@ -18,6 +18,7 @@ module API
params do
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/access_requests" do
source = find_source(source_type, params[:id])
@@ -26,6 +27,7 @@ module API
present access_requesters, with: Entities::AccessRequester
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Requests access for the authenticated user to a #{source_type}." do
detail 'This feature was introduced in GitLab 8.11.'
@@ -50,6 +52,7 @@ module API
requires :user_id, type: Integer, desc: 'The user ID of the access requester'
optional :access_level, type: Integer, desc: 'A valid access level (defaults: `30`, developer access level)'
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/access_requests/:user_id/approve' do
source = find_source(source_type, params[:id])
@@ -61,6 +64,7 @@ module API
status :created
present member, with: Entities::Member
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Denies an access request for the given user.' do
detail 'This feature was introduced in GitLab 8.11.'
@@ -68,6 +72,7 @@ module API
params do
requires :user_id, type: Integer, desc: 'The user ID of the access requester'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id/access_requests/:user_id" do
source = find_source(source_type, params[:id])
member = source.requesters.find_by!(user_id: params[:user_id])
@@ -76,6 +81,7 @@ module API
::Members::DestroyService.new(current_user).execute(member)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/award_emoji.rb b/lib/api/award_emoji.rb
index bde4b3ff4f6..e334af22183 100644
--- a/lib/api/award_emoji.rb
+++ b/lib/api/award_emoji.rb
@@ -103,6 +103,7 @@ module API
awardable.user_can_award?(current_user)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def awardable
@awardable ||=
begin
@@ -119,6 +120,7 @@ module API
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def read_ability(awardable)
case awardable
diff --git a/lib/api/boards_responses.rb b/lib/api/boards_responses.rb
index 7e873012efe..3322b37c6ff 100644
--- a/lib/api/boards_responses.rb
+++ b/lib/api/boards_responses.rb
@@ -49,11 +49,13 @@ module API
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def authorize_list_type_resource!
unless available_labels_for(board_parent).exists?(params[:label_id])
render_api_error!({ error: 'Label not found!' }, 400)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
params :list_creation_params do
requires :label_id, type: Integer, desc: 'The ID of an existing label'
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index 6c1d445e53d..7ab9f3bb4f0 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -73,6 +73,7 @@ module API
optional :developers_can_push, type: Boolean, desc: 'Flag if developers can push to that branch'
optional :developers_can_merge, type: Boolean, desc: 'Flag if developers can merge to that branch'
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/repository/branches/:branch/protect', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
authorize_admin_project
@@ -100,6 +101,7 @@ module API
render_api_error!(protected_branch.errors.full_messages, 422)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Note: This API will be deprecated in favor of the protected branches API.
desc 'Unprotect a single branch' do
@@ -108,6 +110,7 @@ module API
params do
requires :branch, type: String, desc: 'The name of the branch'
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/repository/branches/:branch/unprotect', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
authorize_admin_project
@@ -117,6 +120,7 @@ module API
present branch, with: Entities::Branch, current_user: current_user, project: user_project
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Create branch' do
success Entities::Branch
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb
index 829eef18795..8e6f706afd4 100644
--- a/lib/api/commit_statuses.rb
+++ b/lib/api/commit_statuses.rb
@@ -21,6 +21,7 @@ module API
optional :all, type: String, desc: 'Show all statuses, default: false'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/repository/commits/:sha/statuses' do
authorize!(:read_commit_status, user_project)
@@ -34,6 +35,7 @@ module API
statuses = statuses.where(name: params[:name]) if params[:name].present?
present paginate(statuses), with: Entities::CommitStatus
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Post status to a commit' do
success Entities::CommitStatus
@@ -49,6 +51,7 @@ module API
optional :context, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"'
optional :coverage, type: Float, desc: 'The total code coverage'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/statuses/:sha' do
authorize! :create_commit_status, user_project
@@ -118,6 +121,7 @@ module API
render_api_error!(e.message, 400)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index 3e8de3c8dae..5a134ed78fd 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -136,6 +136,7 @@ module API
use :pagination
requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/repository/commits/:sha/comments', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
@@ -144,6 +145,7 @@ module API
present paginate(notes), with: Entities::CommitNote
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Cherry pick commit into a branch' do
detail 'This feature was introduced in GitLab 8.15'
diff --git a/lib/api/custom_attributes_endpoints.rb b/lib/api/custom_attributes_endpoints.rb
index 5000aa0d9ac..b5864665cc3 100644
--- a/lib/api/custom_attributes_endpoints.rb
+++ b/lib/api/custom_attributes_endpoints.rb
@@ -30,6 +30,7 @@ module API
params do
use :custom_attributes_key
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/custom_attributes/:key' do
resource = public_send(attributable_finder, params[:id]) # rubocop:disable GitlabSecurity/PublicSend
authorize! :read_custom_attribute
@@ -38,12 +39,14 @@ module API
present custom_attribute, with: Entities::CustomAttribute
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Set a custom attribute on a #{attributable_name}"
params do
use :custom_attributes_key
requires :value, type: String, desc: 'The value of the custom attribute'
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/custom_attributes/:key' do
resource = public_send(attributable_finder, params[:id]) # rubocop:disable GitlabSecurity/PublicSend
authorize! :update_custom_attribute
@@ -59,11 +62,13 @@ module API
render_validation_error!(custom_attribute)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Delete a custom attribute on a #{attributable_name}"
params do
use :custom_attributes_key
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/custom_attributes/:key' do
resource = public_send(attributable_finder, params[:id]) # rubocop:disable GitlabSecurity/PublicSend
authorize! :update_custom_attribute
@@ -72,6 +77,7 @@ module API
status 204
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb
index 6769855b899..501e9f64db0 100644
--- a/lib/api/deploy_keys.rb
+++ b/lib/api/deploy_keys.rb
@@ -9,9 +9,11 @@ module API
project.deploy_keys_projects.create(attrs)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by_deploy_key(project, key_id)
project.deploy_keys_projects.find_by!(deploy_key: key_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
desc 'Return all deploy keys'
@@ -36,11 +38,13 @@ module API
params do
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/deploy_keys" do
keys = user_project.deploy_keys_projects.preload(:deploy_key)
present paginate(keys), with: Entities::DeployKeysProject
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get single deploy key' do
success Entities::DeployKeysProject
@@ -62,6 +66,7 @@ module API
requires :title, type: String, desc: 'The name of the deploy key'
optional :can_push, type: Boolean, desc: "Can deploy key push to the project's repository"
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ":id/deploy_keys" do
params[:key].strip!
@@ -94,6 +99,7 @@ module API
render_validation_error!(deploy_key_project)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Update an existing deploy key for a project' do
success Entities::SSHKey
@@ -147,12 +153,14 @@ module API
params do
requires :key_id, type: Integer, desc: 'The ID of the deploy key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id/deploy_keys/:key_id" do
deploy_key_project = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id])
not_found!('Deploy Key') unless deploy_key_project
destroy_conditionally!(deploy_key_project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/deployments.rb b/lib/api/deployments.rb
index 184fae0eb76..b7892599295 100644
--- a/lib/api/deployments.rb
+++ b/lib/api/deployments.rb
@@ -18,11 +18,13 @@ module API
optional :order_by, type: String, values: %w[id iid created_at ref], default: 'id', desc: 'Return deployments ordered by `id` or `iid` or `created_at` or `ref`'
optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/deployments' do
authorize! :read_deployment, user_project
present paginate(user_project.deployments.order(params[:order_by] => params[:sort])), with: Entities::Deployment
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Gets a specific deployment' do
detail 'This feature was introduced in GitLab 8.11.'
diff --git a/lib/api/discussions.rb b/lib/api/discussions.rb
index 13c34e3473a..88668992215 100644
--- a/lib/api/discussions.rb
+++ b/lib/api/discussions.rb
@@ -23,6 +23,7 @@ module API
requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/#{noteables_path}/:noteable_id/discussions" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -36,6 +37,7 @@ module API
present paginate(discussions), with: Entities::Discussion
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Get a single #{noteable_type.to_s.downcase} discussion" do
success Entities::Discussion
@@ -219,6 +221,7 @@ module API
end
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def readable_discussion_notes(noteable, discussion_id)
notes = noteable.notes
.where(discussion_id: discussion_id)
@@ -228,6 +231,7 @@ module API
notes.reject { |n| n.cross_reference_not_visible_for?(current_user) }
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index f0eafbaeb94..0fec3dc3dc4 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -168,6 +168,7 @@ module API
expose :namespace, using: 'API::Entities::NamespaceBasic'
expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes
+ # rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
# Preloading tags, should be done with using only `:tags`,
# as `:tags` are defined as: `has_many :tags, through: :taggings`
@@ -177,6 +178,7 @@ module API
.preload(:import_state, :tags)
.preload(namespace: [:route, :owner])
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
class Project < BasicProjectDetails
@@ -247,6 +249,7 @@ module API
expose :statistics, using: 'API::Entities::ProjectStatistics', if: :statistics
+ # rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
# Preloading tags, should be done with using only `:tags`,
# as `:tags` are defined as: `has_many :tags, through: :taggings`
@@ -258,6 +261,7 @@ module API
forked_project_link: :forked_from_project,
forked_from_project: [:route, :forks, :tags, namespace: :route])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def self.forks_counting_projects(projects_relation)
projects_relation + projects_relation.map(&:forked_from_project).compact
@@ -558,10 +562,12 @@ module API
expose :total_time_spent, as: :human_total_time_spent
end
+ # rubocop: disable CodeReuse/ActiveRecord
def total_time_spent
# Avoids an N+1 query since timelogs are preloaded
object.timelogs.map(&:time_spent).sum
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
class ExternalIssue < Grape::Entity
@@ -936,6 +942,7 @@ module API
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
relation = super(projects_relation, options)
@@ -960,6 +967,7 @@ module API
relation
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
class LabelBasic < Grape::Entity
@@ -1066,9 +1074,11 @@ module API
options[:project].repository.commit(repo_tag.dereferenced_target)
end
+ # rubocop: disable CodeReuse/ActiveRecord
expose :release, using: Entities::Release do |repo_tag, options|
options[:project].releases.find_by(tag: repo_tag.name)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
class Runner < Grape::Entity
@@ -1091,6 +1101,7 @@ module API
expose :version, :revision, :platform, :architecture
expose :contacted_at
expose :token, if: lambda { |runner, options| options[:current_user].admin? || !runner.instance_type? }
+ # rubocop: disable CodeReuse/ActiveRecord
expose :projects, with: Entities::BasicProjectDetails do |runner, options|
if options[:current_user].admin?
runner.projects
@@ -1098,6 +1109,8 @@ module API
options[:current_user].authorized_projects.where(id: runner.projects)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
expose :groups, with: Entities::BasicGroupDetails do |runner, options|
if options[:current_user].admin?
runner.groups
@@ -1105,6 +1118,7 @@ module API
options[:current_user].authorized_groups.where(id: runner.groups)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
class RunnerRegistrationDetails < Grape::Entity
diff --git a/lib/api/events.rb b/lib/api/events.rb
index a415508a632..dfe0e81af26 100644
--- a/lib/api/events.rb
+++ b/lib/api/events.rb
@@ -16,12 +16,14 @@ module API
desc: 'Return events sorted in ascending and descending order'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def present_events(events)
events = events.reorder(created_at: params[:sort])
.with_associations
present paginate(events), with: Entities::Event
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
resource :events do
@@ -36,6 +38,7 @@ module API
use :event_filter_params
use :sort_params
end
+ # rubocop: disable CodeReuse/ActiveRecord
get do
authenticate!
@@ -43,6 +46,7 @@ module API
present_events(events)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
params do
@@ -60,6 +64,7 @@ module API
use :event_filter_params
use :sort_params
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/events' do
user = find_user(params[:id])
not_found!('User') unless user
@@ -68,6 +73,7 @@ module API
present_events(events)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
params do
@@ -82,11 +88,13 @@ module API
use :event_filter_params
use :sort_params
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/events" do
events = EventsFinder.new(params.merge(source: user_project, current_user: current_user)).execute.preload(:author, :target)
present_events(events)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/features.rb b/lib/api/features.rb
index 11d848584d9..79be8c1903e 100644
--- a/lib/api/features.rb
+++ b/lib/api/features.rb
@@ -14,6 +14,7 @@ module API
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def gate_targets(params)
targets = []
targets << Feature.group(params[:feature_group]) if params[:feature_group]
@@ -21,6 +22,7 @@ module API
targets
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
resource :features do
diff --git a/lib/api/group_variables.rb b/lib/api/group_variables.rb
index 55d5c7f1606..b6610dd04b3 100644
--- a/lib/api/group_variables.rb
+++ b/lib/api/group_variables.rb
@@ -27,6 +27,7 @@ module API
params do
requires :key, type: String, desc: 'The key of the variable'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/variables/:key' do
key = params[:key]
variable = user_group.variables.find_by(key: key)
@@ -35,6 +36,7 @@ module API
present variable, with: Entities::Variable
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Create a new variable in a group' do
success Entities::Variable
@@ -64,6 +66,7 @@ module API
optional :value, type: String, desc: 'The value of the variable'
optional :protected, type: String, desc: 'Whether the variable is protected'
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/variables/:key' do
variable = user_group.variables.find_by(key: params[:key])
@@ -77,6 +80,7 @@ module API
render_validation_error!(variable)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an existing variable from a group' do
success Entities::Variable
@@ -84,12 +88,14 @@ module API
params do
requires :key, type: String, desc: 'The key of the variable'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/variables/:key' do
variable = user_group.variables.find_by(key: params[:key])
not_found!('GroupVariable') unless variable
destroy_conditionally!(variable)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index b4f441f6a4f..018ca72c32a 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -38,6 +38,7 @@ module API
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_groups(params, parent_id = nil)
find_params = params.slice(:all_available, :custom_attributes, :owned, :min_access_level)
find_params[:parent] = find_group!(parent_id) if parent_id
@@ -53,6 +54,7 @@ module API
groups
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_group_projects(params)
group = find_group!(params[:id])
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 5505d7a7b08..458cfc9d9a4 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -94,6 +94,7 @@ module API
LabelsFinder.new(current_user, search_params).execute
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_user(id)
if id =~ /^\d+$/
User.find_by(id: id)
@@ -101,7 +102,9 @@ module API
User.find_by(username: id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def find_project(id)
if id.is_a?(Integer) || id =~ /^\d+$/
Project.find_by(id: id)
@@ -109,6 +112,7 @@ module API
Project.find_by_full_path(id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_project!(id)
project = find_project(id)
@@ -120,6 +124,7 @@ module API
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_group(id)
if id.to_s =~ /^\d+$/
Group.find_by(id: id)
@@ -127,6 +132,7 @@ module API
Group.find_by_full_path(id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_group!(id)
group = find_group(id)
@@ -138,6 +144,7 @@ module API
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_namespace(id)
if id.to_s =~ /^\d+$/
Namespace.find_by(id: id)
@@ -145,6 +152,7 @@ module API
Namespace.find_by_full_path(id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_namespace!(id)
namespace = find_namespace(id)
@@ -169,13 +177,17 @@ module API
label || not_found!('Label')
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_project_issue(iid)
IssuesFinder.new(current_user, project_id: user_project.id).find_by!(iid: iid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def find_project_merge_request(iid)
MergeRequestsFinder.new(current_user, project_id: user_project.id).find_by!(iid: iid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_project_commit(id)
user_project.commit_by(oid: id)
@@ -186,11 +198,13 @@ module API
SnippetsFinder.new(current_user, finder_params).find(id)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_merge_request_with_access(iid, access_level = :read_merge_request)
merge_request = user_project.merge_requests.find_by!(iid: iid)
authorize! access_level, merge_request
merge_request
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_build!(id)
user_project.builds.find(id.to_i)
@@ -282,9 +296,11 @@ module API
Gitlab.rails5? ? permitted_attrs.to_h : permitted_attrs
end
+ # rubocop: disable CodeReuse/ActiveRecord
def filter_by_iid(items, iid)
items.where(iid: iid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def filter_by_search(items, text)
items.search(text)
@@ -381,9 +397,11 @@ module API
# project helpers
+ # rubocop: disable CodeReuse/ActiveRecord
def reorder_projects(projects)
projects.reorder(params[:order_by] => params[:sort])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def project_finder_params
finder_params = {}
diff --git a/lib/api/helpers/custom_attributes.rb b/lib/api/helpers/custom_attributes.rb
index 10d652e33f5..3bbe827967e 100644
--- a/lib/api/helpers/custom_attributes.rb
+++ b/lib/api/helpers/custom_attributes.rb
@@ -12,6 +12,7 @@ module API
desc: 'Filter with custom attributes'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def with_custom_attributes(collection_or_resource, options = {})
options = options.merge(
with_custom_attributes: params[:with_custom_attributes] &&
@@ -24,6 +25,7 @@ module API
[collection_or_resource, options]
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/helpers/members_helpers.rb b/lib/api/helpers/members_helpers.rb
index fed8846e505..518aaa62aef 100644
--- a/lib/api/helpers/members_helpers.rb
+++ b/lib/api/helpers/members_helpers.rb
@@ -17,6 +17,7 @@ module API
.non_request
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_all_members_for_project(project)
shared_group_ids = project.project_group_links.pluck(:group_id)
project_group_ids = project.group&.self_and_ancestors&.pluck(:id)
@@ -28,13 +29,16 @@ module API
.where(project_authorizations: { project_id: project.id })
.where(source_id: source_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def find_all_members_for_group(group)
source_ids = group.self_and_ancestors.pluck(:id)
Member.includes(:user)
.where(source_id: source_ids)
.where(source_type: 'Namespace')
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/helpers/pagination.rb b/lib/api/helpers/pagination.rb
index 3308212216e..50bcd4e0437 100644
--- a/lib/api/helpers/pagination.rb
+++ b/lib/api/helpers/pagination.rb
@@ -91,6 +91,7 @@ module API
@request_context = request_context
end
+ # rubocop: disable CodeReuse/ActiveRecord
def paginate(relation)
pagination = KeysetPaginationInfo.new(relation, request_context)
@@ -112,6 +113,7 @@ module API
paged_relation
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -183,6 +185,7 @@ module API
private
+ # rubocop: disable CodeReuse/ActiveRecord
def add_default_order(relation)
if relation.is_a?(ActiveRecord::Relation) && relation.order_values.empty?
relation = relation.order(:id)
@@ -190,6 +193,7 @@ module API
relation
end
+ # rubocop: enable CodeReuse/ActiveRecord
def add_pagination_headers(paginated_data)
header 'X-Per-Page', paginated_data.limit_value.to_s
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index e3e8cb71c09..71b87f60bf6 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -26,6 +26,7 @@ module API
# project - project full_path (not path on disk)
# action - git action (git-upload-pack or git-receive-pack)
# changes - changes as "oldrev newrev ref", see Gitlab::ChangesList
+ # rubocop: disable CodeReuse/ActiveRecord
post "/allowed" do
# Stores some Git-specific env thread-safely
env = parse_env
@@ -96,7 +97,9 @@ module API
response_with_status(code: 500, success: false, message: UNKNOWN_CHECK_RESULT_ERROR)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
post "/lfs_authenticate" do
status 200
@@ -118,6 +121,7 @@ module API
repository_http_path: project.http_url_to_repo
}
end
+ # rubocop: enable CodeReuse/ActiveRecord
get "/merge_request_urls" do
merge_request_urls
@@ -126,6 +130,7 @@ module API
#
# Get a ssh key using the fingerprint
#
+ # rubocop: disable CodeReuse/ActiveRecord
get "/authorized_keys" do
fingerprint = params.fetch(:fingerprint) do
Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint
@@ -134,10 +139,12 @@ module API
not_found!("Key") if key.nil?
present key, with: Entities::SSHKey
end
+ # rubocop: enable CodeReuse/ActiveRecord
#
# Discover user by ssh key, user id or username
#
+ # rubocop: disable CodeReuse/ActiveRecord
get "/discover" do
if params[:key_id]
key = Key.find(params[:key_id])
@@ -150,6 +157,7 @@ module API
present user, with: Entities::UserSafe
end
+ # rubocop: enable CodeReuse/ActiveRecord
get "/check" do
{
@@ -176,6 +184,7 @@ module API
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
post '/two_factor_recovery_codes' do
status 200
@@ -217,6 +226,7 @@ module API
{ success: true, recovery_codes: codes }
end
+ # rubocop: enable CodeReuse/ActiveRecord
post '/pre_receive' do
status 200
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index cedfd2fbaa0..bcb03a0b540 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -7,6 +7,7 @@ module API
helpers ::Gitlab::IssuableMetadata
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def find_issues(args = {})
args = declared_params.merge(args)
@@ -20,6 +21,7 @@ module API
issues.reorder(args[:order_by] => args[:sort])
end
+ # rubocop: enable CodeReuse/ActiveRecord
params :issues_params do
optional :labels, type: String, desc: 'Comma-separated list of label names'
@@ -207,6 +209,7 @@ module API
at_least_one_of :title, :description, :assignee_ids, :assignee_id, :milestone_id, :discussion_locked,
:labels, :created_at, :due_date, :confidential, :state_event
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/issues/:issue_iid' do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42322')
@@ -234,6 +237,7 @@ module API
render_validation_error!(issue)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Move an existing issue' do
success Entities::Issue
@@ -242,6 +246,7 @@ module API
requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
requires :to_project_id, type: Integer, desc: 'The ID of the new project'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/issues/:issue_iid/move' do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42323')
@@ -258,11 +263,13 @@ module API
render_api_error!(error.message, 400)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete a project issue'
params do
requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id/issues/:issue_iid" do
issue = user_project.issues.find_by(iid: params[:issue_iid])
not_found!('Issue') unless issue
@@ -273,6 +280,7 @@ module API
Issuable::DestroyService.new(user_project, current_user).execute(issue)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'List merge requests closing issue' do
success Entities::MergeRequestBasic
@@ -280,6 +288,7 @@ module API
params do
requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/issues/:issue_iid/closed_by' do
issue = find_project_issue(params[:issue_iid])
@@ -288,6 +297,7 @@ module API
present paginate(merge_requests), with: Entities::MergeRequestBasic, current_user: current_user, project: user_project
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'List participants for an issue' do
success Entities::UserBasic
diff --git a/lib/api/job_artifacts.rb b/lib/api/job_artifacts.rb
index 32379d7c8ab..ab4203c4e25 100644
--- a/lib/api/job_artifacts.rb
+++ b/lib/api/job_artifacts.rb
@@ -21,6 +21,7 @@ module API
requires :job, type: String, desc: 'The name for the job'
end
route_setting :authentication, job_token_allowed: true
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/jobs/artifacts/:ref_name/download',
requirements: { ref_name: /.+/ } do
authorize_download_artifacts!
@@ -30,6 +31,7 @@ module API
present_carrierwave_file!(latest_build.artifacts_file)
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Download the artifacts archive from a job' do
detail 'This feature was introduced in GitLab 8.5'
diff --git a/lib/api/jobs.rb b/lib/api/jobs.rb
index fc8c52085ab..27ffd42834c 100644
--- a/lib/api/jobs.rb
+++ b/lib/api/jobs.rb
@@ -34,6 +34,7 @@ module API
use :optional_scope
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/jobs' do
builds = user_project.builds.order('id DESC')
builds = filter_builds(builds, params[:scope])
@@ -41,6 +42,7 @@ module API
builds = builds.preload(:user, :job_artifacts_archive, :job_artifacts, :runner, pipeline: :project)
present paginate(builds), with: Entities::Job
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get pipeline jobs' do
success Entities::Job
@@ -50,6 +52,7 @@ module API
use :optional_scope
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/pipelines/:pipeline_id/jobs' do
pipeline = user_project.pipelines.find(params[:pipeline_id])
builds = pipeline.builds
@@ -58,6 +61,7 @@ module API
present paginate(builds), with: Entities::Job
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a specific job of a project' do
success Entities::Job
@@ -168,6 +172,7 @@ module API
end
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def filter_builds(builds, scope)
return builds if scope.nil? || scope.empty?
@@ -178,6 +183,7 @@ module API
builds.where(status: available_statuses && scope)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/labels.rb b/lib/api/labels.rb
index 81eaf56e48e..98c9818db39 100644
--- a/lib/api/labels.rb
+++ b/lib/api/labels.rb
@@ -27,6 +27,7 @@ module API
optional :description, type: String, desc: 'The description of label to be created'
optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/labels' do
authorize! :admin_label, user_project
@@ -43,6 +44,7 @@ module API
render_validation_error!(label)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an existing label' do
success Entities::Label
@@ -50,6 +52,7 @@ module API
params do
requires :name, type: String, desc: 'The name of the label to be deleted'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/labels' do
authorize! :admin_label, user_project
@@ -58,6 +61,7 @@ module API
destroy_conditionally!(label)
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Update an existing label. At least one optional parameter is required.' do
success Entities::Label
@@ -70,6 +74,7 @@ module API
optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true
at_least_one_of :new_name, :color, :description, :priority
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/labels' do
authorize! :admin_label, user_project
@@ -95,6 +100,7 @@ module API
present label, with: Entities::Label, current_user: current_user, project: user_project
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/members.rb b/lib/api/members.rb
index d23dd834c69..4d8e23dee91 100644
--- a/lib/api/members.rb
+++ b/lib/api/members.rb
@@ -18,6 +18,7 @@ module API
optional :query, type: String, desc: 'A query string to search for members'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/members" do
source = find_source(source_type, params[:id])
@@ -27,6 +28,7 @@ module API
present members, with: Entities::Member
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Gets a list of group or project members viewable by the authenticated user, including those who gained membership through ancestor group.' do
success Entities::Member
@@ -35,6 +37,7 @@ module API
optional :query, type: String, desc: 'A query string to search for members'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/members/all" do
source = find_source(source_type, params[:id])
@@ -44,6 +47,7 @@ module API
present members, with: Entities::Member
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Gets a member of a group or project.' do
success Entities::Member
@@ -51,6 +55,7 @@ module API
params do
requires :user_id, type: Integer, desc: 'The user ID of the member'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/members/:user_id" do
source = find_source(source_type, params[:id])
@@ -59,6 +64,7 @@ module API
present member, with: Entities::Member
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Adds a member to a group or project.' do
success Entities::Member
@@ -68,6 +74,7 @@ module API
requires :access_level, type: Integer, desc: 'A valid access level (defaults: `30`, developer access level)'
optional :expires_at, type: DateTime, desc: 'Date string in the format YEAR-MONTH-DAY'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ":id/members" do
source = find_source(source_type, params[:id])
authorize_admin_source!(source_type, source)
@@ -88,6 +95,7 @@ module API
render_validation_error!(member)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Updates a member of a group or project.' do
success Entities::Member
@@ -97,6 +105,7 @@ module API
requires :access_level, type: Integer, desc: 'A valid access level'
optional :expires_at, type: DateTime, desc: 'Date string in the format YEAR-MONTH-DAY'
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ":id/members/:user_id" do
source = find_source(source_type, params.delete(:id))
authorize_admin_source!(source_type, source)
@@ -113,11 +122,13 @@ module API
render_validation_error!(updated_member)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Removes a user from a group or project.'
params do
requires :user_id, type: Integer, desc: 'The user ID of the member'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id/members/:user_id" do
source = find_source(source_type, params[:id])
member = source.members.find_by!(user_id: params[:user_id])
@@ -126,6 +137,7 @@ module API
::Members::DestroyService.new(current_user).execute(member)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 55f54fe3c43..cad38271cbb 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -28,6 +28,7 @@ module API
end
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def find_merge_requests(args = {})
args = declared_params.merge(args)
@@ -45,6 +46,7 @@ module API
merge_requests
.preload(:notes, :author, :assignee, :milestone, :latest_merge_request_diff, :labels, :timelogs)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def merge_request_pipelines_with_access
authorize! :read_pipeline, user_project
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index 39923e6d5b5..dc9373bb3c2 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -28,6 +28,7 @@ module API
desc: 'Return notes sorted in `asc` or `desc` order.'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/#{noteables_str}/:noteable_id/notes" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -45,6 +46,7 @@ module API
.reject { |n| n.cross_reference_not_visible_for?(current_user) }
present notes, with: Entities::Note
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Get a single #{noteable_type.to_s.downcase} note" do
success Entities::Note
diff --git a/lib/api/pages_domains.rb b/lib/api/pages_domains.rb
index ba33993d852..8730c91b426 100644
--- a/lib/api/pages_domains.rb
+++ b/lib/api/pages_domains.rb
@@ -13,9 +13,11 @@ module API
end
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def find_pages_domain!
user_project.pages_domains.find_by(domain: params[:domain]) || not_found!('PagesDomain')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def pages_domain
@pages_domain ||= find_pages_domain!
@@ -61,11 +63,13 @@ module API
params do
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/pages/domains" do
authorize! :read_pages, user_project
present paginate(user_project.pages_domains.order(:domain)), with: Entities::PagesDomain
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a single pages domain' do
success Entities::PagesDomain
diff --git a/lib/api/pipeline_schedules.rb b/lib/api/pipeline_schedules.rb
index 37f32411296..f858e199f36 100644
--- a/lib/api/pipeline_schedules.rb
+++ b/lib/api/pipeline_schedules.rb
@@ -16,6 +16,7 @@ module API
optional :scope, type: String, values: %w[active inactive],
desc: 'The scope of pipeline schedules'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/pipeline_schedules' do
authorize! :read_pipeline_schedule, user_project
@@ -23,6 +24,7 @@ module API
.preload([:owner, :last_pipeline])
present paginate(schedules), with: Entities::PipelineSchedule
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a single pipeline schedule' do
success Entities::PipelineScheduleDetails
@@ -161,6 +163,7 @@ module API
end
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def pipeline_schedule
@pipeline_schedule ||=
user_project
@@ -172,7 +175,9 @@ module API
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def pipeline_schedule_variable
@pipeline_schedule_variable ||=
pipeline_schedule.variables.find_by(key: params[:key]).tap do |pipeline_schedule_variable|
@@ -181,6 +186,7 @@ module API
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb
index 5d33a13d035..5cce96d5ae7 100644
--- a/lib/api/pipelines.rb
+++ b/lib/api/pipelines.rb
@@ -43,6 +43,7 @@ module API
requires :ref, type: String, desc: 'Reference'
optional :variables, Array, desc: 'Array of variables available in the pipeline'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/pipeline' do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42124')
@@ -63,6 +64,7 @@ module API
render_validation_error!(new_pipeline)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Gets a specific pipeline for the project' do
detail 'This feature was introduced in GitLab 8.11'
diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb
index 0ada0ef4708..1ef176b1320 100644
--- a/lib/api/project_snippets.rb
+++ b/lib/api/project_snippets.rb
@@ -85,6 +85,7 @@ module API
desc: 'The visibility of the snippet'
at_least_one_of :title, :file_name, :code, :visibility_level
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ":id/snippets/:snippet_id" do
snippet = snippets_for_current_user.find_by(id: params.delete(:snippet_id))
not_found!('Snippet') unless snippet
@@ -107,11 +108,13 @@ module API
render_validation_error!(snippet)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete a project snippet'
params do
requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id/snippets/:snippet_id" do
snippet = snippets_for_current_user.find_by(id: params[:snippet_id])
not_found!('Snippet') unless snippet
@@ -120,11 +123,13 @@ module API
destroy_conditionally!(snippet)
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a raw project snippet'
params do
requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/snippets/:snippet_id/raw" do
snippet = snippets_for_current_user.find_by(id: params[:snippet_id])
not_found!('Snippet') unless snippet
@@ -133,6 +138,7 @@ module API
content_type 'text/plain'
present snippet.content
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get the user agent details for a project snippet' do
success Entities::UserAgentDetail
@@ -140,6 +146,7 @@ module API
params do
requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/snippets/:snippet_id/user_agent_detail" do
authenticated_as_admin!
@@ -149,6 +156,7 @@ module API
present snippet.user_agent_detail, with: Entities::UserAgentDetail
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 2801ae918c6..ee426f39523 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -198,6 +198,7 @@ module API
use :optional_project_params
use :create_params
end
+ # rubocop: disable CodeReuse/ActiveRecord
post "user/:user_id" do
authenticated_as_admin!
user = User.find_by(id: params.delete(:user_id))
@@ -214,6 +215,7 @@ module API
render_validation_error!(project)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
params do
@@ -444,6 +446,7 @@ module API
params do
requires :group_id, type: Integer, desc: 'The ID of the group'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id/share/:group_id" do
authorize! :admin_project, user_project
@@ -452,6 +455,7 @@ module API
destroy_conditionally!(link)
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Upload a file'
params do
diff --git a/lib/api/protected_branches.rb b/lib/api/protected_branches.rb
index a30eb46c220..e569fad8663 100644
--- a/lib/api/protected_branches.rb
+++ b/lib/api/protected_branches.rb
@@ -16,11 +16,13 @@ module API
params do
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/protected_branches' do
protected_branches = user_project.protected_branches.preload(:push_access_levels, :merge_access_levels)
present paginate(protected_branches), with: Entities::ProtectedBranch, project: user_project
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a single protected branch' do
success Entities::ProtectedBranch
@@ -28,11 +30,13 @@ module API
params do
requires :name, type: String, desc: 'The name of the branch or wildcard'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
protected_branch = user_project.protected_branches.find_by!(name: params[:name])
present protected_branch, with: Entities::ProtectedBranch, project: user_project
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Protect a single branch or wildcard' do
success Entities::ProtectedBranch
@@ -46,6 +50,7 @@ module API
values: ProtectedRefAccess::ALLOWED_ACCESS_LEVELS,
desc: 'Access levels allowed to merge (defaults: `40`, maintainer access level)'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/protected_branches' do
protected_branch = user_project.protected_branches.find_by(name: params[:name])
if protected_branch
@@ -62,11 +67,13 @@ module API
render_api_error!(protected_branch.errors.full_messages, 422)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Unprotect a single branch'
params do
requires :name, type: String, desc: 'The name of the protected branch'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
protected_branch = user_project.protected_branches.find_by!(name: params[:name])
@@ -75,6 +82,7 @@ module API
destroy_service.execute(protected_branch)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/protected_tags.rb b/lib/api/protected_tags.rb
index bf0a7184e1c..219d51a2bc5 100644
--- a/lib/api/protected_tags.rb
+++ b/lib/api/protected_tags.rb
@@ -17,11 +17,13 @@ module API
params do
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/protected_tags' do
protected_tags = user_project.protected_tags.preload(:create_access_levels)
present paginate(protected_tags), with: Entities::ProtectedTag, project: user_project
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a single protected tag' do
detail 'This feature was introduced in GitLab 11.3.'
@@ -30,11 +32,13 @@ module API
params do
requires :name, type: String, desc: 'The name of the tag or wildcard'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/protected_tags/:name', requirements: TAG_ENDPOINT_REQUIREMENTS do
protected_tag = user_project.protected_tags.find_by!(name: params[:name])
present protected_tag, with: Entities::ProtectedTag, project: user_project
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Protect a single tag or wildcard' do
detail 'This feature was introduced in GitLab 11.3.'
@@ -69,11 +73,13 @@ module API
params do
requires :name, type: String, desc: 'The name of the protected tag'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/protected_tags/:name', requirements: TAG_ENDPOINT_REQUIREMENTS do
protected_tag = user_project.protected_tags.find_by!(name: params[:name])
destroy_conditionally!(protected_tag)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/resource_label_events.rb b/lib/api/resource_label_events.rb
index 5ac3adeb990..b6fbe8c0235 100644
--- a/lib/api/resource_label_events.rb
+++ b/lib/api/resource_label_events.rb
@@ -25,12 +25,15 @@ module API
requires :eventable_id, types: [Integer, String], desc: 'The ID of the eventable'
use :pagination
end
+
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/#{eventables_str}/:eventable_id/resource_label_events" do
eventable = find_noteable(parent_type, eventables_str, params[:eventable_id])
events = eventable.resource_label_events.includes(:label, :user)
present paginate(events), with: Entities::ResourceLabelEvent
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Get a single #{eventable_type.to_s.downcase} resource label event" do
success Entities::ResourceLabelEvent
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index c9931c2d603..b2d46cef23c 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -17,6 +17,7 @@ module API
optional :tag_list, type: Array[String], desc: %q(List of Runner's tags)
optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post '/' do
attributes = attributes_for_keys([:description, :active, :locked, :run_untagged, :tag_list, :maximum_timeout])
.merge(get_runner_details_from_request)
@@ -43,6 +44,7 @@ module API
render_validation_error!(runner)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Deletes a registered Runner' do
http_codes [[204, 'Runner was deleted'], [403, 'Forbidden']]
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index 51242341dba..f35cf521e0a 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -146,6 +146,7 @@ module API
params do
requires :runner_id, type: Integer, desc: 'The ID of the runner'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/runners/:runner_id' do
runner_project = user_project.runner_projects.find_by(runner_id: params[:runner_id])
not_found!('Runner') unless runner_project
@@ -155,6 +156,7 @@ module API
destroy_conditionally!(runner_project)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
helpers do
diff --git a/lib/api/services.rb b/lib/api/services.rb
index d1a5ee7db35..0ae05ce08f1 100644
--- a/lib/api/services.rb
+++ b/lib/api/services.rb
@@ -821,11 +821,13 @@ module API
TRIGGER_SERVICES.each do |service_slug, settings|
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def slash_command_service(project, service_slug, params)
project.services.active.where(template: false).find do |service|
service.try(:token) == params[:token] && service.to_param == service_slug.underscore
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
params do
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb
index b30305b4bc9..6352a9c8742 100644
--- a/lib/api/snippets.rb
+++ b/lib/api/snippets.rb
@@ -92,6 +92,7 @@ module API
desc: 'The visibility of the snippet'
at_least_one_of :title, :file_name, :content, :visibility
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id' do
snippet = snippets_for_current_user.find_by(id: params.delete(:id))
break not_found!('Snippet') unless snippet
@@ -110,6 +111,7 @@ module API
render_validation_error!(snippet)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Remove snippet' do
detail 'This feature was introduced in GitLab 8.15.'
@@ -118,6 +120,7 @@ module API
params do
requires :id, type: Integer, desc: 'The ID of a snippet'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id' do
snippet = snippets_for_current_user.find_by(id: params.delete(:id))
break not_found!('Snippet') unless snippet
@@ -126,6 +129,7 @@ module API
destroy_conditionally!(snippet)
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a raw snippet' do
detail 'This feature was introduced in GitLab 8.15.'
@@ -133,6 +137,7 @@ module API
params do
requires :id, type: Integer, desc: 'The ID of a snippet'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/raw" do
snippet = snippets_for_current_user.find_by(id: params.delete(:id))
break not_found!('Snippet') unless snippet
@@ -141,6 +146,7 @@ module API
content_type 'text/plain'
present snippet.content
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get the user agent details for a snippet' do
success Entities::UserAgentDetail
@@ -148,6 +154,7 @@ module API
params do
requires :id, type: Integer, desc: 'The ID of a snippet'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id/user_agent_detail" do
authenticated_as_admin!
@@ -157,6 +164,7 @@ module API
present snippet.user_agent_detail, with: Entities::UserAgentDetail
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb
index c7a460df46a..07552aa18e8 100644
--- a/lib/api/system_hooks.rb
+++ b/lib/api/system_hooks.rb
@@ -63,12 +63,14 @@ module API
params do
requires :id, type: Integer, desc: 'The ID of the system hook'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id" do
hook = SystemHook.find_by(id: params[:id])
not_found!('System hook') unless hook
destroy_conditionally!(hook)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb
index b29e660c6e0..5e2917e4c3e 100644
--- a/lib/api/triggers.rb
+++ b/lib/api/triggers.rb
@@ -42,6 +42,7 @@ module API
params do
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/triggers' do
authenticate!
authorize! :admin_build, user_project
@@ -50,6 +51,7 @@ module API
present paginate(triggers), with: Entities::Trigger
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get specific trigger of a project' do
success Entities::Trigger
diff --git a/lib/api/users.rb b/lib/api/users.rb
index b0811bb4aad..b1657399cd8 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -14,11 +14,14 @@ module API
end
helpers do
+ # rubocop: disable CodeReuse/ActiveRecord
def find_user_by_id(params)
id = params[:user_id] || params[:id]
User.find_by(id: id) || not_found!('User')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def reorder_users(users)
if params[:order_by] && params[:sort]
users.reorder(params[:order_by] => params[:sort])
@@ -26,6 +29,7 @@ module API
users
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
params :optional_attributes do
optional :skype, type: String, desc: 'The Skype username'
@@ -75,6 +79,7 @@ module API
use :pagination
use :with_custom_attributes
end
+ # rubocop: disable CodeReuse/ActiveRecord
get do
authenticated_as_admin! if params[:external].present? || (params[:extern_uid].present? && params[:provider].present?)
@@ -102,6 +107,7 @@ module API
present paginate(users), options
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a single user' do
success Entities::User
@@ -111,6 +117,7 @@ module API
use :with_custom_attributes
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ":id" do
user = User.find_by(id: params[:id])
not_found!('User') unless user && can?(current_user, :read_user, user)
@@ -120,6 +127,7 @@ module API
present user, opts
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Get the status of a user"
params do
@@ -145,6 +153,7 @@ module API
requires :username, type: String, desc: 'The username of the user'
use :optional_attributes
end
+ # rubocop: disable CodeReuse/ActiveRecord
post do
authenticated_as_admin!
@@ -165,6 +174,7 @@ module API
render_validation_error!(user)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Update a user. Available only for admins.' do
success Entities::UserPublic
@@ -178,6 +188,7 @@ module API
optional :username, type: String, desc: 'The username of the user'
use :optional_attributes
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ":id" do
authenticated_as_admin!
@@ -216,6 +227,7 @@ module API
render_validation_error!(user)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Add an SSH key to a specified user. Available only for admins.' do
success Entities::SSHKey
@@ -225,6 +237,7 @@ module API
requires :key, type: String, desc: 'The new SSH key'
requires :title, type: String, desc: 'The title of the new SSH key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ":id/keys" do
authenticated_as_admin!
@@ -239,6 +252,7 @@ module API
render_validation_error!(key)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get the SSH keys of a specified user. Available only for admins.' do
success Entities::SSHKey
@@ -247,6 +261,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/keys' do
authenticated_as_admin!
@@ -255,6 +270,7 @@ module API
present paginate(user.keys), with: Entities::SSHKey
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an existing SSH key from a specified user. Available only for admins.' do
success Entities::SSHKey
@@ -263,6 +279,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
requires :key_id, type: Integer, desc: 'The ID of the SSH key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/keys/:key_id' do
authenticated_as_admin!
@@ -274,6 +291,7 @@ module API
destroy_conditionally!(key)
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Add a GPG key to a specified user. Available only for admins.' do
detail 'This feature was added in GitLab 10.0'
@@ -283,6 +301,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
requires :key, type: String, desc: 'The new GPG key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/gpg_keys' do
authenticated_as_admin!
@@ -297,6 +316,7 @@ module API
render_validation_error!(key)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get the GPG keys of a specified user. Available only for admins.' do
detail 'This feature was added in GitLab 10.0'
@@ -306,6 +326,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/gpg_keys' do
authenticated_as_admin!
@@ -314,6 +335,7 @@ module API
present paginate(user.gpg_keys), with: Entities::GPGKey
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an existing GPG key from a specified user. Available only for admins.' do
detail 'This feature was added in GitLab 10.0'
@@ -322,6 +344,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
requires :key_id, type: Integer, desc: 'The ID of the GPG key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/gpg_keys/:key_id' do
authenticated_as_admin!
@@ -334,6 +357,7 @@ module API
status 204
key.destroy
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Revokes an existing GPG key from a specified user. Available only for admins.' do
detail 'This feature was added in GitLab 10.0'
@@ -342,6 +366,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
requires :key_id, type: Integer, desc: 'The ID of the GPG key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/gpg_keys/:key_id/revoke' do
authenticated_as_admin!
@@ -354,6 +379,7 @@ module API
key.revoke
status :accepted
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Add an email address to a specified user. Available only for admins.' do
success Entities::Email
@@ -362,6 +388,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
requires :email, type: String, desc: 'The email of the user'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ":id/emails" do
authenticated_as_admin!
@@ -376,6 +403,7 @@ module API
render_validation_error!(email)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get the emails addresses of a specified user. Available only for admins.' do
success Entities::Email
@@ -384,6 +412,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/emails' do
authenticated_as_admin!
user = User.find_by(id: params[:id])
@@ -391,6 +420,7 @@ module API
present paginate(user.emails), with: Entities::Email
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an email address of a specified user. Available only for admins.' do
success Entities::Email
@@ -399,6 +429,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
requires :email_id, type: Integer, desc: 'The ID of the email'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/emails/:email_id' do
authenticated_as_admin!
user = User.find_by(id: params[:id])
@@ -411,6 +442,7 @@ module API
Emails::DestroyService.new(current_user, user: user).execute(email)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete a user. Available only for admins.' do
success Entities::Email
@@ -419,6 +451,7 @@ module API
requires :id, type: Integer, desc: 'The ID of the user'
optional :hard_delete, type: Boolean, desc: "Whether to remove a user's contributions"
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ":id" do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42279')
@@ -431,11 +464,13 @@ module API
user.delete_async(deleted_by: current_user, params: params)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Block a user. Available only for admins.'
params do
requires :id, type: Integer, desc: 'The ID of the user'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/block' do
authenticated_as_admin!
user = User.find_by(id: params[:id])
@@ -447,11 +482,13 @@ module API
forbidden!('LDAP blocked users cannot be modified by the API')
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Unblock a user. Available only for admins.'
params do
requires :id, type: Integer, desc: 'The ID of the user'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post ':id/unblock' do
authenticated_as_admin!
user = User.find_by(id: params[:id])
@@ -463,6 +500,7 @@ module API
user.activate
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
params do
requires :user_id, type: Integer, desc: 'The ID of the user'
@@ -475,9 +513,11 @@ module API
PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_impersonation_token
finder.find_by(id: declared_params[:impersonation_token_id]) || not_found!('Impersonation Token')
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
before { authenticated_as_admin! }
@@ -578,12 +618,14 @@ module API
params do
requires :key_id, type: Integer, desc: 'The ID of the SSH key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get "keys/:key_id" do
key = current_user.keys.find_by(id: params[:key_id])
not_found!('Key') unless key
present key, with: Entities::SSHKey
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Add a new SSH key to the currently authenticated user' do
success Entities::SSHKey
@@ -608,12 +650,14 @@ module API
params do
requires :key_id, type: Integer, desc: 'The ID of the SSH key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete "keys/:key_id" do
key = current_user.keys.find_by(id: params[:key_id])
not_found!('Key') unless key
destroy_conditionally!(key)
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Get the currently authenticated user's GPG keys" do
detail 'This feature was added in GitLab 10.0'
@@ -633,12 +677,14 @@ module API
params do
requires :key_id, type: Integer, desc: 'The ID of the GPG key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get 'gpg_keys/:key_id' do
key = current_user.gpg_keys.find_by(id: params[:key_id])
not_found!('GPG Key') unless key
present key, with: Entities::GPGKey
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Add a new GPG key to the currently authenticated user' do
detail 'This feature was added in GitLab 10.0'
@@ -663,6 +709,7 @@ module API
params do
requires :key_id, type: Integer, desc: 'The ID of the GPG key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
post 'gpg_keys/:key_id/revoke' do
key = current_user.gpg_keys.find_by(id: params[:key_id])
not_found!('GPG Key') unless key
@@ -670,6 +717,7 @@ module API
key.revoke
status :accepted
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete a GPG key from the currently authenticated user' do
detail 'This feature was added in GitLab 10.0'
@@ -677,6 +725,7 @@ module API
params do
requires :key_id, type: Integer, desc: 'The ID of the SSH key'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete 'gpg_keys/:key_id' do
key = current_user.gpg_keys.find_by(id: params[:key_id])
not_found!('GPG Key') unless key
@@ -684,6 +733,7 @@ module API
status 204
key.destroy
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc "Get the currently authenticated user's email addresses" do
success Entities::Email
@@ -701,12 +751,14 @@ module API
params do
requires :email_id, type: Integer, desc: 'The ID of the email'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get "emails/:email_id" do
email = current_user.emails.find_by(id: params[:email_id])
not_found!('Email') unless email
present email, with: Entities::Email
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Add new email address to the currently authenticated user' do
success Entities::Email
@@ -728,6 +780,7 @@ module API
params do
requires :email_id, type: Integer, desc: 'The ID of the email'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete "emails/:email_id" do
email = current_user.emails.find_by(id: params[:email_id])
not_found!('Email') unless email
@@ -736,12 +789,14 @@ module API
Emails::DestroyService.new(current_user, user: current_user).execute(email)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Get a list of user activities'
params do
optional :from, type: DateTime, default: 6.months.ago, desc: 'Date string in the format YEAR-MONTH-DAY'
use :pagination
end
+ # rubocop: disable CodeReuse/ActiveRecord
get "activities" do
authenticated_as_admin!
@@ -751,6 +806,7 @@ module API
present paginate(activities), with: Entities::UserActivity
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Set the status of the current user' do
success Entities::UserStatus
diff --git a/lib/api/variables.rb b/lib/api/variables.rb
index a34de9410e8..50e6fa6bcdf 100644
--- a/lib/api/variables.rb
+++ b/lib/api/variables.rb
@@ -27,6 +27,7 @@ module API
params do
requires :key, type: String, desc: 'The key of the variable'
end
+ # rubocop: disable CodeReuse/ActiveRecord
get ':id/variables/:key' do
key = params[:key]
variable = user_project.variables.find_by(key: key)
@@ -35,6 +36,7 @@ module API
present variable, with: Entities::Variable
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Create a new variable in a project' do
success Entities::Variable
@@ -64,6 +66,7 @@ module API
optional :value, type: String, desc: 'The value of the variable'
optional :protected, type: String, desc: 'Whether the variable is protected'
end
+ # rubocop: disable CodeReuse/ActiveRecord
put ':id/variables/:key' do
variable = user_project.variables.find_by(key: params[:key])
@@ -77,6 +80,7 @@ module API
render_validation_error!(variable)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an existing variable from a project' do
success Entities::Variable
@@ -84,6 +88,7 @@ module API
params do
requires :key, type: String, desc: 'The key of the variable'
end
+ # rubocop: disable CodeReuse/ActiveRecord
delete ':id/variables/:key' do
variable = user_project.variables.find_by(key: params[:key])
not_found!('Variable') unless variable
@@ -92,6 +97,7 @@ module API
status 204
variable.destroy
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/container_registry/path.rb b/lib/container_registry/path.rb
index 61849a40383..1ab14c1c155 100644
--- a/lib/container_registry/path.rb
+++ b/lib/container_registry/path.rb
@@ -28,6 +28,7 @@ module ContainerRegistry
@components ||= @path.split('/')
end
+ # rubocop: disable CodeReuse/ActiveRecord
def nodes
raise InvalidRegistryPathError unless valid?
@@ -35,17 +36,20 @@ module ContainerRegistry
components.take(length).join('/')
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def has_project?
repository_project.present?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def has_repository?
return false unless has_project?
repository_project.container_repositories
.where(name: repository_name).any?
end
+ # rubocop: enable CodeReuse/ActiveRecord
def root_repository?
@path == project_path
diff --git a/lib/container_registry/tag.rb b/lib/container_registry/tag.rb
index 728deea224f..c785bca4dad 100644
--- a/lib/container_registry/tag.rb
+++ b/lib/container_registry/tag.rb
@@ -73,11 +73,13 @@ module ContainerRegistry
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def total_size
return unless layers
layers.map(&:size).sum if v2?
end
+ # rubocop: enable CodeReuse/ActiveRecord
def delete
return unless digest
diff --git a/lib/event_filter.rb b/lib/event_filter.rb
index 515095af1c2..f756a211a12 100644
--- a/lib/event_filter.rb
+++ b/lib/event_filter.rb
@@ -35,6 +35,7 @@ class EventFilter
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def apply_filter(events)
return events if params.blank? || params == EventFilter.all
@@ -51,6 +52,7 @@ class EventFilter
events.where(action: [Event::CREATED, Event::UPDATED, Event::CLOSED, Event::REOPENED])
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def options(key)
filter = params.dup
diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb
index 69d981e8be9..53aa8d04e5c 100644
--- a/lib/file_size_validator.rb
+++ b/lib/file_size_validator.rb
@@ -32,6 +32,7 @@ class FileSizeValidator < ActiveModel::EachValidator
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def validate_each(record, attribute, value)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.is_a? CarrierWave::Uploader::Base
@@ -62,6 +63,7 @@ class FileSizeValidator < ActiveModel::EachValidator
record.errors.add(attribute, MESSAGES[key], errors_options)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def help
Helper.instance
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb
index 111e18b2076..a36d551d1d7 100644
--- a/lib/gitlab/auth.rb
+++ b/lib/gitlab/auth.rb
@@ -136,6 +136,7 @@ module Gitlab
Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def oauth_access_token_check(login, password)
if login == "oauth2" && password.present?
token = Doorkeeper::AccessToken.by_token(password)
@@ -146,7 +147,9 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def personal_access_token_check(password)
return unless password.present?
@@ -156,6 +159,7 @@ module Gitlab
Gitlab::Auth::Result.new(token.user, nil, :personal_access_token, abilities_for_scopes(token.scopes))
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def valid_oauth_token?(token)
token && token.accessible? && valid_scoped_token?(token, [:api])
@@ -177,6 +181,7 @@ module Gitlab
end.uniq
end
+ # rubocop: disable CodeReuse/ActiveRecord
def deploy_token_check(login, password)
return unless password.present?
@@ -192,6 +197,7 @@ module Gitlab
Gitlab::Auth::Result.new(token, token.project, :deploy_token, scopes)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def lfs_token_check(login, password, project)
deploy_key_matches = login.match(/\Alfs\+deploy-key-(\d+)\z/)
diff --git a/lib/gitlab/auth/ldap/user.rb b/lib/gitlab/auth/ldap/user.rb
index 922d0567d99..3c21ddf3241 100644
--- a/lib/gitlab/auth/ldap/user.rb
+++ b/lib/gitlab/auth/ldap/user.rb
@@ -11,11 +11,13 @@ module Gitlab
extend ::Gitlab::Utils::Override
class << self
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by_uid_and_provider(uid, provider)
identity = ::Identity.with_extern_uid(provider, uid).take
identity && identity.user
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
def save
diff --git a/lib/gitlab/auth/o_auth/user.rb b/lib/gitlab/auth/o_auth/user.rb
index 589e8062226..2b4f6ed75e5 100644
--- a/lib/gitlab/auth/o_auth/user.rb
+++ b/lib/gitlab/auth/o_auth/user.rb
@@ -112,11 +112,13 @@ module Gitlab
build_new_user
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by_email
return unless auth_hash.has_attribute?(:email)
::User.find_by(email: auth_hash.email.downcase)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def auto_link_ldap_user?
Gitlab.config.omniauth.auto_link_ldap_user
@@ -180,10 +182,12 @@ module Gitlab
@auth_hash = AuthHash.new(auth_hash)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by_uid_and_provider
identity = Identity.with_extern_uid(auth_hash.provider, auth_hash.uid).take
identity&.user
end
+ # rubocop: enable CodeReuse/ActiveRecord
def build_new_user
user_params = user_attributes.merge(skip_confirmation: true)
diff --git a/lib/gitlab/auth/omniauth_identity_linker_base.rb b/lib/gitlab/auth/omniauth_identity_linker_base.rb
index f79ce6bb809..8ae29a02a13 100644
--- a/lib/gitlab/auth/omniauth_identity_linker_base.rb
+++ b/lib/gitlab/auth/omniauth_identity_linker_base.rb
@@ -33,11 +33,13 @@ module Gitlab
@changed = identity.save
end
+ # rubocop: disable CodeReuse/ActiveRecord
def identity
@identity ||= current_user.identities
.with_extern_uid(provider, uid)
.first_or_initialize(extern_uid: uid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def provider
oauth['provider']
diff --git a/lib/gitlab/auth/user_auth_finders.rb b/lib/gitlab/auth/user_auth_finders.rb
index c7993665421..064cba43278 100644
--- a/lib/gitlab/auth/user_auth_finders.rb
+++ b/lib/gitlab/auth/user_auth_finders.rb
@@ -71,6 +71,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_personal_access_token
token =
current_request.params[PRIVATE_TOKEN_PARAM].presence ||
@@ -81,6 +82,7 @@ module Gitlab
# Expiration, revocation and scopes are verified in `validate_access_token!`
PersonalAccessToken.find_by(token: token) || raise(UnauthorizedError)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def find_oauth_access_token
token = Doorkeeper::OAuth::Token.from_request(current_request, *Doorkeeper.configuration.access_token_methods)
diff --git a/lib/gitlab/badge/coverage/report.rb b/lib/gitlab/badge/coverage/report.rb
index 778d78185ff..16fd6f01495 100644
--- a/lib/gitlab/badge/coverage/report.rb
+++ b/lib/gitlab/badge/coverage/report.rb
@@ -36,6 +36,7 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def raw_coverage
return unless @pipeline
@@ -47,6 +48,7 @@ module Gitlab
.try(:coverage)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/badge/pipeline/status.rb b/lib/gitlab/badge/pipeline/status.rb
index 5fee7a93475..d1d9b7949f5 100644
--- a/lib/gitlab/badge/pipeline/status.rb
+++ b/lib/gitlab/badge/pipeline/status.rb
@@ -18,11 +18,13 @@ module Gitlab
'pipeline'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def status
@project.pipelines
.where(sha: @sha)
.latest_status(@ref) || 'unknown'
end
+ # rubocop: enable CodeReuse/ActiveRecord
def metadata
@metadata ||= Pipeline::Metadata.new(self)
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb
index fa0186c854c..a7dfccea2f6 100644
--- a/lib/gitlab/bitbucket_import/importer.rb
+++ b/lib/gitlab/bitbucket_import/importer.rb
@@ -43,6 +43,7 @@ module Gitlab
find_user_id(username) || project.creator_id
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_user_id(username)
return nil unless username
@@ -53,6 +54,7 @@ module Gitlab
.find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", username)
.try(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def repo
@repo ||= client.repo(project.import_source)
@@ -68,6 +70,7 @@ module Gitlab
errors << { type: :wiki, errors: e.message }
end
+ # rubocop: disable CodeReuse/ActiveRecord
def import_issues
return unless repo.issues_enabled?
@@ -101,6 +104,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def import_issue_comments(issue, gitlab_issue)
client.issue_comments(repo, issue.iid).each do |comment|
diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb
index d044e0a484f..15aa4739ee9 100644
--- a/lib/gitlab/bitbucket_server_import/importer.rb
+++ b/lib/gitlab/bitbucket_server_import/importer.rb
@@ -240,6 +240,7 @@ module Gitlab
standalone_pr_comments: pr_comments.count)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def import_merge_event(merge_request, merge_event)
log_info(stage: 'import_merge_event', message: 'starting', iid: merge_request.iid)
@@ -253,6 +254,7 @@ module Gitlab
log_info(stage: 'import_merge_event', message: 'finished', iid: merge_request.iid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def import_inline_comments(inline_comments, merge_request)
log_info(stage: 'import_inline_comments', message: 'starting', iid: merge_request.iid)
diff --git a/lib/gitlab/checks/commit_check.rb b/lib/gitlab/checks/commit_check.rb
index 22310e313ac..7e0c34aada3 100644
--- a/lib/gitlab/checks/commit_check.rb
+++ b/lib/gitlab/checks/commit_check.rb
@@ -43,6 +43,7 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def lfs_file_locks_validation
lambda do |paths|
lfs_lock = project.lfs_file_locks.where(path: paths).where.not(user_id: user.id).first
@@ -52,6 +53,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def path_validations
validate_lfs_file_locks? ? [lfs_file_locks_validation] : []
diff --git a/lib/gitlab/checks/lfs_integrity.rb b/lib/gitlab/checks/lfs_integrity.rb
index b816a8f00cd..3f7adecc621 100644
--- a/lib/gitlab/checks/lfs_integrity.rb
+++ b/lib/gitlab/checks/lfs_integrity.rb
@@ -6,6 +6,7 @@ module Gitlab
@newrev = newrev
end
+ # rubocop: disable CodeReuse/ActiveRecord
def objects_missing?
return false unless @newrev && @project.lfs_enabled?
@@ -20,6 +21,7 @@ module Gitlab
existing_count != new_lfs_pointers.count
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/checks/matching_merge_request.rb b/lib/gitlab/checks/matching_merge_request.rb
index 849848515da..86f4aaeb4d3 100644
--- a/lib/gitlab/checks/matching_merge_request.rb
+++ b/lib/gitlab/checks/matching_merge_request.rb
@@ -7,12 +7,14 @@ module Gitlab
@project = project
end
+ # rubocop: disable CodeReuse/ActiveRecord
def match?
@project.merge_requests
.with_state(:locked)
.where(in_progress_merge_commit_sha: @newrev, target_branch: @branch_name)
.exists?
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/ci/build/artifacts/metadata/entry.rb b/lib/gitlab/ci/build/artifacts/metadata/entry.rb
index 428c0505808..85072a072d6 100644
--- a/lib/gitlab/ci/build/artifacts/metadata/entry.rb
+++ b/lib/gitlab/ci/build/artifacts/metadata/entry.rb
@@ -96,12 +96,14 @@ module Gitlab
blank_node? || @entries.include?(@path.to_s)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def total_size
descendant_pattern = /^#{Regexp.escape(@path.to_s)}/
entries.sum do |path, entry|
(entry[:size] if path =~ descendant_pattern).to_i
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def path
@path.to_s
diff --git a/lib/gitlab/ci/charts.rb b/lib/gitlab/ci/charts.rb
index 46ed330dbbf..7b7354bce16 100644
--- a/lib/gitlab/ci/charts.rb
+++ b/lib/gitlab/ci/charts.rb
@@ -2,12 +2,14 @@ module Gitlab
module Ci
module Charts
module DailyInterval
+ # rubocop: disable CodeReuse/ActiveRecord
def grouped_count(query)
query
.group("DATE(#{::Ci::Pipeline.table_name}.created_at)")
.count(:created_at)
.transform_keys { |date| date.strftime(@format) } # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
+ # rubocop: enable CodeReuse/ActiveRecord
def interval_step
@interval_step ||= 1.day
@@ -15,6 +17,7 @@ module Gitlab
end
module MonthlyInterval
+ # rubocop: disable CodeReuse/ActiveRecord
def grouped_count(query)
if Gitlab::Database.postgresql?
query
@@ -27,6 +30,7 @@ module Gitlab
.count(:created_at)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def interval_step
@interval_step ||= 1.month
@@ -46,6 +50,7 @@ module Gitlab
collect
end
+ # rubocop: disable CodeReuse/ActiveRecord
def collect
query = project.pipelines
.where("? > #{::Ci::Pipeline.table_name}.created_at AND #{::Ci::Pipeline.table_name}.created_at > ?", @to, @from) # rubocop:disable GitlabSecurity/SqlInjection
@@ -64,6 +69,7 @@ module Gitlab
current += interval_step
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
class YearChart < Chart
diff --git a/lib/gitlab/ci/config/entry/configurable.rb b/lib/gitlab/ci/config/entry/configurable.rb
index 7cddd2c7b7e..697f622c45e 100644
--- a/lib/gitlab/ci/config/entry/configurable.rb
+++ b/lib/gitlab/ci/config/entry/configurable.rb
@@ -24,6 +24,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def compose!(deps = nil)
return unless valid?
@@ -41,6 +42,7 @@ module Gitlab
entry.compose!(deps)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
class_methods do
def nodes
@@ -49,12 +51,14 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def entry(key, entry, metadata)
factory = Entry::Factory.new(entry)
.with(description: metadata[:description])
(@nodes ||= {}).merge!(key.to_sym => factory)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def helpers(*nodes)
nodes.each do |symbol|
diff --git a/lib/gitlab/ci/config/entry/global.rb b/lib/gitlab/ci/config/entry/global.rb
index a4ec8f0ff2f..04077fa7a61 100644
--- a/lib/gitlab/ci/config/entry/global.rb
+++ b/lib/gitlab/ci/config/entry/global.rb
@@ -45,6 +45,7 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def compose_jobs!
factory = Entry::Factory.new(Entry::Jobs)
.value(@config.except(*self.class.nodes.keys))
@@ -53,6 +54,7 @@ module Gitlab
@entries[:jobs] = factory.create!
end
+ # rubocop: enable CodeReuse/ActiveRecord
def compose_deprecated_entries!
##
diff --git a/lib/gitlab/ci/config/entry/jobs.rb b/lib/gitlab/ci/config/entry/jobs.rb
index 5671a09480b..96b6f2e5d6c 100644
--- a/lib/gitlab/ci/config/entry/jobs.rb
+++ b/lib/gitlab/ci/config/entry/jobs.rb
@@ -26,6 +26,7 @@ module Gitlab
name.to_s.start_with?('.')
end
+ # rubocop: disable CodeReuse/ActiveRecord
def compose!(deps = nil)
super do
@config.each do |name, config|
@@ -45,6 +46,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/ci/pipeline/chain/create.rb b/lib/gitlab/ci/pipeline/chain/create.rb
index f4c8d5342c1..02493c7fe02 100644
--- a/lib/gitlab/ci/pipeline/chain/create.rb
+++ b/lib/gitlab/ci/pipeline/chain/create.rb
@@ -5,6 +5,7 @@ module Gitlab
class Create < Chain::Base
include Chain::Helpers
+ # rubocop: disable CodeReuse/ActiveRecord
def perform!
::Ci::Pipeline.transaction do
pipeline.save!
@@ -23,6 +24,7 @@ module Gitlab
rescue ActiveRecord::RecordInvalid => e
error("Failed to persist the pipeline: #{e}")
end
+ # rubocop: enable CodeReuse/ActiveRecord
def break?
!pipeline.persisted?
diff --git a/lib/gitlab/ci/pipeline/duration.rb b/lib/gitlab/ci/pipeline/duration.rb
index 469fc094cc8..30701e1de1b 100644
--- a/lib/gitlab/ci/pipeline/duration.rb
+++ b/lib/gitlab/ci/pipeline/duration.rb
@@ -86,6 +86,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def from_pipeline(pipeline)
status = %w[success failed running canceled]
builds = pipeline.builds.latest
@@ -93,6 +94,7 @@ module Gitlab
from_builds(builds)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def from_builds(builds)
now = Time.now
@@ -134,9 +136,11 @@ module Gitlab
Period.new(previous.first, [previous.last, current.last].max)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def process_duration(periods)
periods.sum(&:duration)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/ci/reports/test_reports.rb b/lib/gitlab/ci/reports/test_reports.rb
index c6e732e68eb..c87bdb4a8a2 100644
--- a/lib/gitlab/ci/reports/test_reports.rb
+++ b/lib/gitlab/ci/reports/test_reports.rb
@@ -12,13 +12,17 @@ module Gitlab
test_suites[suite_name] ||= TestSuite.new(suite_name)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def total_time
test_suites.values.sum(&:total_time)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def total_count
test_suites.values.sum(&:total_count)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def total_status
if failed_count > 0 || error_count > 0
@@ -30,7 +34,9 @@ module Gitlab
TestCase::STATUS_TYPES.each do |status_type|
define_method("#{status_type}_count") do
+ # rubocop: disable CodeReuse/ActiveRecord
test_suites.values.sum { |suite| suite.public_send("#{status_type}_count") } # rubocop:disable GitlabSecurity/PublicSend
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/ci/reports/test_reports_comparer.rb b/lib/gitlab/ci/reports/test_reports_comparer.rb
index c0943f5a51a..726c6a11a81 100644
--- a/lib/gitlab/ci/reports/test_reports_comparer.rb
+++ b/lib/gitlab/ci/reports/test_reports_comparer.rb
@@ -29,7 +29,9 @@ module Gitlab
%w(total_count resolved_count failed_count).each do |method|
define_method(method) do
+ # rubocop: disable CodeReuse/ActiveRecord
suite_comparers.sum { |suite| suite.public_send(method) } # rubocop:disable GitlabSecurity/PublicSend
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/ci/reports/test_suite.rb b/lib/gitlab/ci/reports/test_suite.rb
index b722d0ba735..b5f15397c0f 100644
--- a/lib/gitlab/ci/reports/test_suite.rb
+++ b/lib/gitlab/ci/reports/test_suite.rb
@@ -21,9 +21,11 @@ module Gitlab
@total_time += test_case.execution_time
end
+ # rubocop: disable CodeReuse/ActiveRecord
def total_count
test_cases.values.sum(&:count)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def total_status
if failed_count > 0 || error_count > 0
diff --git a/lib/gitlab/ci/trace/chunked_io.rb b/lib/gitlab/ci/trace/chunked_io.rb
index bfe0c2a2c26..2147f62a84a 100644
--- a/lib/gitlab/ci/trace/chunked_io.rb
+++ b/lib/gitlab/ci/trace/chunked_io.rb
@@ -133,6 +133,7 @@ module Gitlab
invalidate_chunk_cache
end
+ # rubocop: disable CodeReuse/ActiveRecord
def truncate(offset)
raise ArgumentError, 'Outside of file' if offset > size || offset < 0
return if offset == size # Skip the following process as it doesn't affect anything
@@ -148,6 +149,7 @@ module Gitlab
ensure
invalidate_chunk_cache
end
+ # rubocop: enable CodeReuse/ActiveRecord
def flush
# no-op
@@ -206,9 +208,11 @@ module Gitlab
@chunks_cache = []
end
+ # rubocop: disable CodeReuse/ActiveRecord
def current_chunk
@chunks_cache[chunk_index] ||= trace_chunks.find_by(chunk_index: chunk_index)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def build_chunk
@chunks_cache[chunk_index] = ::Ci::BuildTraceChunk.new(build: build, chunk_index: chunk_index)
@@ -218,13 +222,17 @@ module Gitlab
current_chunk || build_chunk
end
+ # rubocop: disable CodeReuse/ActiveRecord
def trace_chunks
::Ci::BuildTraceChunk.where(build: build)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def calculate_size
trace_chunks.order(chunk_index: :desc).first.try(&:end_offset).to_i
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/cleanup/project_uploads.rb b/lib/gitlab/cleanup/project_uploads.rb
index f55ab535efe..82a405362c2 100644
--- a/lib/gitlab/cleanup/project_uploads.rb
+++ b/lib/gitlab/cleanup/project_uploads.rb
@@ -38,6 +38,7 @@ module Gitlab
end
# Accepts a path in the form of "#{hex_secret}/#{filename}"
+ # rubocop: disable CodeReuse/ActiveRecord
def find_correct_path(upload_path)
upload = Upload.find_by(uploader: 'FileUploader', path: upload_path)
return unless upload && upload.local? && upload.model
@@ -52,6 +53,7 @@ module Gitlab
# I.e. the project record might be missing, which raises an exception.
nil
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_to_lost_and_found(path, dry_run)
new_path = path.sub(/\A#{ProjectUploadFileFinder::ABSOLUTE_UPLOAD_DIR}/, LOST_AND_FOUND)
@@ -107,18 +109,22 @@ module Gitlab
new(path_matched[1], path_matched[2])
end
+ # rubocop: disable CodeReuse/ActiveRecord
def orphan?
return true if full_path.nil? || upload_path.nil?
# It's possible to reduce to one query, but `where_full_path_in` is complex
!Upload.exists?(path: upload_path, model_id: project_id, model_type: 'Project', uploader: 'FileUploader')
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def project_id
@project_id ||= Project.where_full_path_in([full_path]).pluck(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/cleanup/remote_uploads.rb b/lib/gitlab/cleanup/remote_uploads.rb
index 45a5aea4fcd..eba1faacc3a 100644
--- a/lib/gitlab/cleanup/remote_uploads.rb
+++ b/lib/gitlab/cleanup/remote_uploads.rb
@@ -33,6 +33,7 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def each_orphan_file
# we want to skip files already moved to lost_and_found directory
lost_dir_match = "^#{lost_and_found_dir}\/"
@@ -50,6 +51,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_to_lost_and_found(file)
new_path = "#{lost_and_found_dir}/#{file.key}"
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb
index 58ca077e636..3236abfa43f 100644
--- a/lib/gitlab/contributions_calendar.rb
+++ b/lib/gitlab/contributions_calendar.rb
@@ -14,6 +14,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def activity_dates
return @activity_dates if @activity_dates.present?
@@ -36,7 +37,9 @@ module Gitlab
activities[event["date"]] += event["total_amount"]
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def events_by_date(date)
return Event.none unless can_read_cross_project?
@@ -44,6 +47,7 @@ module Gitlab
.where(created_at: date.beginning_of_day..date.end_of_day)
.where(project_id: projects)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def starting_year
1.year.ago.year
@@ -59,6 +63,7 @@ module Gitlab
Ability.allowed?(current_user, :read_cross_project)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def event_counts(date_from, feature)
t = Event.arel_table
@@ -87,5 +92,6 @@ module Gitlab
.where(conditions)
.where("events.project_id in (#{authed_projects.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb
index d16a55720b7..d2ca7a070fa 100644
--- a/lib/gitlab/diff/file.rb
+++ b/lib/gitlab/diff/file.rb
@@ -211,13 +211,17 @@ module Gitlab
old_blob && new_blob && old_blob.binary? != new_blob.binary?
end
+ # rubocop: disable CodeReuse/ActiveRecord
def size
valid_blobs.map(&:size).sum
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def raw_size
valid_blobs.map(&:raw_size).sum
end
+ # rubocop: enable CodeReuse/ActiveRecord
def raw_binary?
try_blobs(:raw_binary?)
diff --git a/lib/gitlab/diff/inline_diff.rb b/lib/gitlab/diff/inline_diff.rb
index 99970779c67..72d5ec547da 100644
--- a/lib/gitlab/diff/inline_diff.rb
+++ b/lib/gitlab/diff/inline_diff.rb
@@ -67,6 +67,7 @@ module Gitlab
private
# Finds pairs of old/new line pairs that represent the same line that changed
+ # rubocop: disable CodeReuse/ActiveRecord
def find_changed_line_pairs(lines)
# Prefixes of all diff lines, indicating their types
# For example: `" - + -+ ---+++ --+ -++"`
@@ -89,6 +90,7 @@ module Gitlab
changed_line_pairs
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
private
diff --git a/lib/gitlab/email/handler/create_issue_handler.rb b/lib/gitlab/email/handler/create_issue_handler.rb
index 64ed9e036ad..69982efbbe6 100644
--- a/lib/gitlab/email/handler/create_issue_handler.rb
+++ b/lib/gitlab/email/handler/create_issue_handler.rb
@@ -30,9 +30,11 @@ module Gitlab
record_name: 'issue')
end
+ # rubocop: disable CodeReuse/ActiveRecord
def author
@author ||= User.find_by(incoming_email_token: incoming_email_token)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def project
@project ||= Project.find_by_full_path(project_path)
diff --git a/lib/gitlab/email/handler/create_merge_request_handler.rb b/lib/gitlab/email/handler/create_merge_request_handler.rb
index a5bd70248af..e68ae60ff98 100644
--- a/lib/gitlab/email/handler/create_merge_request_handler.rb
+++ b/lib/gitlab/email/handler/create_merge_request_handler.rb
@@ -34,9 +34,11 @@ module Gitlab
record_name: 'merge_request')
end
+ # rubocop: disable CodeReuse/ActiveRecord
def author
@author ||= User.find_by(incoming_email_token: incoming_email_token)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def project
@project ||= Project.find_by_full_path(project_path)
diff --git a/lib/gitlab/fogbugz_import/importer.rb b/lib/gitlab/fogbugz_import/importer.rb
index a91de278cf3..98ea5b309a1 100644
--- a/lib/gitlab/fogbugz_import/importer.rb
+++ b/lib/gitlab/fogbugz_import/importer.rb
@@ -79,6 +79,7 @@ module Gitlab
::Labels::FindOrCreateService.new(nil, project, params).execute(skip_authorization: true)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def user_info(person_id)
user_hash = user_map[person_id.to_s]
@@ -95,7 +96,9 @@ module Gitlab
{ name: user_name, gitlab_id: gitlab_id }
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def import_cases
return unless @cases
@@ -141,6 +144,7 @@ module Gitlab
import_issue_comments(issue, comments)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def opened_content(comments)
while comment = comments.shift
diff --git a/lib/gitlab/git/storage/health.rb b/lib/gitlab/git/storage/health.rb
index 90bbe85fd37..8e14acb4ccb 100644
--- a/lib/gitlab/git/storage/health.rb
+++ b/lib/gitlab/git/storage/health.rb
@@ -81,9 +81,11 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def total_failures
@total_failures ||= failing_info.sum { |info_for_host| info_for_host[:failure_count] }
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index aa5b4f94090..f65d7383dc7 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -250,6 +250,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def patch(revision)
request = Gitaly::CommitPatchRequest.new(
repository: @gitaly_repo,
@@ -259,6 +260,7 @@ module Gitlab
response.sum(&:data)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def commit_stats(revision)
request = Gitaly::CommitStatsRequest.new(
diff --git a/lib/gitlab/github_import/importer/labels_importer.rb b/lib/gitlab/github_import/importer/labels_importer.rb
index a73033d35ba..80246fa1b77 100644
--- a/lib/gitlab/github_import/importer/labels_importer.rb
+++ b/lib/gitlab/github_import/importer/labels_importer.rb
@@ -10,11 +10,13 @@ module Gitlab
# project - An instance of `Project`.
# client - An instance of `Gitlab::GithubImport::Client`.
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(project, client)
@project = project
@client = client
@existing_labels = project.labels.pluck(:title).to_set
end
+ # rubocop: enable CodeReuse/ActiveRecord
def execute
bulk_insert(Label, build_labels)
diff --git a/lib/gitlab/github_import/importer/milestones_importer.rb b/lib/gitlab/github_import/importer/milestones_importer.rb
index 94eb9136b9a..8d54b27374c 100644
--- a/lib/gitlab/github_import/importer/milestones_importer.rb
+++ b/lib/gitlab/github_import/importer/milestones_importer.rb
@@ -10,11 +10,13 @@ module Gitlab
# project - An instance of `Project`
# client - An instance of `Gitlab::GithubImport::Client`
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(project, client)
@project = project
@client = client
@existing_milestones = project.milestones.pluck(:iid).to_set
end
+ # rubocop: enable CodeReuse/ActiveRecord
def execute
# We insert records in bulk, by-passing any standard model callbacks.
diff --git a/lib/gitlab/github_import/importer/releases_importer.rb b/lib/gitlab/github_import/importer/releases_importer.rb
index 100f459fdcc..0e7c9ee0d00 100644
--- a/lib/gitlab/github_import/importer/releases_importer.rb
+++ b/lib/gitlab/github_import/importer/releases_importer.rb
@@ -10,11 +10,13 @@ module Gitlab
# project - An instance of `Project`
# client - An instance of `Gitlab::GithubImport::Client`
+ # rubocop: disable CodeReuse/ActiveRecord
def initialize(project, client)
@project = project
@client = client
@existing_tags = project.releases.pluck(:tag).to_set
end
+ # rubocop: enable CodeReuse/ActiveRecord
def execute
bulk_insert(Release, build_releases)
diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb
index 01168abde6c..374dc9d3c00 100644
--- a/lib/gitlab/github_import/importer/repository_importer.rb
+++ b/lib/gitlab/github_import/importer/repository_importer.rb
@@ -14,11 +14,13 @@ module Gitlab
end
# Returns true if we should import the wiki for the project.
+ # rubocop: disable CodeReuse/ActiveRecord
def import_wiki?
client.repository(project.import_source)&.has_wiki &&
!project.wiki_repository_exists? &&
Gitlab::GitalyClient::RemoteService.exists?(wiki_url)
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Imports the repository data.
#
diff --git a/lib/gitlab/github_import/label_finder.rb b/lib/gitlab/github_import/label_finder.rb
index 9be071141db..d2479a8f565 100644
--- a/lib/gitlab/github_import/label_finder.rb
+++ b/lib/gitlab/github_import/label_finder.rb
@@ -18,6 +18,7 @@ module Gitlab
Caching.read_integer(cache_key_for(name))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def build_cache
mapping = @project
.labels
@@ -28,6 +29,7 @@ module Gitlab
Caching.write_multiple(mapping)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def cache_key_for(name)
CACHE_KEY % { project: project.id, name: name }
diff --git a/lib/gitlab/github_import/milestone_finder.rb b/lib/gitlab/github_import/milestone_finder.rb
index 208d15dc144..5625730e796 100644
--- a/lib/gitlab/github_import/milestone_finder.rb
+++ b/lib/gitlab/github_import/milestone_finder.rb
@@ -21,6 +21,7 @@ module Gitlab
Caching.read_integer(cache_key_for(issuable.milestone_number))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def build_cache
mapping = @project
.milestones
@@ -31,6 +32,7 @@ module Gitlab
Caching.write_multiple(mapping)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def cache_key_for(iid)
CACHE_KEY % { project: project.id, iid: iid }
diff --git a/lib/gitlab/github_import/user_finder.rb b/lib/gitlab/github_import/user_finder.rb
index be1259662a7..30283f147ef 100644
--- a/lib/gitlab/github_import/user_finder.rb
+++ b/lib/gitlab/github_import/user_finder.rb
@@ -136,13 +136,17 @@ module Gitlab
Caching.write(ID_FOR_EMAIL_CACHE_KEY % email, gitlab_id)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def query_id_for_github_id(id)
User.for_github_id(id).pluck(:id).first
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def query_id_for_github_email(email)
User.by_any_email(email).pluck(:id).first
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Reads an ID from the cache.
#
diff --git a/lib/gitlab/gitlab_import/importer.rb b/lib/gitlab/gitlab_import/importer.rb
index 195672f5a12..047487f1d24 100644
--- a/lib/gitlab/gitlab_import/importer.rb
+++ b/lib/gitlab/gitlab_import/importer.rb
@@ -52,10 +52,12 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def gitlab_user_id(project, gitlab_id)
user = User.joins(:identities).find_by("identities.extern_uid = ? AND identities.provider = 'gitlab'", gitlab_id.to_s)
(user && user.id) || project.creator_id
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/gl_repository.rb b/lib/gitlab/gl_repository.rb
index 07c0abcce23..b54e45de4fe 100644
--- a/lib/gitlab/gl_repository.rb
+++ b/lib/gitlab/gl_repository.rb
@@ -4,6 +4,7 @@ module Gitlab
"#{is_wiki ? 'wiki' : 'project'}-#{project.id}"
end
+ # rubocop: disable CodeReuse/ActiveRecord
def self.parse(gl_repository)
match_data = /\A(project|wiki)-([1-9][0-9]*)\z/.match(gl_repository)
unless match_data
@@ -16,5 +17,6 @@ module Gitlab
[project, wiki]
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb
index 5070f4e3cfe..94c15739231 100644
--- a/lib/gitlab/google_code_import/importer.rb
+++ b/lib/gitlab/google_code_import/importer.rb
@@ -78,6 +78,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def import_issues
return unless repo.issues
@@ -123,6 +124,7 @@ module Gitlab
import_issue_comments(issue, comments)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def import_issue_labels(raw_issue)
labels = []
diff --git a/lib/gitlab/gpg/commit.rb b/lib/gitlab/gpg/commit.rb
index 2716834f566..2bc081a6181 100644
--- a/lib/gitlab/gpg/commit.rb
+++ b/lib/gitlab/gpg/commit.rb
@@ -26,6 +26,7 @@ module Gitlab
!!(signature_text && signed_text)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def signature
return unless has_signature?
@@ -36,6 +37,7 @@ module Gitlab
@signature = create_cached_signature!
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update_signature!(cached_signature)
using_keychain do |gpg_key|
@@ -113,9 +115,11 @@ module Gitlab
gpg_key&.verified_user_infos&.first || gpg_key&.user_infos&.first || {}
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_gpg_key(keyid)
GpgKey.find_by(primary_keyid: keyid) || GpgKeySubkey.find_by(keyid: keyid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/gpg/invalid_gpg_signature_updater.rb b/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
index 1991911ef6a..6972bd685f7 100644
--- a/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
+++ b/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
@@ -5,6 +5,7 @@ module Gitlab
@gpg_key = gpg_key
end
+ # rubocop: disable CodeReuse/ActiveRecord
def run
GpgSignature
.select(:id, :commit_sha, :project_id)
@@ -12,6 +13,7 @@ module Gitlab
.where(gpg_key_primary_keyid: @gpg_key.keyids)
.find_each { |sig| sig.gpg_commit&.update_signature!(sig) }
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/graphql/connections/keyset_connection.rb b/lib/gitlab/graphql/connections/keyset_connection.rb
index abee2afe144..3c0d7e9784a 100644
--- a/lib/gitlab/graphql/connections/keyset_connection.rb
+++ b/lib/gitlab/graphql/connections/keyset_connection.rb
@@ -6,6 +6,7 @@ module Gitlab
encode(node[order_field].to_s)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def sliced_nodes
@sliced_nodes ||=
begin
@@ -17,7 +18,9 @@ module Gitlab
sliced
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def paged_nodes
if first && last
raise Gitlab::Graphql::Errors::ArgumentError.new("Can only provide either `first` or `last`, not both")
@@ -29,6 +32,7 @@ module Gitlab
sliced_nodes.limit(limit_value)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/lib/gitlab/group_hierarchy.rb b/lib/gitlab/group_hierarchy.rb
index 42ded7c286f..b74e7b10448 100644
--- a/lib/gitlab/group_hierarchy.rb
+++ b/lib/gitlab/group_hierarchy.rb
@@ -19,9 +19,11 @@ module Gitlab
# Returns the set of descendants of a given relation, but excluding the given
# relation
+ # rubocop: disable CodeReuse/ActiveRecord
def descendants
base_and_descendants.where.not(id: descendants_base.select(:id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Returns the set of ancestors of a given relation, but excluding the given
# relation
@@ -29,9 +31,11 @@ module Gitlab
# Passing an `upto` will stop the recursion once the specified parent_id is
# reached. So all ancestors *lower* than the specified ancestor will be
# included.
+ # rubocop: disable CodeReuse/ActiveRecord
def ancestors(upto: nil)
base_and_ancestors(upto: upto).where.not(id: ancestors_base.select(:id))
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Returns a relation that includes the ancestors_base set of groups
# and all their ancestors (recursively).
@@ -75,6 +79,7 @@ module Gitlab
# Rails thinking it's selecting data the usual way.
#
# If nested groups are not supported, ancestors_base is returned.
+ # rubocop: disable CodeReuse/ActiveRecord
def all_groups
return ancestors_base unless Group.supports_nested_groups?
@@ -95,9 +100,11 @@ module Gitlab
read_only(relation)
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
+ # rubocop: disable CodeReuse/ActiveRecord
def base_and_ancestors_cte(stop_id = nil)
cte = SQL::RecursiveCTE.new(:base_and_ancestors)
@@ -113,7 +120,9 @@ module Gitlab
cte << parent_query
cte
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def base_and_descendants_cte
cte = SQL::RecursiveCTE.new(:base_and_descendants)
@@ -127,6 +136,7 @@ module Gitlab
cte
end
+ # rubocop: enable CodeReuse/ActiveRecord
def groups_table
model.arel_table
diff --git a/lib/gitlab/hashed_storage/migrator.rb b/lib/gitlab/hashed_storage/migrator.rb
index d11fcc6a3e3..4edc251facb 100644
--- a/lib/gitlab/hashed_storage/migrator.rb
+++ b/lib/gitlab/hashed_storage/migrator.rb
@@ -22,6 +22,7 @@ module Gitlab
#
# @param [Object] start first project id for the range
# @param [Object] finish last project id for the range
+ # rubocop: disable CodeReuse/ActiveRecord
def bulk_migrate(start, finish)
projects = build_relation(start, finish)
@@ -29,6 +30,7 @@ module Gitlab
migrate(project)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Flag a project to be migrated
#
@@ -43,6 +45,7 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def build_relation(start, finish)
relation = Project
table = Project.arel_table
@@ -52,6 +55,7 @@ module Gitlab
relation
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/hashed_storage/rake_helper.rb b/lib/gitlab/hashed_storage/rake_helper.rb
index 303b05e6a9a..22edd5f999d 100644
--- a/lib/gitlab/hashed_storage/rake_helper.rb
+++ b/lib/gitlab/hashed_storage/rake_helper.rb
@@ -21,6 +21,7 @@ module Gitlab
!range_from.nil? && range_from == range_to
end
+ # rubocop: disable CodeReuse/ActiveRecord
def self.project_id_batches(&block)
Project.with_unmigrated_storage.in_batches(of: batch_size, start: range_from, finish: range_to) do |relation| # rubocop: disable Cop/InBatches
ids = relation.pluck(:id)
@@ -28,20 +29,25 @@ module Gitlab
yield ids.min, ids.max
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def self.legacy_attachments_relation
Upload.joins(<<~SQL).where('projects.storage_version < :version OR projects.storage_version IS NULL', version: Project::HASHED_STORAGE_FEATURES[:attachments])
JOIN projects
ON (uploads.model_type='Project' AND uploads.model_id=projects.id)
SQL
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def self.hashed_attachments_relation
Upload.joins(<<~SQL).where('projects.storage_version >= :version', version: Project::HASHED_STORAGE_FEATURES[:attachments])
JOIN projects
ON (uploads.model_type='Project' AND uploads.model_id=projects.id)
SQL
end
+ # rubocop: enable CodeReuse/ActiveRecord
def self.relation_summary(relation_name, relation)
relation_count = relation.count
@@ -62,6 +68,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def self.listing(relation_name, relation)
relation_count = relation_summary(relation_name, relation)
return unless relation_count > 0
@@ -78,6 +85,7 @@ module Gitlab
break if index + 1 >= limit
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/health_checks/redis/cache_check.rb b/lib/gitlab/health_checks/redis/cache_check.rb
index 0eb9b77634a..2f6c4db12bb 100644
--- a/lib/gitlab/health_checks/redis/cache_check.rb
+++ b/lib/gitlab/health_checks/redis/cache_check.rb
@@ -19,11 +19,13 @@ module Gitlab
result == 'PONG'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def check
catch_timeout 10.seconds do
Gitlab::Redis::Cache.with(&:ping)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/health_checks/redis/queues_check.rb b/lib/gitlab/health_checks/redis/queues_check.rb
index f322fe831b8..63d2882c5b2 100644
--- a/lib/gitlab/health_checks/redis/queues_check.rb
+++ b/lib/gitlab/health_checks/redis/queues_check.rb
@@ -19,11 +19,13 @@ module Gitlab
result == 'PONG'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def check
catch_timeout 10.seconds do
Gitlab::Redis::Queues.with(&:ping)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/health_checks/redis/shared_state_check.rb b/lib/gitlab/health_checks/redis/shared_state_check.rb
index 07e6f707998..f1ea1ffe1be 100644
--- a/lib/gitlab/health_checks/redis/shared_state_check.rb
+++ b/lib/gitlab/health_checks/redis/shared_state_check.rb
@@ -19,11 +19,13 @@ module Gitlab
result == 'PONG'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def check
catch_timeout 10.seconds do
Gitlab::Redis::SharedState.with(&:ping)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/identifier.rb b/lib/gitlab/identifier.rb
index 3f3f10596c5..a8b93f1d4b2 100644
--- a/lib/gitlab/identifier.rb
+++ b/lib/gitlab/identifier.rb
@@ -28,6 +28,7 @@ module Gitlab
end
# Tries to identify a user based on a user identifier (e.g. "user-123").
+ # rubocop: disable CodeReuse/ActiveRecord
def identify_using_user(identifier)
user_id = identifier.gsub("user-", "")
@@ -35,6 +36,7 @@ module Gitlab
User.find_by(id: user_id)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Tries to identify a user based on an SSH key identifier (e.g. "key-123").
def identify_using_ssh_key(identifier)
diff --git a/lib/gitlab/import/database_helpers.rb b/lib/gitlab/import/database_helpers.rb
index 80857061933..5b3f30d894a 100644
--- a/lib/gitlab/import/database_helpers.rb
+++ b/lib/gitlab/import/database_helpers.rb
@@ -8,6 +8,7 @@ module Gitlab
# attributes - The attributes/columns to set.
# relation - An ActiveRecord::Relation to use for finding the ID of the row
# when using MySQL.
+ # rubocop: disable CodeReuse/ActiveRecord
def insert_and_return_id(attributes, relation)
# We use bulk_insert here so we can bypass any queries executed by
# callbacks or validation rules, as doing this wouldn't scale when
@@ -20,6 +21,7 @@ module Gitlab
result.first ||
relation.where(iid: attributes[:iid]).limit(1).pluck(:id).first
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/import/merge_request_helpers.rb b/lib/gitlab/import/merge_request_helpers.rb
index 8ba70700dc1..97dc1a987c4 100644
--- a/lib/gitlab/import/merge_request_helpers.rb
+++ b/lib/gitlab/import/merge_request_helpers.rb
@@ -5,6 +5,7 @@ module Gitlab
module MergeRequestHelpers
include DatabaseHelpers
+ # rubocop: disable CodeReuse/ActiveRecord
def create_merge_request_without_hooks(project, attributes, iid)
# This work must be wrapped in a transaction as otherwise we can leave
# behind incomplete data in the event of an error. This can then lead
@@ -39,7 +40,9 @@ module Gitlab
# existing row.
[project.merge_requests.find_by(iid: iid), true]
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def insert_or_replace_git_data(merge_request, source_branch_sha, target_branch_sha, already_exists = false)
# These fields are set so we can create the correct merge request
# diffs.
@@ -65,6 +68,7 @@ module Gitlab
diff.save
diff.save_git_content
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/legacy_github_import/base_formatter.rb b/lib/gitlab/legacy_github_import/base_formatter.rb
index 2f07fde406c..11d1300e51e 100644
--- a/lib/gitlab/legacy_github_import/base_formatter.rb
+++ b/lib/gitlab/legacy_github_import/base_formatter.rb
@@ -10,6 +10,7 @@ module Gitlab
@formatter = Gitlab::ImportFormatter.new
end
+ # rubocop: disable CodeReuse/ActiveRecord
def create!
association = project.public_send(project_association) # rubocop:disable GitlabSecurity/PublicSend
@@ -17,6 +18,7 @@ module Gitlab
record.attributes = attributes
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def url
raw_data.url || ''
diff --git a/lib/gitlab/legacy_github_import/importer.rb b/lib/gitlab/legacy_github_import/importer.rb
index b04d678cf98..c5bde681365 100644
--- a/lib/gitlab/legacy_github_import/importer.rb
+++ b/lib/gitlab/legacy_github_import/importer.rb
@@ -113,6 +113,7 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def import_issues
fetch_resources(:issues, repo, state: :all, sort: :created, direction: :asc, per_page: 100) do |issues|
issues.each do |raw|
@@ -133,6 +134,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def import_pull_requests
fetch_resources(:pull_requests, repo, state: :all, sort: :created, direction: :asc, per_page: 100) do |pull_requests|
@@ -193,6 +195,7 @@ module Gitlab
issuable.update_attribute(:label_ids, label_ids)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def import_comments(issuable_type)
resource_type = "#{issuable_type}_comments".to_sym
@@ -213,7 +216,9 @@ module Gitlab
create_comments(comments)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def create_comments(comments)
ActiveRecord::Base.no_touching do
comments.each do |raw|
@@ -238,6 +243,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def discard_inserted_comments(comments, last_note)
last_note_attrs = nil
diff --git a/lib/gitlab/legacy_github_import/issuable_formatter.rb b/lib/gitlab/legacy_github_import/issuable_formatter.rb
index de55382d3ad..7db4a54267e 100644
--- a/lib/gitlab/legacy_github_import/issuable_formatter.rb
+++ b/lib/gitlab/legacy_github_import/issuable_formatter.rb
@@ -55,12 +55,14 @@ module Gitlab
end
end
+ # rubocop: disable CodeReuse/ActiveRecord
def milestone
if raw_data.milestone.present?
milestone = MilestoneFormatter.new(project, raw_data.milestone)
project.milestones.find_by(milestone.find_condition)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/legacy_github_import/label_formatter.rb b/lib/gitlab/legacy_github_import/label_formatter.rb
index c3eed12e739..e9663650903 100644
--- a/lib/gitlab/legacy_github_import/label_formatter.rb
+++ b/lib/gitlab/legacy_github_import/label_formatter.rb
@@ -13,6 +13,7 @@ module Gitlab
:labels
end
+ # rubocop: disable CodeReuse/ActiveRecord
def create!
params = attributes.except(:project)
service = ::Labels::FindOrCreateService.new(nil, project, params)
@@ -22,6 +23,7 @@ module Gitlab
label
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/lib/gitlab/legacy_github_import/user_formatter.rb b/lib/gitlab/legacy_github_import/user_formatter.rb
index 6d8055622f1..3794380e2d0 100644
--- a/lib/gitlab/legacy_github_import/user_formatter.rb
+++ b/lib/gitlab/legacy_github_import/user_formatter.rb
@@ -29,6 +29,7 @@ module Gitlab
.try(:id)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by_external_uid
return nil unless id
@@ -40,6 +41,7 @@ module Gitlab
.first
.try(:id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/multi_collection_paginator.rb b/lib/gitlab/multi_collection_paginator.rb
index fd5de73c526..fab7a43dd30 100644
--- a/lib/gitlab/multi_collection_paginator.rb
+++ b/lib/gitlab/multi_collection_paginator.rb
@@ -53,6 +53,7 @@ module Gitlab
@first_collection_page_count = first_collection_page.total_pages
end
+ # rubocop: disable CodeReuse/ActiveRecord
def first_collection_last_page_size
return @first_collection_last_page_size if defined?(@first_collection_last_page_size)
@@ -60,5 +61,6 @@ module Gitlab
.except(:select)
.size
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/lib/gitlab/otp_key_rotator.rb b/lib/gitlab/otp_key_rotator.rb
index 22332474945..ca5d49eedb9 100644
--- a/lib/gitlab/otp_key_rotator.rb
+++ b/lib/gitlab/otp_key_rotator.rb
@@ -26,6 +26,7 @@ module Gitlab
@filename = filename
end
+ # rubocop: disable CodeReuse/ActiveRecord
def rotate!(old_key:, new_key:)
old_key ||= Gitlab::Application.secrets.otp_key_base
@@ -47,7 +48,9 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def rollback!
ActiveRecord::Base.transaction do
CSV.foreach(filename, headers: HEADERS, return_headers: false) do |row|
@@ -55,6 +58,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb
index 92a308a12dc..fda61000f6a 100644
--- a/lib/gitlab/performance_bar.rb
+++ b/lib/gitlab/performance_bar.rb
@@ -15,6 +15,7 @@ module Gitlab
Gitlab::CurrentSettings.performance_bar_allowed_group_id
end
+ # rubocop: disable CodeReuse/ActiveRecord
def self.allowed_user_ids
Rails.cache.fetch(ALLOWED_USER_IDS_KEY, expires_in: EXPIRY_TIME) do
group = Group.find_by_id(allowed_group_id)
@@ -26,6 +27,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def self.expire_allowed_user_ids_cache
Rails.cache.delete(ALLOWED_USER_IDS_KEY)
diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb
index c5bb4648572..15391b1330b 100644
--- a/lib/gitlab/profiler.rb
+++ b/lib/gitlab/profiler.rb
@@ -34,6 +34,7 @@ module Gitlab
#
# - private_token: instead of providing a user instance, the token can be
# given as a string. Takes precedence over the user option.
+ # rubocop: disable CodeReuse/ActiveRecord
def self.profile(url, logger: nil, post_data: nil, user: nil, private_token: nil)
app = ActionDispatch::Integration::Session.new(Rails.application)
verb = :get
@@ -76,6 +77,7 @@ module Gitlab
result
end
+ # rubocop: enable CodeReuse/ActiveRecord
def self.create_custom_logger(logger, private_token: nil)
return unless logger
@@ -135,6 +137,7 @@ module Gitlab
result
end
+ # rubocop: disable CodeReuse/ActiveRecord
def self.log_load_times_by_model(logger)
return unless logger.respond_to?(:load_times_by_model)
@@ -146,6 +149,7 @@ module Gitlab
logger.info("#{model} total (#{query_count}): #{time.round(2)}ms")
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def self.print_by_total_time(result, options = {})
default_options = { sort_method: :total_time }
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb
index 62f9e538c04..71e9cc7f238 100644
--- a/lib/gitlab/project_search_results.rb
+++ b/lib/gitlab/project_search_results.rb
@@ -29,6 +29,7 @@ module Gitlab
@blobs_count ||= blobs.count
end
+ # rubocop: disable CodeReuse/ActiveRecord
def limited_notes_count
return @limited_notes_count if defined?(@limited_notes_count)
@@ -42,6 +43,7 @@ module Gitlab
@limited_notes_count
end
+ # rubocop: enable CodeReuse/ActiveRecord
def wiki_blobs_count
@wiki_blobs_count ||= wiki_blobs.count
@@ -118,9 +120,11 @@ module Gitlab
@notes ||= notes_finder(nil)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def notes_finder(type)
NotesFinder.new(project, @current_user, search: query, target_type: type).execute.user.order('updated_at DESC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def commits
@commits ||= find_commits(query)
diff --git a/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb b/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
index 8534afcc849..fa86d2dfd6c 100644
--- a/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
+++ b/lib/gitlab/prometheus/queries/additional_metrics_deployment_query.rb
@@ -4,6 +4,7 @@ module Gitlab
class AdditionalMetricsDeploymentQuery < BaseQuery
include QueryAdditionalMetrics
+ # rubocop: disable CodeReuse/ActiveRecord
def query(deployment_id)
Deployment.find_by(id: deployment_id).try do |deployment|
query_metrics(
@@ -17,6 +18,7 @@ module Gitlab
)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
index e3af217b202..09f8f1103d2 100644
--- a/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
+++ b/lib/gitlab/prometheus/queries/additional_metrics_environment_query.rb
@@ -4,6 +4,7 @@ module Gitlab
class AdditionalMetricsEnvironmentQuery < BaseQuery
include QueryAdditionalMetrics
+ # rubocop: disable CodeReuse/ActiveRecord
def query(environment_id)
::Environment.find_by(id: environment_id).try do |environment|
query_metrics(
@@ -13,6 +14,7 @@ module Gitlab
)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/prometheus/queries/deployment_query.rb b/lib/gitlab/prometheus/queries/deployment_query.rb
index c2626581897..3a609a795ba 100644
--- a/lib/gitlab/prometheus/queries/deployment_query.rb
+++ b/lib/gitlab/prometheus/queries/deployment_query.rb
@@ -2,6 +2,7 @@ module Gitlab
module Prometheus
module Queries
class DeploymentQuery < BaseQuery
+ # rubocop: disable CodeReuse/ActiveRecord
def query(deployment_id)
Deployment.find_by(id: deployment_id).try do |deployment|
environment_slug = deployment.environment.slug
@@ -25,6 +26,7 @@ module Gitlab
}
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def self.transform_reactive_result(result)
result[:metrics] = result.delete :data
diff --git a/lib/gitlab/prometheus/queries/environment_query.rb b/lib/gitlab/prometheus/queries/environment_query.rb
index b62910c8de6..4d8b136d7af 100644
--- a/lib/gitlab/prometheus/queries/environment_query.rb
+++ b/lib/gitlab/prometheus/queries/environment_query.rb
@@ -2,6 +2,7 @@ module Gitlab
module Prometheus
module Queries
class EnvironmentQuery < BaseQuery
+ # rubocop: disable CodeReuse/ActiveRecord
def query(environment_id)
::Environment.find_by(id: environment_id).try do |environment|
environment_slug = environment.slug
@@ -19,6 +20,7 @@ module Gitlab
}
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def self.transform_reactive_result(result)
result[:metrics] = result.delete :data
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index 1e45d074e0a..d1cf8e10228 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -62,10 +62,13 @@ module Gitlab
without_count ? collection.without_count : collection
end
+ # rubocop: disable CodeReuse/ActiveRecord
def limited_projects_count
@limited_projects_count ||= projects.limit(count_limit).count
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def limited_issues_count
return @limited_issues_count if @limited_issues_count
@@ -77,14 +80,19 @@ module Gitlab
sum = issues(public_only: true).limit(count_limit).count
@limited_issues_count = sum < count_limit ? issues.limit(count_limit).count : sum
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def limited_merge_requests_count
@limited_merge_requests_count ||= merge_requests.limit(count_limit).count
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def limited_milestones_count
@limited_milestones_count ||= milestones.limit(count_limit).count
end
+ # rubocop: enable CodeReuse/ActiveRecord
def single_commit_result?
false
@@ -100,6 +108,7 @@ module Gitlab
limit_projects.search(query)
end
+ # rubocop: disable CodeReuse/ActiveRecord
def issues(finder_params = {})
issues = IssuesFinder.new(current_user, finder_params).execute
unless default_project_filter
@@ -115,13 +124,17 @@ module Gitlab
issues.reorder('updated_at DESC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def milestones
milestones = Milestone.where(project_id: project_ids_relation)
milestones = milestones.search(query)
milestones.reorder('updated_at DESC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def merge_requests
merge_requests = MergeRequestsFinder.new(current_user).execute
unless default_project_filter
@@ -137,13 +150,16 @@ module Gitlab
merge_requests.reorder('updated_at DESC')
end
+ # rubocop: enable CodeReuse/ActiveRecord
def default_scope
'projects'
end
+ # rubocop: disable CodeReuse/ActiveRecord
def project_ids_relation
limit_projects.select(:id).reorder(nil)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index a17cd27e82d..c6fbdc5ddd9 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -225,6 +225,7 @@ module Gitlab
# Ex.
# remove_keys_not_found_in_db
#
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_keys_not_found_in_db
return unless self.authorized_keys_enabled?
@@ -243,6 +244,7 @@ module Gitlab
end
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
# Iterate over all ssh key IDs from gitlab shell, in batches
#
@@ -326,9 +328,11 @@ module Gitlab
# exists?(storage, 'gitlab')
# exists?(storage, 'gitlab/cookies.git')
#
+ # rubocop: disable CodeReuse/ActiveRecord
def exists?(storage, dir_name)
Gitlab::GitalyClient::NamespaceService.new(storage).exists?(dir_name)
end
+ # rubocop: enable CodeReuse/ActiveRecord
protected
diff --git a/lib/gitlab/slash_commands/base_command.rb b/lib/gitlab/slash_commands/base_command.rb
index 466554e398c..0c76378d51c 100644
--- a/lib/gitlab/slash_commands/base_command.rb
+++ b/lib/gitlab/slash_commands/base_command.rb
@@ -40,9 +40,11 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def find_by_iid(iid)
collection.find_by(iid: iid)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/slash_commands/deploy.rb b/lib/gitlab/slash_commands/deploy.rb
index 93e00ab75a1..b308fd9637f 100644
--- a/lib/gitlab/slash_commands/deploy.rb
+++ b/lib/gitlab/slash_commands/deploy.rb
@@ -36,6 +36,7 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def find_action(from, to)
environment = project.environments.find_by(name: from)
return unless environment
@@ -50,6 +51,7 @@ module Gitlab
actions.first
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/slash_commands/issue_search.rb b/lib/gitlab/slash_commands/issue_search.rb
index acba84b54b4..ee78f0f832e 100644
--- a/lib/gitlab/slash_commands/issue_search.rb
+++ b/lib/gitlab/slash_commands/issue_search.rb
@@ -9,6 +9,7 @@ module Gitlab
"issue search <your query>"
end
+ # rubocop: disable CodeReuse/ActiveRecord
def execute(match)
issues = collection.search(match[:query]).limit(QUERY_LIMIT)
@@ -18,6 +19,7 @@ module Gitlab
Presenters::Access.new(issues).not_found
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/snippet_search_results.rb b/lib/gitlab/snippet_search_results.rb
index 4f86b3e8f73..95e37dfbdab 100644
--- a/lib/gitlab/snippet_search_results.rb
+++ b/lib/gitlab/snippet_search_results.rb
@@ -30,13 +30,17 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def snippet_titles
limit_snippets.search(query).order('updated_at DESC').includes(:author)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def snippet_blobs
limit_snippets.search_code(query).order('updated_at DESC').includes(:author)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def default_scope
'snippet_blobs'
diff --git a/lib/gitlab/string_regex_marker.rb b/lib/gitlab/string_regex_marker.rb
index b19aa6dea35..1c87c56c45e 100644
--- a/lib/gitlab/string_regex_marker.rb
+++ b/lib/gitlab/string_regex_marker.rb
@@ -1,5 +1,6 @@
module Gitlab
class StringRegexMarker < StringRangeMarker
+ # rubocop: disable CodeReuse/ActiveRecord
def mark(regex, group: 0, &block)
ranges = []
@@ -11,5 +12,6 @@ module Gitlab
super(ranges, &block)
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 957908f183d..f7d8ee571cd 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -31,6 +31,7 @@ module Gitlab
end
# rubocop:disable Metrics/AbcSize
+ # rubocop: disable CodeReuse/ActiveRecord
def system_usage_data
{
counts: {
@@ -82,6 +83,7 @@ module Gitlab
}.merge(services_usage)
}
end
+ # rubocop: enable CodeReuse/ActiveRecord
def cycle_analytics_usage_data
Gitlab::CycleAnalytics::UsageData.new.to_json
@@ -112,6 +114,7 @@ module Gitlab
}
end
+ # rubocop: disable CodeReuse/ActiveRecord
def services_usage
types = {
JiraService: :projects_jira_active,
@@ -129,6 +132,7 @@ module Gitlab
rescue ActiveRecord::StatementInvalid
fallback
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/lib/gitlab/user_extractor.rb b/lib/gitlab/user_extractor.rb
index 3ede0a5b5e6..09652a4fb5e 100644
--- a/lib/gitlab/user_extractor.rb
+++ b/lib/gitlab/user_extractor.rb
@@ -14,11 +14,13 @@ module Gitlab
@text = text
end
+ # rubocop: disable CodeReuse/ActiveRecord
def users
return User.none unless @text.present?
@users ||= User.from("(#{union.to_sql}) users")
end
+ # rubocop: enable CodeReuse/ActiveRecord
def usernames
matches[:usernames]
diff --git a/lib/gitlab/verify/uploads.rb b/lib/gitlab/verify/uploads.rb
index 73fc43cb590..201fcc7de7f 100644
--- a/lib/gitlab/verify/uploads.rb
+++ b/lib/gitlab/verify/uploads.rb
@@ -11,9 +11,11 @@ module Gitlab
private
+ # rubocop: disable CodeReuse/ActiveRecord
def all_relation
Upload.all.preload(:model)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def local?(upload)
upload.local?