Skip to content
Snippets Groups Projects
Unverified Commit 2039c828 authored by Yorick Peterse's avatar Yorick Peterse
Browse files

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.
parent 91c40973
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Showing
with 52 additions and 0 deletions
# 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
Loading
Loading
@@ -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(
Loading
Loading
@@ -24,6 +25,7 @@ class PasswordsController < Devise::PasswordsController
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
def update
super do |resource|
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -19,4 +20,5 @@ class Profiles::AccountsController < Profiles::ApplicationController
 
redirect_to profile_account_path
end
# rubocop: enable CodeReuse/ActiveRecord
end
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
Loading
Loading
Loading
Loading
@@ -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)
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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]
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -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])
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
 
Loading
Loading
@@ -23,6 +24,7 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
rescue StandardError
head :bad_request
end
# rubocop: enable CodeReuse/ActiveRecord
 
private
 
Loading
Loading
Loading
Loading
@@ -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]
Loading
Loading
@@ -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|
Loading
Loading
@@ -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)
Loading
Loading
@@ -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]
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -32,6 +33,7 @@ class Projects::CommitsController < Projects::ApplicationController
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
def signatures
respond_to do |format|
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -63,6 +64,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
format.json { head :ok }
end
end
# rubocop: enable CodeReuse/ActiveRecord
 
protected
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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?
Loading
Loading
@@ -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])
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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)
 
Loading
Loading
@@ -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])
 
Loading
Loading
@@ -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')
Loading
Loading
Loading
Loading
@@ -161,6 +161,7 @@ class Projects::IssuesController < Projects::ApplicationController
 
protected
 
# rubocop: disable CodeReuse/ActiveRecord
def issue
return @issue if defined?(@issue)
 
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment