Commit 682a3c01 authored by Peter Leitzen's avatar Peter Leitzen Committed by Douglas Barbosa Alexandre

Remove `except` from blacklist of `CodeReuse/ActiveRecord`

parent c830aeee
...@@ -84,7 +84,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController ...@@ -84,7 +84,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
end end
def todos_page_count(todos) def todos_page_count(todos)
if todo_params.except(:sort, :page).empty? # rubocop: disable CodeReuse/ActiveRecord if todo_params.except(:sort, :page).empty?
(current_user.todos_pending_count.to_f / todos.limit_value).ceil (current_user.todos_pending_count.to_f / todos.limit_value).ceil
else else
todos.total_pages todos.total_pages
......
...@@ -189,11 +189,9 @@ module DiffHelper ...@@ -189,11 +189,9 @@ module DiffHelper
params[:w] == '1' params[:w] == '1'
end end
# rubocop: disable CodeReuse/ActiveRecord
def params_with_whitespace def params_with_whitespace
hide_whitespace? ? request.query_parameters.except(:w) : request.query_parameters.merge(w: 1) hide_whitespace? ? request.query_parameters.except(:w) : request.query_parameters.merge(w: 1)
end end
# rubocop: enable CodeReuse/ActiveRecord
def toggle_whitespace_link(url, options) def toggle_whitespace_link(url, options)
options[:class] = [*options[:class], 'btn btn-default'].join(' ') options[:class] = [*options[:class], 'btn btn-default'].join(' ')
......
...@@ -235,7 +235,6 @@ module ProjectsHelper ...@@ -235,7 +235,6 @@ module ProjectsHelper
# #
# If no limit is applied we'll just issue a COUNT since the result set could # If no limit is applied we'll just issue a COUNT since the result set could
# be too large to load into memory. # be too large to load into memory.
# rubocop: disable CodeReuse/ActiveRecord
def any_projects?(projects) def any_projects?(projects)
return projects.any? if projects.is_a?(Array) return projects.any? if projects.is_a?(Array)
...@@ -245,7 +244,6 @@ module ProjectsHelper ...@@ -245,7 +244,6 @@ module ProjectsHelper
projects.except(:offset).any? projects.except(:offset).any?
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
# TODO: Remove this method when removing the feature flag # TODO: Remove this method when removing the feature flag
# https://gitlab.com/gitlab-org/gitlab/merge_requests/11209#note_162234863 # https://gitlab.com/gitlab-org/gitlab/merge_requests/11209#note_162234863
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
module SafeParamsHelper module SafeParamsHelper
# Rails 5.0 requires to permit `params` if they're used in url helpers. # Rails 5.0 requires to permit `params` if they're used in url helpers.
# Use this helper when generating links with `params.merge(...)` # Use this helper when generating links with `params.merge(...)`
# rubocop: disable CodeReuse/ActiveRecord
def safe_params def safe_params
if params.respond_to?(:permit!) if params.respond_to?(:permit!)
params.except(:host, :port, :protocol).permit! params.except(:host, :port, :protocol).permit!
...@@ -11,5 +10,4 @@ module SafeParamsHelper ...@@ -11,5 +10,4 @@ module SafeParamsHelper
params params
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
end end
...@@ -6,7 +6,7 @@ module Applications ...@@ -6,7 +6,7 @@ module Applications
def initialize(current_user, params) def initialize(current_user, params)
@current_user = current_user @current_user = current_user
@params = params.except(:ip_address) # rubocop: disable CodeReuse/ActiveRecord @params = params.except(:ip_address)
end end
# EE would override and use `request` arg # EE would override and use `request` arg
......
...@@ -45,11 +45,9 @@ module Issuable ...@@ -45,11 +45,9 @@ module Issuable
original_entity.resource_label_events.find_in_batches do |batch| original_entity.resource_label_events.find_in_batches do |batch|
events = batch.map do |event| events = batch.map do |event|
entity_key = new_entity.is_a?(Issue) ? 'issue_id' : 'epic_id' entity_key = new_entity.is_a?(Issue) ? 'issue_id' : 'epic_id'
# rubocop: disable CodeReuse/ActiveRecord
event.attributes event.attributes
.except('id', 'reference', 'reference_html') .except('id', 'reference', 'reference_html')
.merge(entity_key => new_entity.id, 'action' => ResourceLabelEvent.actions[event.action]) .merge(entity_key => new_entity.id, 'action' => ResourceLabelEvent.actions[event.action])
# rubocop: enable CodeReuse/ActiveRecord
end end
Gitlab::Database.bulk_insert(ResourceLabelEvent.table_name, events) Gitlab::Database.bulk_insert(ResourceLabelEvent.table_name, events)
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
module Milestones module Milestones
class UpdateService < Milestones::BaseService class UpdateService < Milestones::BaseService
# rubocop: disable CodeReuse/ActiveRecord
def execute(milestone) def execute(milestone)
state = params[:state_event] state = params[:state_event]
...@@ -19,7 +18,6 @@ module Milestones ...@@ -19,7 +18,6 @@ module Milestones
milestone milestone
end end
# rubocop: enable CodeReuse/ActiveRecord
end end
end end
......
...@@ -29,7 +29,7 @@ module Projects ...@@ -29,7 +29,7 @@ module Projects
# Getting all Lfs pointers already in the database and linking them to the project # Getting all Lfs pointers already in the database and linking them to the project
linked_oids = LfsLinkService.new(project).execute(lfs_pointers_in_repository.keys) linked_oids = LfsLinkService.new(project).execute(lfs_pointers_in_repository.keys)
# Retrieving those oids not present in the database which we need to download # Retrieving those oids not present in the database which we need to download
missing_oids = lfs_pointers_in_repository.except(*linked_oids) # rubocop: disable CodeReuse/ActiveRecord missing_oids = lfs_pointers_in_repository.except(*linked_oids)
# Downloading the required information and gathering it inside a LfsDownloadObject for each oid # Downloading the required information and gathering it inside a LfsDownloadObject for each oid
LfsDownloadLinkListService.new(project, remote_uri: current_endpoint_uri).execute(missing_oids) LfsDownloadLinkListService.new(project, remote_uri: current_endpoint_uri).execute(missing_oids)
rescue LfsDownloadLinkListService::DownloadLinksError => e rescue LfsDownloadLinkListService::DownloadLinksError => e
......
...@@ -70,7 +70,6 @@ module Projects ...@@ -70,7 +70,6 @@ module Projects
) )
end end
# rubocop: disable CodeReuse/ActiveRecord
def service_hash def service_hash
@service_hash ||= @service_hash ||=
begin begin
...@@ -84,7 +83,6 @@ module Projects ...@@ -84,7 +83,6 @@ module Projects
end end
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def run_callbacks(batch) def run_callbacks(batch)
......
...@@ -7,7 +7,6 @@ module Projects ...@@ -7,7 +7,6 @@ module Projects
ValidationError = Class.new(StandardError) ValidationError = Class.new(StandardError)
# rubocop: disable CodeReuse/ActiveRecord
def execute def execute
remove_unallowed_params remove_unallowed_params
validate! validate!
...@@ -31,7 +30,6 @@ module Projects ...@@ -31,7 +30,6 @@ module Projects
rescue ValidationError => e rescue ValidationError => e
error(e.message) error(e.message)
end end
# rubocop: enable CodeReuse/ActiveRecord
def run_auto_devops_pipeline? def run_auto_devops_pipeline?
return false if project.repository.gitlab_ci_yml || !project.auto_devops&.previous_changes&.include?('enabled') return false if project.repository.gitlab_ci_yml || !project.auto_devops&.previous_changes&.include?('enabled')
......
...@@ -26,10 +26,8 @@ module Releases ...@@ -26,10 +26,8 @@ module Releases
Ability.allowed?(current_user, :update_release, release) Ability.allowed?(current_user, :update_release, release)
end end
# rubocop: disable CodeReuse/ActiveRecord
def empty_params? def empty_params?
params.except(:tag).empty? params.except(:tag).empty?
end end
# rubocop: enable CodeReuse/ActiveRecord
end end
end end
...@@ -57,7 +57,7 @@ module Users ...@@ -57,7 +57,7 @@ module Users
params.reject! { |key, _| read_only.include?(key.to_sym) } params.reject! { |key, _| read_only.include?(key.to_sym) }
end end
@user.assign_attributes(params.except(*identity_attributes)) unless params.empty? # rubocop: disable CodeReuse/ActiveRecord @user.assign_attributes(params.except(*identity_attributes)) unless params.empty?
end end
def assign_identity def assign_identity
......
...@@ -46,7 +46,7 @@ module Projects ...@@ -46,7 +46,7 @@ module Projects
end end
def permitted_params def permitted_params
params.except(*PARAMS_TO_EXCLUDE).permit! # rubocop:disable CodeReuse/ActiveRecord params.except(*PARAMS_TO_EXCLUDE).permit!
end end
end end
end end
......
...@@ -47,7 +47,7 @@ module Security ...@@ -47,7 +47,7 @@ module Security
def normalize_report_occurrences(report_occurrences) def normalize_report_occurrences(report_occurrences)
report_occurrences.map do |report_occurrence| report_occurrences.map do |report_occurrence|
occurrence_hash = report_occurrence.to_hash occurrence_hash = report_occurrence.to_hash
.except(:compare_key, :identifiers, :location, :scanner) # rubocop:disable CodeReuse/ActiveRecord .except(:compare_key, :identifiers, :location, :scanner)
occurrence = Vulnerabilities::Occurrence.new(occurrence_hash) occurrence = Vulnerabilities::Occurrence.new(occurrence_hash)
......
...@@ -37,7 +37,7 @@ module EE ...@@ -37,7 +37,7 @@ module EE
if regenerate_token if regenerate_token
attr[:token] = nil attr[:token] = nil
else else
attr = attr.except(:token) # rubocop: disable CodeReuse/ActiveRecord attr = attr.except(:token)
end end
{ alerting_setting_attributes: attr } { alerting_setting_attributes: attr }
......
...@@ -27,7 +27,7 @@ module Geo ...@@ -27,7 +27,7 @@ module Geo
private private
def payload(status) def payload(status)
status.attributes.except('id') # rubocop: disable CodeReuse/ActiveRecord status.attributes.except('id')
end end
def handle_failure_for(response) def handle_failure_for(response)
......
...@@ -54,7 +54,7 @@ module Security ...@@ -54,7 +54,7 @@ module Security
} }
create_params = occurrence.to_hash create_params = occurrence.to_hash
.except(:compare_key, :identifiers, :location, :scanner) # rubocop: disable CodeReuse/ActiveRecord .except(:compare_key, :identifiers, :location, :scanner)
begin begin
project.vulnerabilities project.vulnerabilities
......
...@@ -89,7 +89,6 @@ module API ...@@ -89,7 +89,6 @@ module API
values: %w(approved blacklisted), values: %w(approved blacklisted),
desc: 'The approval status of the license. "blacklisted" or "approved".' desc: 'The approval status of the license. "blacklisted" or "approved".'
end end
# rubocop: disable CodeReuse/ActiveRecord
patch ':id/managed_licenses/:managed_license_id', requirements: { managed_license_id: /.*/ } do patch ':id/managed_licenses/:managed_license_id', requirements: { managed_license_id: /.*/ } do
authorize_can_admin! authorize_can_admin!
break not_found!('SoftwareLicensePolicy') unless software_license_policy break not_found!('SoftwareLicensePolicy') unless software_license_policy
...@@ -106,7 +105,6 @@ module API ...@@ -106,7 +105,6 @@ module API
render_api_error!(result[:message], result[:http_status]) render_api_error!(result[:message], result[:http_status])
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an existing software license policy from a project' do desc 'Delete an existing software license policy from a project' do
success EE::API::Entities::ManagedLicense success EE::API::Entities::ManagedLicense
......
...@@ -10,7 +10,6 @@ module EE ...@@ -10,7 +10,6 @@ module EE
extend ::Gitlab::Utils::Override extend ::Gitlab::Utils::Override
override :filter_attributes_using_license override :filter_attributes_using_license
# rubocop: disable CodeReuse/ActiveRecord
def filter_attributes_using_license(attrs) def filter_attributes_using_license(attrs)
unless ::License.feature_available?(:repository_mirrors) unless ::License.feature_available?(:repository_mirrors)
attrs = attrs.except(*::EE::ApplicationSettingsHelper.repository_mirror_attributes) attrs = attrs.except(*::EE::ApplicationSettingsHelper.repository_mirror_attributes)
...@@ -30,7 +29,6 @@ module EE ...@@ -30,7 +29,6 @@ module EE
attrs attrs
end end
# rubocop: enable CodeReuse/ActiveRecord
end end
end end
end end
......
...@@ -72,7 +72,6 @@ module EE ...@@ -72,7 +72,6 @@ module EE
parse_params.merge(overwrites) parse_params.merge(overwrites)
end end
# rubocop: disable CodeReuse/ActiveRecord
def parse_params def parse_params
# compact can remove :active if the value for that is nil # compact can remove :active if the value for that is nil
@params.except(:email, :name).compact.each_with_object({}) do |(param, value), hash| @params.except(:email, :name).compact.each_with_object({}) do |(param, value), hash|
...@@ -81,7 +80,6 @@ module EE ...@@ -81,7 +80,6 @@ module EE
hash[attribute] = coerce(value) if attribute hash[attribute] = coerce(value) if attribute
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
def parse_emails def parse_emails
emails = @params[:emails] emails = @params[:emails]
......
...@@ -46,7 +46,6 @@ module API ...@@ -46,7 +46,6 @@ module API
requires :ref, type: String, desc: 'Reference' requires :ref, type: String, desc: 'Reference'
optional :variables, Array, desc: 'Array of variables available in the pipeline' optional :variables, Array, desc: 'Array of variables available in the pipeline'
end end
# rubocop: disable CodeReuse/ActiveRecord
post ':id/pipeline' do post ':id/pipeline' do
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42124') Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42124')
...@@ -67,7 +66,6 @@ module API ...@@ -67,7 +66,6 @@ module API
render_validation_error!(new_pipeline) render_validation_error!(new_pipeline)
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Gets a the latest pipeline for the project branch' do desc 'Gets a the latest pipeline for the project branch' do
detail 'This feature was introduced in GitLab 12.3' detail 'This feature was introduced in GitLab 12.3'
......
...@@ -75,7 +75,7 @@ module API ...@@ -75,7 +75,7 @@ module API
render_api_error!(message, 400) unless obtain_new_cleanup_container_lease render_api_error!(message, 400) unless obtain_new_cleanup_container_lease
CleanupContainerRepositoryWorker.perform_async(current_user.id, repository.id, CleanupContainerRepositoryWorker.perform_async(current_user.id, repository.id,
declared_params.except(:repository_id)) # rubocop: disable CodeReuse/ActiveRecord declared_params.except(:repository_id))
status :accepted status :accepted
end end
......
...@@ -34,7 +34,6 @@ class FileSizeValidator < ActiveModel::EachValidator ...@@ -34,7 +34,6 @@ class FileSizeValidator < ActiveModel::EachValidator
end end
end end
# rubocop: disable CodeReuse/ActiveRecord
def validate_each(record, attribute, value) def validate_each(record, attribute, value)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.is_a? CarrierWave::Uploader::Base raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.is_a? CarrierWave::Uploader::Base
...@@ -65,7 +64,6 @@ class FileSizeValidator < ActiveModel::EachValidator ...@@ -65,7 +64,6 @@ class FileSizeValidator < ActiveModel::EachValidator
record.errors.add(attribute, MESSAGES[key], errors_options) record.errors.add(attribute, MESSAGES[key], errors_options)
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
def help def help
Helper.instance Helper.instance
......
...@@ -132,12 +132,12 @@ module Gitlab ...@@ -132,12 +132,12 @@ module Gitlab
return unless @config.is_a?(Hash) return unless @config.is_a?(Hash)
@jobs_config = @config @jobs_config = @config
.except(*self.class.reserved_nodes_names) # rubocop: disable CodeReuse/ActiveRecord .except(*self.class.reserved_nodes_names)
.select do |name, config| .select do |name, config|
Entry::Jobs.find_type(name, config).present? Entry::Jobs.find_type(name, config).present?
end end
@config = @config.except(*@jobs_config.keys) # rubocop: disable CodeReuse/ActiveRecord @config = @config.except(*@jobs_config.keys)
end end
end end
end end
......
...@@ -15,7 +15,6 @@ module Gitlab ...@@ -15,7 +15,6 @@ module Gitlab
:labels :labels
end end
# rubocop: disable CodeReuse/ActiveRecord
def create! def create!
params = attributes.except(:project) params = attributes.except(:project)
service = ::Labels::FindOrCreateService.new(nil, project, params) service = ::Labels::FindOrCreateService.new(nil, project, params)
...@@ -25,7 +24,6 @@ module Gitlab ...@@ -25,7 +24,6 @@ module Gitlab
label label
end end
# rubocop: enable CodeReuse/ActiveRecord
private private
......
...@@ -55,7 +55,6 @@ module Gitlab ...@@ -55,7 +55,6 @@ module Gitlab
@first_collection_page_count = first_collection_page.total_pages @first_collection_page_count = first_collection_page.total_pages
end end
# rubocop: disable CodeReuse/ActiveRecord
def first_collection_last_page_size def first_collection_last_page_size
return @first_collection_last_page_size if defined?(@first_collection_last_page_size) return @first_collection_last_page_size if defined?(@first_collection_last_page_size)
...@@ -63,6 +62,5 @@ module Gitlab ...@@ -63,6 +62,5 @@ module Gitlab
.except(:select) .except(:select)
.size .size
end end
# rubocop: enable CodeReuse/ActiveRecord
end end
end end
...@@ -27,7 +27,6 @@ module RuboCop ...@@ -27,7 +27,6 @@ module RuboCop
create_with: true, create_with: true,
distinct: false, distinct: false,
eager_load: true, eager_load: true,
except: true,
exists?: true, exists?: true,
find_by: true, find_by: true,
find_by!: true, find_by!: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment