diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-08-27 18:31:01 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-09-11 18:32:00 +0300 |
commit | 2039c8280db1646845c33d6c5a74e5f23ca6f4de (patch) | |
tree | e2b3cd3012d9711cda7c6afb962ae4228d59521a /app/services/merge_requests | |
parent | 91c40973dc620430b173ea2df968587d2a708dff (diff) |
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.
Diffstat (limited to 'app/services/merge_requests')
6 files changed, 16 insertions, 0 deletions
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 |