Commit 461a6b90 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'pl-rubocop-allow-except' into 'master'

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

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