Skip to content

Move query in MergeRequests::RefreshService as a scope

The following discussion from !22418 (merged) should be addressed:

  • @reprazent started a discussion: (+2 comments)

    Could we move this to scopes, most of them exist already:

    MergeRequest.opened
      .from_project(project)
      .from_source_branches(@push.branch_name)
      .from_fork # NEW: this could be `where(source_project_id <> target_project_id)

    That way, we wouldn't need to disable the cop anymore, as we're touching that anyway 😄.


In !22418 (merged), a query was moved to MergeRequests::RefreshService#merge_requests_for_forks and the CodeReuse/ActiveRecord is disabled.

To re-enable the cop again, we should move this query to a scope in MergeRequest model.