diff options
48 files changed, 56 insertions, 112 deletions
diff --git a/.rubocop_todo/rails/negate_include.yml b/.rubocop_todo/rails/negate_include.yml deleted file mode 100644 index 74f469f325b..00000000000 --- a/.rubocop_todo/rails/negate_include.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -# Cop supports --autocorrect. -Rails/NegateInclude: - Details: grace period - Exclude: - - 'app/finders/projects_finder.rb' - - 'app/helpers/application_settings_helper.rb' - - 'app/helpers/projects_helper.rb' - - 'app/helpers/tree_helper.rb' - - 'app/models/integrations/chat_message/pipeline_message.rb' - - 'app/models/integrations/field.rb' - - 'app/models/label.rb' - - 'app/models/merge_request.rb' - - 'app/models/milestone.rb' - - 'app/services/todo_service.rb' - - 'app/services/work_items/parent_links/create_service.rb' - - 'config/application.rb' - - 'config/initializers/1_settings.rb' - - 'danger/roulette/Dangerfile' - - 'ee/app/finders/security/pipeline_vulnerabilities_finder.rb' - - 'ee/app/models/ee/vulnerability.rb' - - 'ee/app/services/epic_issues/create_service.rb' - - 'ee/app/services/security/ingestion/tasks/ingest_remediations.rb' - - 'ee/app/services/security/security_orchestration_policies/validate_policy_service.rb' - - 'lib/api/maven_packages.rb' - - 'lib/gitlab/background_migration/legacy_upload_mover.rb' - - 'lib/gitlab/ci/build/rules/rule/clause/exists.rb' - - 'lib/gitlab/ci/parsers/coverage/sax_document.rb' - - 'lib/gitlab/ci/queue/metrics.rb' - - 'lib/gitlab/database/each_database.rb' - - 'lib/gitlab/email/handler/create_issue_handler.rb' - - 'lib/gitlab/email/handler/service_desk_handler.rb' - - 'lib/gitlab/graphql/queries.rb' - - 'lib/gitlab/import_export/attributes_permitter.rb' - - 'lib/gitlab/search_results.rb' - - 'lib/gitlab/task_helpers.rb' - - 'lib/gitlab/url_blocker.rb' - - 'lib/gitlab_edition.rb' - - 'qa/qa/page/merge_request/show.rb' - - 'qa/qa/runtime/ip_address.rb' - - 'qa/qa/support/run.rb' - - 'qa/qa/tools/delete_test_users.rb' - - 'rubocop/cop/gitlab/feature_available_usage.rb' - - 'rubocop/cop/graphql/id_type.rb' - - 'rubocop/cop/migration/add_reference.rb' - - 'rubocop/cop/rspec/factory_bot/inline_association.rb' - - 'scripts/lib/gitlab.rb' - - 'scripts/static-analysis' - - 'spec/lib/container_registry/blob_spec.rb' - - 'spec/lib/container_registry/client_spec.rb' - - 'spec/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter_spec.rb' - - 'spec/lib/gitlab/metrics/subscribers/active_record_spec.rb' - - 'spec/support/matchers/pushed_frontend_feature_flags_matcher.rb' - - 'spec/support/shared_contexts/markdown_golden_master_shared_examples.rb' - - 'spec/uploaders/object_storage_spec.rb' - - 'tooling/danger/specs.rb' diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb index 3c42a1f769f..6b1c52c357e 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -134,7 +134,7 @@ class ProjectsFinder < UnionFinder public_visibility_levels = Gitlab::VisibilityLevel.levels_for_user(current_user) - !public_visibility_levels.include?(params[:visibility_level].to_i) + public_visibility_levels.exclude?(params[:visibility_level].to_i) end def owned_projects? diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index f573aa34730..4fb53fcc738 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -104,7 +104,7 @@ module ApplicationSettingsHelper def oauth_providers_checkboxes(form) button_based_providers.map do |source| - checked = !@application_setting.disabled_oauth_sign_in_sources.include?(source.to_s) + checked = @application_setting.disabled_oauth_sign_in_sources.exclude?(source.to_s) name = Gitlab::Auth::OAuth::Provider.label_for(source) form.gitlab_ui_checkbox_component( diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index d44ba35bb44..a3fbf78c919 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -696,7 +696,7 @@ module ProjectsHelper def project_allowed_visibility_levels(project) Gitlab::VisibilityLevel.values.select do |level| - project.visibility_level_allowed?(level) && !restricted_levels.include?(level) + project.visibility_level_allowed?(level) && restricted_levels.exclude?(level) end end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 370dbb10462..6f8b80aead9 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -96,7 +96,7 @@ module TreeHelper part_path = File.join(part_path, part) unless part_path.empty? part_path = part if part_path.empty? - next if parts.count > max_links && !parts.last(2).include?(part) + next if parts.count > max_links && parts.last(2).exclude?(part) yield(part, part_path) end diff --git a/app/models/integrations/chat_message/pipeline_message.rb b/app/models/integrations/chat_message/pipeline_message.rb index 88db40bea7f..815b260f6a3 100644 --- a/app/models/integrations/chat_message/pipeline_message.rb +++ b/app/models/integrations/chat_message/pipeline_message.rb @@ -96,7 +96,7 @@ module Integrations failed_jobs = builds.select do |build| # Select jobs which doesn't have a successful retry - build[:status] == 'failed' && !succeeded_job_names.include?(build[:name]) + build[:status] == 'failed' && succeeded_job_names.exclude?(build[:name]) end failed_jobs.uniq { |job| job[:name] }.reverse diff --git a/app/models/integrations/field.rb b/app/models/integrations/field.rb index 53c8f5f623e..5931a34fca9 100644 --- a/app/models/integrations/field.rb +++ b/app/models/integrations/field.rb @@ -28,7 +28,7 @@ module Integrations invalid_attributes = attributes.keys - ATTRIBUTES if invalid_attributes.present? raise ArgumentError, "Invalid attributes #{invalid_attributes.inspect}" - elsif !TYPES.include?(self[:type]) + elsif TYPES.exclude?(self[:type]) raise ArgumentError, "Invalid type #{self[:type].inspect}" end end diff --git a/app/models/label.rb b/app/models/label.rb index aa53c0e0f3f..8637df72fed 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -285,7 +285,7 @@ class Label < ApplicationRecord def label_format_reference(format = :id) raise StandardError, 'Unknown format' unless [:id, :name].include?(format) - if format == :name && !name.include?('"') + if format == :name && name.exclude?('"') %("#{name}") else id diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 6987bccadcb..cccf2c918b0 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -733,7 +733,7 @@ class MergeRequest < ApplicationRecord def merge_participants participants = [author] - if auto_merge_enabled? && !participants.include?(merge_user) + if auto_merge_enabled? && participants.exclude?(merge_user) participants << merge_user end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index da07d8dd9fc..ba5b84add7d 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -263,7 +263,7 @@ class Milestone < ApplicationRecord raise ArgumentError, _('Cannot refer to a group milestone by an internal id!') end - if format == :name && !name.include?('"') + if format == :name && name.exclude?('"') %("#{name}") else iid diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 06352d36215..afb69149cea 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -235,7 +235,7 @@ class TodoService ).distinct_user_ids end - if users_multiple_todos.present? && !Todo::ACTIONS_MULTIPLE_ALLOWED.include?(attributes.fetch(:action)) + if users_multiple_todos.present? && Todo::ACTIONS_MULTIPLE_ALLOWED.exclude?(attributes.fetch(:action)) excluded_user_ids += pending_todos( users_multiple_todos, attributes.slice(:project_id, :target_id, :target_type, :commit_id, :discussion, :action) diff --git a/app/services/work_items/parent_links/create_service.rb b/app/services/work_items/parent_links/create_service.rb index e7906f1fcdd..81d90f5feab 100644 --- a/app/services/work_items/parent_links/create_service.rb +++ b/app/services/work_items/parent_links/create_service.rb @@ -30,7 +30,7 @@ module WorkItems def linkable?(work_item) can?(current_user, :admin_parent_link, work_item) && - !previous_related_issuables.include?(work_item) + previous_related_issuables.exclude?(work_item) end def previous_related_issuables diff --git a/config/application.rb b/config/application.rb index 51818579ccf..597f19c7f3c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -525,7 +525,7 @@ module Gitlab LOOSE_APP_ASSETS = lambda do |logical_path, filename| filename.start_with?(*asset_roots) && - !['.js', '.css', '.md', '.vue', '.graphql', ''].include?(File.extname(logical_path)) + ['.js', '.css', '.md', '.vue', '.graphql', ''].exclude?(File.extname(logical_path)) end app.config.assets.precompile << LOOSE_APP_ASSETS diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index d0a67c13622..0e3f4e8e189 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -932,7 +932,7 @@ Gitlab.ee do Settings.kerberos['https'] = Settings.gitlab.https if Settings.kerberos['https'].nil? Settings.kerberos['port'] ||= Settings.kerberos.https ? 8443 : 8088 - if Settings.kerberos['enabled'] && !Settings.omniauth.providers.map(&:name).include?('kerberos') + if Settings.kerberos['enabled'] && Settings.omniauth.providers.map(&:name).exclude?('kerberos') Settings.omniauth.providers << Settingslogic.new({ 'name' => 'kerberos' }) end end diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index ca5a671ef29..8f2d01390e1 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -96,7 +96,7 @@ categories = Set.new(changes.keys - [:unknown]) categories << :database if helper.mr_labels.include?('database') # Ensure to spin for UX reviewer when ~UX is applied (e.g. to review changes to the UI) except when it's from wider community contribution where we want to assign from the corresponding group -categories << :ux if helper.mr_labels.include?('UX') && !helper.mr_labels.include?('Community contribution') +categories << :ux if helper.mr_labels.include?('UX') && helper.mr_labels.exclude?('Community contribution') # Ensure to spin for Product Intelligence reviewer when ~"product intelligence::review pending" is applied categories << :product_intelligence if helper.mr_labels.include?("product intelligence::review pending") diff --git a/lib/api/maven_packages.rb b/lib/api/maven_packages.rb index 638ce6dbedc..a82f53cf738 100644 --- a/lib/api/maven_packages.rb +++ b/lib/api/maven_packages.rb @@ -107,7 +107,7 @@ module API def fetch_package(file_name:, project: nil, group: nil) order_by_package_file = file_name.include?(::Packages::Maven::Metadata.filename) && - !params[:path].include?(::Packages::Maven::FindOrCreatePackageService::SNAPSHOT_TERM) + params[:path].exclude?(::Packages::Maven::FindOrCreatePackageService::SNAPSHOT_TERM) ::Packages::Maven::PackageFinder.new( current_user, diff --git a/lib/gitlab/background_migration/delete_orphans_approval_merge_request_rules.rb b/lib/gitlab/background_migration/delete_orphans_approval_merge_request_rules.rb index b75bda51ef3..4b7b7d42c77 100644 --- a/lib/gitlab/background_migration/delete_orphans_approval_merge_request_rules.rb +++ b/lib/gitlab/background_migration/delete_orphans_approval_merge_request_rules.rb @@ -4,7 +4,7 @@ module Gitlab module BackgroundMigration # Deletes orphans records whenever report_type equals to scan_finding (i.e., 4) class DeleteOrphansApprovalMergeRequestRules < BatchedMigrationJob - scope_to -> (relation) { relation.where(report_type: 4) } + scope_to ->(relation) { relation.where(report_type: 4) } operation_name :delete_all diff --git a/lib/gitlab/background_migration/legacy_upload_mover.rb b/lib/gitlab/background_migration/legacy_upload_mover.rb index 1879a6c5427..2b2a7d65d08 100644 --- a/lib/gitlab/background_migration/legacy_upload_mover.rb +++ b/lib/gitlab/background_migration/legacy_upload_mover.rb @@ -109,7 +109,7 @@ module Gitlab old_path = upload.absolute_path old_path_sub = '-/system/note/attachment' - if !File.exist?(old_path) || !old_path.include?(old_path_sub) + if !File.exist?(old_path) || old_path.exclude?(old_path_sub) log_legacy_diff_note_problem(old_path) return false end diff --git a/lib/gitlab/ci/build/rules/rule/clause/exists.rb b/lib/gitlab/ci/build/rules/rule/clause/exists.rb index c55615bb83b..d3cc9337fd9 100644 --- a/lib/gitlab/ci/build/rules/rule/clause/exists.rb +++ b/lib/gitlab/ci/build/rules/rule/clause/exists.rb @@ -66,12 +66,12 @@ module Gitlab # matches glob patterns that only match files in the top level directory def top_level_glob?(glob) - !glob.include?('/') && !glob.include?('**') + glob.exclude?('/') && glob.exclude?('**') end # matches glob patterns that have no metacharacters for File#fnmatch? def exact_glob?(glob) - !glob.include?('*') && !glob.include?('?') && !glob.include?('[') && !glob.include?('{') + glob.exclude?('*') && glob.exclude?('?') && glob.exclude?('[') && glob.exclude?('{') end end end diff --git a/lib/gitlab/ci/parsers/coverage/sax_document.rb b/lib/gitlab/ci/parsers/coverage/sax_document.rb index ddd9c80f5ea..eafeaf9d505 100644 --- a/lib/gitlab/ci/parsers/coverage/sax_document.rb +++ b/lib/gitlab/ci/parsers/coverage/sax_document.rb @@ -63,7 +63,7 @@ module Gitlab end def parse_source(node) - return unless project_path && paths && !node.include?(GO_SOURCE_PATTERN) + return unless project_path && paths && node.exclude?(GO_SOURCE_PATTERN) source = build_source_path(node) self.sources << source if source.present? diff --git a/lib/gitlab/ci/queue/metrics.rb b/lib/gitlab/ci/queue/metrics.rb index 5cee73238ca..0273a13e6f2 100644 --- a/lib/gitlab/ci/queue/metrics.rb +++ b/lib/gitlab/ci/queue/metrics.rb @@ -76,7 +76,7 @@ module Gitlab def observe_queue_depth(queue, size) return unless Feature.enabled?(:gitlab_ci_builds_queuing_metrics) - if !Rails.env.production? && !QUEUE_DEPTH_HISTOGRAMS.include?(queue) + if !Rails.env.production? && QUEUE_DEPTH_HISTOGRAMS.exclude?(queue) raise ArgumentError, "unknown queue depth label: #{queue}" end @@ -113,7 +113,7 @@ module Gitlab end def self.increment_queue_operation(operation) - if !Rails.env.production? && !OPERATION_COUNTERS.include?(operation) + if !Rails.env.production? && OPERATION_COUNTERS.exclude?(operation) raise ArgumentError, "unknown queue operation: #{operation}" end diff --git a/lib/gitlab/database/each_database.rb b/lib/gitlab/database/each_database.rb index 02f008abf85..dcf2ab9dec8 100644 --- a/lib/gitlab/database/each_database.rb +++ b/lib/gitlab/database/each_database.rb @@ -52,7 +52,7 @@ module Gitlab next unless shared_model.limit_connection_names.include?(connection_name.to_sym) end - next if selected_databases.present? && !selected_databases.include?(connection_name.to_sym) + next if selected_databases.present? && selected_databases.exclude?(connection_name.to_sym) with_shared_connection(connection_model.connection, connection_name) do yield shared_model, connection_name @@ -63,7 +63,7 @@ module Gitlab def with_model_connection(model, selected_databases, &blk) connection_name = model.connection_db_config.name - return if selected_databases.present? && !selected_databases.include?(connection_name.to_sym) + return if selected_databases.present? && selected_databases.exclude?(connection_name.to_sym) with_shared_connection(model.connection, connection_name) do yield model, connection_name diff --git a/lib/gitlab/email/handler/create_issue_handler.rb b/lib/gitlab/email/handler/create_issue_handler.rb index e21a88c4e0d..c41c93b6ec0 100644 --- a/lib/gitlab/email/handler/create_issue_handler.rb +++ b/lib/gitlab/email/handler/create_issue_handler.rb @@ -73,7 +73,7 @@ module Gitlab end def can_handle_legacy_format? - project_path && !incoming_email_token.include?('+') && !mail_key.include?(Gitlab::Email::Common::UNSUBSCRIBE_SUFFIX_LEGACY) + project_path && incoming_email_token.exclude?('+') && mail_key.exclude?(Gitlab::Email::Common::UNSUBSCRIBE_SUFFIX_LEGACY) end end end diff --git a/lib/gitlab/email/handler/service_desk_handler.rb b/lib/gitlab/email/handler/service_desk_handler.rb index 06365296a76..8b436bb7a29 100644 --- a/lib/gitlab/email/handler/service_desk_handler.rb +++ b/lib/gitlab/email/handler/service_desk_handler.rb @@ -186,7 +186,7 @@ module Gitlab end def can_handle_legacy_format? - project_path && project_path.include?('/') && !mail_key.include?('+') + project_path && project_path.include?('/') && mail_key.exclude?('+') end def author diff --git a/lib/gitlab/graphql/queries.rb b/lib/gitlab/graphql/queries.rb index cf06a2729d9..b97a003813d 100644 --- a/lib/gitlab/graphql/queries.rb +++ b/lib/gitlab/graphql/queries.rb @@ -78,7 +78,7 @@ module Gitlab # remove variable definitions only used in skipped (client) fields vars = op.variables.reject do |v| - @skipped_arguments.include?(v.name) && !@printed_arguments.include?(v.name) + @skipped_arguments.include?(v.name) && @printed_arguments.exclude?(v.name) end if vars.any? @@ -109,7 +109,7 @@ module Gitlab end def print_fragment_definition(fragment_def, indent: "") - if skips? && @skipped_fragments.include?(fragment_def.name) && !@used_fragments.include?(fragment_def.name) + if skips? && @skipped_fragments.include?(fragment_def.name) && @used_fragments.exclude?(fragment_def.name) return '' end diff --git a/lib/gitlab/import_export/attributes_permitter.rb b/lib/gitlab/import_export/attributes_permitter.rb index 8c7a6c13246..67c6a1f0649 100644 --- a/lib/gitlab/import_export/attributes_permitter.rb +++ b/lib/gitlab/import_export/attributes_permitter.rb @@ -67,7 +67,7 @@ module Gitlab end def permitted_attributes_defined?(relation_sym) - !DISABLED_RELATION_NAMES.include?(relation_sym) && @attributes_finder.included_attributes.key?(relation_sym) + DISABLED_RELATION_NAMES.exclude?(relation_sym) && @attributes_finder.included_attributes.key?(relation_sym) end private diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb index 37414f9e2b1..8658fa343e2 100644 --- a/lib/gitlab/search_results.rb +++ b/lib/gitlab/search_results.rb @@ -144,7 +144,7 @@ module Gitlab sort_by = ::Gitlab::Search::SortOptions.sort_and_direction(order_by, sort) # Reset sort to default if the chosen one is not supported by scope - sort_by = nil if SCOPE_ONLY_SORT[sort_by] && !SCOPE_ONLY_SORT[sort_by].include?(scope) + sort_by = nil if SCOPE_ONLY_SORT[sort_by] && SCOPE_ONLY_SORT[sort_by].exclude?(scope) case sort_by when :created_at_asc diff --git a/lib/gitlab/task_helpers.rb b/lib/gitlab/task_helpers.rb index 54db31ffd6c..38ad7712e73 100644 --- a/lib/gitlab/task_helpers.rb +++ b/lib/gitlab/task_helpers.rb @@ -62,7 +62,7 @@ module Gitlab begin print(message) answer = $stdin.gets.chomp - end while choices.present? && !choices.include?(answer) + end while choices.present? && choices.exclude?(answer) answer end diff --git a/lib/gitlab/url_blocker.rb b/lib/gitlab/url_blocker.rb index 1e447923a39..f845ffb7ae6 100644 --- a/lib/gitlab/url_blocker.rb +++ b/lib/gitlab/url_blocker.rb @@ -204,7 +204,7 @@ module Gitlab end def validate_scheme(scheme, schemes) - if scheme.blank? || (schemes.any? && !schemes.include?(scheme)) + if scheme.blank? || (schemes.any? && schemes.exclude?(scheme)) raise BlockedUrlError, "Only allowed schemes are #{schemes.join(', ')}" end end diff --git a/lib/gitlab_edition.rb b/lib/gitlab_edition.rb index c3e58852498..2a668537534 100644 --- a/lib/gitlab_edition.rb +++ b/lib/gitlab_edition.rb @@ -49,7 +49,7 @@ module GitlabEdition # The behavior needs to be synchronised with # config/helpers/is_ee_env.js root.join('ee/app/models/license.rb').exist? && - !%w[true 1].include?(ENV['FOSS_ONLY'].to_s) + !%w[true 1].include?(ENV['FOSS_ONLY'].to_s) # rubocop:disable Rails/NegateInclude end def self.jh? @@ -58,7 +58,7 @@ module GitlabEdition @is_jh = ee? && root.join('jh').exist? && - !%w[true 1].include?(ENV['EE_ONLY'].to_s) + !%w[true 1].include?(ENV['EE_ONLY'].to_s) # rubocop:disable Rails/NegateInclude end def self.ee diff --git a/qa/qa/page/merge_request/show.rb b/qa/qa/page/merge_request/show.rb index 329bf5f7143..21ad80b9ace 100644 --- a/qa/qa/page/merge_request/show.rb +++ b/qa/qa/page/merge_request/show.rb @@ -366,7 +366,7 @@ module QA # Revisit after merge page re-architect is done https://gitlab.com/gitlab-org/gitlab/-/issues/300042 # To remove page refresh logic if possible wait_until_ready_to_merge - wait_until { !find_element(:merge_button).text.include?('when pipeline succeeds') } + wait_until { !find_element(:merge_button).text.include?('when pipeline succeeds') } # rubocop:disable Rails/NegateInclude click_element(:merge_button) end diff --git a/qa/qa/runtime/ip_address.rb b/qa/qa/runtime/ip_address.rb index fcb6db750bb..f9a0771ec75 100644 --- a/qa/qa/runtime/ip_address.rb +++ b/qa/qa/runtime/ip_address.rb @@ -13,7 +13,7 @@ module QA def fetch_current_ip_address # When running on CI against a live environment such as staging.gitlab.com, # we use the public facing IP address - non_test_host = !URI.parse(Scenario.gitlab_address).host.include?('.test') + non_test_host = !URI.parse(Scenario.gitlab_address).host.include?('.test') # rubocop:disable Rails/NegateInclude has_no_public_ip = Env.running_in_ci? || Env.use_public_ip_api? ip_address = if has_no_public_ip && non_test_host diff --git a/qa/qa/support/run.rb b/qa/qa/support/run.rb index 242293f9eef..90fc6733105 100644 --- a/qa/qa/support/run.rb +++ b/qa/qa/support/run.rb @@ -13,7 +13,7 @@ module QA alias_method :to_s, :response def success? - exitstatus == 0 && !response.include?('Error encountered') + exitstatus == 0 && !response.include?('Error encountered') # rubocop:disable Rails/NegateInclude end def to_i diff --git a/qa/qa/tools/delete_test_users.rb b/qa/qa/tools/delete_test_users.rb index 30d3a82fb1b..847a2d19e62 100644 --- a/qa/qa/tools/delete_test_users.rb +++ b/qa/qa/tools/delete_test_users.rb @@ -22,7 +22,7 @@ module QA raise ArgumentError, "Please provide GITLAB_QA_ADMIN_ACCESS_TOKEN" unless ENV['GITLAB_QA_ADMIN_ACCESS_TOKEN'] @api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['GITLAB_QA_ADMIN_ACCESS_TOKEN']) - @dry_run = !FALSY_VALUES.include?(dry_run.to_s.downcase) + @dry_run = FALSY_VALUES.exclude?(dry_run.to_s.downcase) @delete_before = Date.parse(delete_before) @page_no = '1' @exclude_users = Array(exclude_users.to_s.split(',')) + EXCLUDE_USERS @@ -61,7 +61,7 @@ module QA JSON.parse(response.body).select do |user| user['username'].start_with?('qa-user-', 'test-user-') \ && (user['name'] == 'QA Tests' || user['name'].start_with?('QA User')) \ - && !@exclude_users.include?(user['username']) \ + && @exclude_users.exclude?(user['username']) \ && Date.parse(user.fetch('created_at', Date.today.to_s)) < @delete_before end end diff --git a/rubocop/cop/gitlab/feature_available_usage.rb b/rubocop/cop/gitlab/feature_available_usage.rb index fcf4992a19d..16f23bb06c4 100644 --- a/rubocop/cop/gitlab/feature_available_usage.rb +++ b/rubocop/cop/gitlab/feature_available_usage.rb @@ -39,7 +39,7 @@ module RuboCop return if feature_name(node).nil? return if ALL_FEATURES.include?(feature_name(node)) && args_count(node) == 2 - if !ALL_FEATURES.include?(feature_name(node)) + if ALL_FEATURES.exclude?(feature_name(node)) add_offense(node, message: licensed_feature_message(node)) elsif args_count(node) < 2 add_offense(node, message: NOT_ENOUGH_ARGS_MSG) diff --git a/rubocop/cop/graphql/id_type.rb b/rubocop/cop/graphql/id_type.rb index eb677aa4507..a86c31de2d4 100644 --- a/rubocop/cop/graphql/id_type.rb +++ b/rubocop/cop/graphql/id_type.rb @@ -21,7 +21,7 @@ module RuboCop private def does_not_match?(arg) - !WHITELISTED_ARGUMENTS.include?(arg) + WHITELISTED_ARGUMENTS.exclude?(arg) end end end diff --git a/rubocop/cop/migration/add_reference.rb b/rubocop/cop/migration/add_reference.rb index 02a0ef899b4..6f2648c8f93 100644 --- a/rubocop/cop/migration/add_reference.rb +++ b/rubocop/cop/migration/add_reference.rb @@ -41,7 +41,7 @@ module RuboCop private def existing_table?(new_tables, table) - !new_tables.include?(table) + new_tables.exclude?(table) end def create_table?(node) diff --git a/rubocop/cop/rspec/factory_bot/inline_association.rb b/rubocop/cop/rspec/factory_bot/inline_association.rb index 8d7c73b99a0..a770dac9794 100644 --- a/rubocop/cop/rspec/factory_bot/inline_association.rb +++ b/rubocop/cop/rspec/factory_bot/inline_association.rb @@ -99,7 +99,7 @@ module RuboCop def inside_assocation_definition?(node) node.each_ancestor(:block).any? do |parent| name = association_definition(parent) - name && !SKIP_NAMES.include?(name) + name && SKIP_NAMES.exclude?(name) end end end diff --git a/scripts/lib/gitlab.rb b/scripts/lib/gitlab.rb index 556e2037edf..a7ca6b7c5df 100644 --- a/scripts/lib/gitlab.rb +++ b/scripts/lib/gitlab.rb @@ -4,10 +4,10 @@ module Gitlab module_function def ee? - File.exist?(File.expand_path('../../ee/app/models/license.rb', __dir__)) && !%w[true 1].include?(ENV['FOSS_ONLY'].to_s) + File.exist?(File.expand_path('../../ee/app/models/license.rb', __dir__)) && !%w[true 1].include?(ENV['FOSS_ONLY'].to_s) # rubocop:disable Rails/NegateInclude end def jh? - ee? && Dir.exist?(File.expand_path('../../jh', __dir__)) && !%w[true 1].include?(ENV['EE_ONLY'].to_s) + ee? && Dir.exist?(File.expand_path('../../jh', __dir__)) && !%w[true 1].include?(ENV['EE_ONLY'].to_s) # rubocop:disable Rails/NegateInclude end end diff --git a/scripts/static-analysis b/scripts/static-analysis index c6cf09e056b..a346675099a 100755 --- a/scripts/static-analysis +++ b/scripts/static-analysis @@ -134,7 +134,7 @@ class StaticAnalysis def warning_count(static_analysis) static_analysis.warned_results - .count { |result| !ALLOWED_WARNINGS.include?(result.stderr.strip) } + .count { |result| !ALLOWED_WARNINGS.include?(result.stderr.strip) } # rubocop:disable Rails/NegateInclude end def tasks_to_run(node_total) diff --git a/spec/lib/container_registry/blob_spec.rb b/spec/lib/container_registry/blob_spec.rb index 676adc74be2..0f8b894cbd8 100644 --- a/spec/lib/container_registry/blob_spec.rb +++ b/spec/lib/container_registry/blob_spec.rb @@ -100,7 +100,7 @@ RSpec.describe ContainerRegistry::Blob do context 'for a valid address' do before do stub_request(:get, location) - .with { |request| !request.headers.include?('Authorization') } + .with { |request| request.headers.exclude?('Authorization') } .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, @@ -115,7 +115,7 @@ RSpec.describe ContainerRegistry::Blob do context 'for a relative address' do before do stub_request(:get, 'http://registry.gitlab/relative') - .with { |request| !request.headers.include?('Authorization') } + .with { |request| request.headers.exclude?('Authorization') } .to_return( status: 200, headers: { 'Content-Type' => 'application/json' }, diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb index cb2da24b712..b3e454fdc42 100644 --- a/spec/lib/container_registry/client_spec.rb +++ b/spec/lib/container_registry/client_spec.rb @@ -180,7 +180,7 @@ RSpec.describe ContainerRegistry::Client do # https://github.com/bblimke/webmock/blob/master/lib/webmock/matchers/hash_excluding_matcher.rb stub_request(:get, redirect_location) .with(headers: redirect_header) do |request| - !request.headers.include?('Authorization') + request.headers.exclude?('Authorization') end .to_return(status: 200, body: "Successfully redirected") end diff --git a/spec/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter_spec.rb b/spec/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter_spec.rb index bb3c8626d32..93bb01ce895 100644 --- a/spec/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Gitlab::Metrics::Dashboard::Stages::MetricEndpointInserter do transform! expect(all_metrics).to satisfy_all do |metric| - metric[:prometheus_endpoint_path].present? && !metric[:prometheus_endpoint_path].include?("\n") + metric[:prometheus_endpoint_path].present? && metric[:prometheus_endpoint_path].exclude?("\n") end end diff --git a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb index 005c1ae2d0a..540231b8024 100644 --- a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb +++ b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb @@ -219,7 +219,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::ActiveRecord do # Emulate Marginalia pre-pending comments def sql(query, comments: true) - if comments && !%w[BEGIN COMMIT].include?(query) + if comments && %w[BEGIN COMMIT].exclude?(query) "/*application:web,controller:badges,action:pipeline,correlation_id:01EYN39K9VMJC56Z7808N7RSRH*/ #{query}" else query @@ -284,7 +284,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::ActiveRecord do # Emulate Marginalia pre-pending comments def sql(query, comments: true) - if comments && !%w[BEGIN COMMIT].include?(query) + if comments && %w[BEGIN COMMIT].exclude?(query) "/*application:web,controller:badges,action:pipeline,correlation_id:01EYN39K9VMJC56Z7808N7RSRH*/ #{query}" else query diff --git a/spec/support/matchers/pushed_frontend_feature_flags_matcher.rb b/spec/support/matchers/pushed_frontend_feature_flags_matcher.rb index ecd174edec9..25a472e2c2b 100644 --- a/spec/support/matchers/pushed_frontend_feature_flags_matcher.rb +++ b/spec/support/matchers/pushed_frontend_feature_flags_matcher.rb @@ -17,7 +17,7 @@ RSpec::Matchers.define :have_pushed_frontend_feature_flags do |expected| failure_message do |actual| missing = expected.select do |feature_flag_name, enabled| - !html(actual).include?(to_js(feature_flag_name, enabled)) + html(actual).exclude?(to_js(feature_flag_name, enabled)) end formatted_missing_flags = missing.map { |feature_flag_name, enabled| to_js(feature_flag_name, enabled) }.join("\n") diff --git a/spec/support/shared_contexts/markdown_golden_master_shared_examples.rb b/spec/support/shared_contexts/markdown_golden_master_shared_examples.rb index 72e23e6d5fa..4d292d265a7 100644 --- a/spec/support/shared_contexts/markdown_golden_master_shared_examples.rb +++ b/spec/support/shared_contexts/markdown_golden_master_shared_examples.rb @@ -44,7 +44,7 @@ RSpec.shared_context 'API::Markdown Golden Master shared context' do |markdown_y if focused_markdown_examples_string = ENV['FOCUSED_MARKDOWN_EXAMPLES'] focused_markdown_examples = focused_markdown_examples_string.split(',').map(&:strip) || [] - markdown_examples.reject! { |markdown_example| !focused_markdown_examples.include?(markdown_example.fetch(:name)) } + markdown_examples.reject! { |markdown_example| focused_markdown_examples.exclude?(markdown_example.fetch(:name)) } end markdown_examples.each do |markdown_example| diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb index a4f6116f7d7..9b48f1fdd8e 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -283,7 +283,7 @@ RSpec.describe ObjectStorage do # We need to check the Host header not including the port because AWS does not accept stub_request(:get, %r{s3.amazonaws.com/#{uploader.path}}) - .with { |request| !request.headers['Host'].to_s.include?(':443') } + .with { |request| request.headers['Host'].to_s.exclude?(':443') } .to_return(status: 200, body: '') end diff --git a/tooling/danger/specs.rb b/tooling/danger/specs.rb index c7baf920314..32e8e404520 100644 --- a/tooling/danger/specs.rb +++ b/tooling/danger/specs.rb @@ -132,7 +132,7 @@ module Tooling def find_line_number(file_lines, searched_line, exclude_indexes: []) _, index = file_lines.each_with_index.find do |file_line, index| - file_line == searched_line && !exclude_indexes.include?(index) + file_line == searched_line && exclude_indexes.exclude?(index) end index |