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
Loading
Loading
@@ -30,6 +30,7 @@ class AbuseReportsController < ApplicationController
))
end
 
# rubocop: disable CodeReuse/ActiveRecord
def set_user
@user = User.find_by(id: params[:user_id])
 
Loading
Loading
@@ -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
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])
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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(
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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])
Loading
Loading
Loading
Loading
@@ -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))
Loading
Loading
@@ -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)
 
Loading
Loading
@@ -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
class Admin::JobsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index
@scope = params[:scope]
@all_builds = Ci::Build
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -19,6 +19,7 @@ class Admin::ProjectsController < Admin::ApplicationController
end
end
 
# rubocop: disable CodeReuse/ActiveRecord
def show
if @group
@group_members = present_members(
Loading
Loading
@@ -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)
Loading
Loading
@@ -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)
Loading
Loading
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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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 =
Loading
Loading
@@ -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
Loading
Loading
@@ -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')
Loading
Loading
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])
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
@@ -99,4 +100,5 @@ module AuthenticatesWithTwoFactor
sign_requests: sign_requests })
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
Loading
Loading
@@ -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)
Loading
Loading
@@ -110,6 +111,7 @@ module CreatesCommit
target_branch: @start_branch)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop:enable Gitlab/ModuleWithInstanceVariables
 
def different_project?
Loading
Loading
Loading
Loading
@@ -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?
Loading
Loading
@@ -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]
Loading
Loading
module GroupTree
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# rubocop: disable CodeReuse/ActiveRecord
def render_group_tree(groups)
groups = groups.sort_by_attribute(@sort = params[:sort])
 
Loading
Loading
@@ -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])
 
Loading
Loading
@@ -40,4 +43,5 @@ module GroupTree
filtered_groups
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
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