diff --git a/.rubocop_todo/rails/negate_include.yml b/.rubocop_todo/rails/negate_include.yml deleted file mode 100644 index 74f469f325b2ffcea0e603bf29ffa006859184e6..0000000000000000000000000000000000000000 --- 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 3c42a1f769f019699e9e8afa5fca4f4b1937fcf1..6b1c52c357e260056b8e9b7d55d4db48cbfc7c85 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -134,7 +134,7 @@ def impossible_visibility_level? 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 f573aa347302337c3d4f7b06aa34911d3614244e..4fb53fcc73820e3532039e5dcb2e7f422cada0e4 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -104,7 +104,7 @@ def import_sources_checkboxes(form) 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 d44ba35bb44313ca85eed46c36d10ff271bf47fe..a3fbf78c919429397ae5844664d2cd61a63748ec 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -696,7 +696,7 @@ def project_permissions_settings(project) 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 370dbb104621d84f465ac187c697473b0927aac0..6f8b80aead91c6f9c2b492ae55f8f24288b06dc8 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -96,7 +96,7 @@ def path_breadcrumbs(max_links = 6) 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 88db40bea7f7eede7f7c20f06d2915075e9d6791..815b260f6a3b7504710f4c3bbc74b1d1288a943d 100644 --- a/app/models/integrations/chat_message/pipeline_message.rb +++ b/app/models/integrations/chat_message/pipeline_message.rb @@ -96,7 +96,7 @@ def actually_failed_jobs(builds) 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 53c8f5f623eb6e9b3355bc72b91fb6c3fba7e061..5931a34fca95efeb19f1170deb81276c487ec6c8 100644 --- a/app/models/integrations/field.rb +++ b/app/models/integrations/field.rb @@ -28,7 +28,7 @@ def initialize(name:, integration_class:, type: 'text', api_only: false, **attri 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 aa53c0e0f3fbdf758cb4c31282652d88cff4404c..8637df72fedea27eafdbb7666c9575aefcd45a46 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -285,7 +285,7 @@ def issues_count(user, params = {}) 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 6987bccadcbbd13f7b220c10a2da9c6cd247df29..cccf2c918b02cf83990b3e1caa0b292444799e6c 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -733,7 +733,7 @@ def rebase_async(user_id, skip_ci: false) 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 da07d8dd9fc7ef4a74d9871467aaf13190e62031..ba5b84add7d9b7e39e43e240f68cfdc345421f5b 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -263,7 +263,7 @@ def timebox_format_reference(format = :iid) 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 06352d36215065615fb871b07aaa03c492699e48..afb69149ceade690b4e84268bf7ea951dad6338d 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -235,7 +235,7 @@ def create_todos(users, attributes) ).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 e7906f1fcdd7e93758931e2b6534270d85122fdc..81d90f5feab8d8a246ba2997a461d22c0ac5bab0 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 @@ def linkable_issuables(work_items) 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 51818579ccfd905f0cc50f09290b9c3b244601fb..597f19c7f3c5a8daaf8a9ca28e551f88c555d85c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -525,7 +525,7 @@ class Application < Rails::Application 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 dd5770447c3ff516f23bf440e61fcb86076d7386..2fa354f552e6b73b5c410960f6d0f576872943af 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -938,7 +938,7 @@ 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 ca5a671ef29b751eb177693289ec049af2e54fbd..8f2d01390e146da75a647db9acfe39359243832a 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/ee/app/finders/security/pipeline_vulnerabilities_finder.rb b/ee/app/finders/security/pipeline_vulnerabilities_finder.rb index d334150843a0e11fd0b8f68e097794c2710b276b..0b8dff4afc9382f517306b9d0c35a0194bb21f39 100644 --- a/ee/app/finders/security/pipeline_vulnerabilities_finder.rb +++ b/ee/app/finders/security/pipeline_vulnerabilities_finder.rb @@ -133,7 +133,7 @@ def filter(findings) next if !include_dismissed? && dismissal_feedback?(finding) next unless confidence_levels.include?(finding.confidence) next unless severity_levels.include?(finding.severity) - next if scanners.present? && !scanners.include?(finding.scanner.external_id) + next if scanners.present? && scanners.exclude?(finding.scanner.external_id) finding end diff --git a/ee/app/models/ee/vulnerability.rb b/ee/app/models/ee/vulnerability.rb index c6ef829bfa9d92b8e5d4a4361af059ed83eda6d3..9e7d004566391df16b6eec0b004daac2b465e9f7 100644 --- a/ee/app/models/ee/vulnerability.rb +++ b/ee/app/models/ee/vulnerability.rb @@ -309,7 +309,7 @@ def order_by(method) def with_keyset_order(arel_function, name, direction, tie_breaker_direction = nil) raise "unknown sort direction given: #{direction}" unless %i[asc desc].include?(direction) - if tie_breaker_direction.present? && !%i[asc desc].include?(tie_breaker_direction) + if tie_breaker_direction.present? && %i[asc desc].exclude?(tie_breaker_direction) raise "unknown tie breaker sort direction given: #{tie_breaker_direction}" end diff --git a/ee/app/services/epic_issues/create_service.rb b/ee/app/services/epic_issues/create_service.rb index ba1de8bdbc661de2f3247da050fded7ab9ba3628..494535607d17d0839a45db31f5eb7b9ed02b9a02 100644 --- a/ee/app/services/epic_issues/create_service.rb +++ b/ee/app/services/epic_issues/create_service.rb @@ -50,7 +50,7 @@ def linkable_issuables(issues) def linkable_issue?(issue) issue.supports_epic? && can?(current_user, :admin_issue, issue.project) && - !previous_related_issuables.include?(issue) + previous_related_issuables.exclude?(issue) end def previous_related_issuables diff --git a/ee/app/services/security/ingestion/tasks/ingest_remediations.rb b/ee/app/services/security/ingestion/tasks/ingest_remediations.rb index 4024e2ffa6684dfa08dbb4dbbdafc6b6911338c9..224a21125313e7cf8a7567865fa03bf3c474662a 100644 --- a/ee/app/services/security/ingestion/tasks/ingest_remediations.rb +++ b/ee/app/services/security/ingestion/tasks/ingest_remediations.rb @@ -97,7 +97,7 @@ def dissassociate_unfound_remediations def new_report_remediations existing_remediation_checksums = existing_remediations.map(&:checksum) - report_remediations.select { |remediation| !existing_remediation_checksums.include?(remediation.checksum) } + report_remediations.select { |remediation| existing_remediation_checksums.exclude?(remediation.checksum) } end def existing_remediations diff --git a/ee/app/services/security/security_orchestration_policies/validate_policy_service.rb b/ee/app/services/security/security_orchestration_policies/validate_policy_service.rb index d35ebef3fb6de2334821b30014c706dc527c05e4..48c0236ae770df07f707492106680cd9f952498f 100644 --- a/ee/app/services/security/security_orchestration_policies/validate_policy_service.rb +++ b/ee/app/services/security/security_orchestration_policies/validate_policy_service.rb @@ -30,7 +30,7 @@ def policy_disabled? def invalid_policy_type? return true if policy[:type].blank? - !Security::OrchestrationPolicyConfiguration::AVAILABLE_POLICY_TYPES.include?(policy_type) + Security::OrchestrationPolicyConfiguration::AVAILABLE_POLICY_TYPES.exclude?(policy_type) end def blank_name? diff --git a/lib/api/maven_packages.rb b/lib/api/maven_packages.rb index 638ce6dbedc9a9ce347cbfd2b1f30b5190a54c3a..a82f53cf738deb71bd58ebafbfb03654b4e0d902 100644 --- a/lib/api/maven_packages.rb +++ b/lib/api/maven_packages.rb @@ -107,7 +107,7 @@ def head_request_on_aws_file?(file, supports_direct_download) 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 b75bda51ef37bcf4bba28ff361fb58b28ec39d07..4b7b7d42c7717acd1811d4c1298a8a9b37b2ef6f 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 1879a6c54275ae67ad7c9326ff75c24a2aa7a95e..2b2a7d65d08855cf7680176964996ea27c2d3b84 100644 --- a/lib/gitlab/background_migration/legacy_upload_mover.rb +++ b/lib/gitlab/background_migration/legacy_upload_mover.rb @@ -109,7 +109,7 @@ def move_legacy_diff_file 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 c55615bb83bdb6a46f678ce2e08811419eb1edf6..d3cc9337fd9ba861e2cdd01d25efdb277168971e 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 @@ def pattern_match?(glob, path) # 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 ddd9c80f5ea224ff7217bcea2770e1c808eae688..eafeaf9d505adf3097734f220f24b646d2ab3d42 100644 --- a/lib/gitlab/ci/parsers/coverage/sax_document.rb +++ b/lib/gitlab/ci/parsers/coverage/sax_document.rb @@ -63,7 +63,7 @@ def parse_line(line) 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 5cee73238ca63c1efab4d60f3145e2e73a34134d..0273a13e6f2ec4b7baa54c59368ebf0e884576f6 100644 --- a/lib/gitlab/ci/queue/metrics.rb +++ b/lib/gitlab/ci/queue/metrics.rb @@ -76,7 +76,7 @@ def increment_queue_operation(operation) 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 @@ def observe_queue_time(metric, runner_type) 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 02f008abf8578858b555d37de57805a6045d314a..dcf2ab9dec888561e48f91fe5d613e22db867103 100644 --- a/lib/gitlab/database/each_database.rb +++ b/lib/gitlab/database/each_database.rb @@ -52,7 +52,7 @@ def with_shared_model_connections(shared_model, selected_databases, &blk) 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 @@ def with_shared_model_connections(shared_model, selected_databases, &blk) 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 e21a88c4e0d198d223f0229c220c97801426e1f3..c41c93b6ec027e82de691d7c4b154ea789a45977 100644 --- a/lib/gitlab/email/handler/create_issue_handler.rb +++ b/lib/gitlab/email/handler/create_issue_handler.rb @@ -73,7 +73,7 @@ def create_issue 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 06365296a76f58e6422d7d83c4f5b8fec72987cb..8b436bb7a29679a15063b88f0a55a7c1d6e876cb 100644 --- a/lib/gitlab/email/handler/service_desk_handler.rb +++ b/lib/gitlab/email/handler/service_desk_handler.rb @@ -186,7 +186,7 @@ def from_address 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 cf06a2729d9b8b9c4602533c578c4ed44b57cc9b..b97a003813d362688a263620245608137ba8d20f 100644 --- a/lib/gitlab/graphql/queries.rb +++ b/lib/gitlab/graphql/queries.rb @@ -78,7 +78,7 @@ def print_operation_definition(op, indent: "") # 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 @@ def print_field(field, indent: '') 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 8c7a6c13246df40d7a7d0eff9ee8411c468beac9..67c6a1f064904070197088ab7cef8833cba6b3f3 100644 --- a/lib/gitlab/import_export/attributes_permitter.rb +++ b/lib/gitlab/import_export/attributes_permitter.rb @@ -67,7 +67,7 @@ def permitted_attributes_for(relation_sym) 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 37414f9e2b1f260f1be3ac7645474d09733e71b8..8658fa343e23eac2bd3bfe8dfdf15b8e1445a86e 100644 --- a/lib/gitlab/search_results.rb +++ b/lib/gitlab/search_results.rb @@ -144,7 +144,7 @@ def apply_sort(results, scope: nil) 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 54db31ffd6ccce25c656fdbd61e3f329082e1f64..38ad7712e739cad228fa758fefa69f7a2a757457 100644 --- a/lib/gitlab/task_helpers.rb +++ b/lib/gitlab/task_helpers.rb @@ -62,7 +62,7 @@ def prompt(message, choices = nil) 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 1e447923a391f5ff7d817ea81a3bb2ead038930f..f845ffb7ae63b8baaadfa835f88c8558f74ab42a 100644 --- a/lib/gitlab/url_blocker.rb +++ b/lib/gitlab/url_blocker.rb @@ -204,7 +204,7 @@ def validate_port(port, ports) 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 c3e5885249836bcd0ed79215c300c0167491a35a..2a6685375340c13f7ff21453d0263f440be0aaa7 100644 --- a/lib/gitlab_edition.rb +++ b/lib/gitlab_edition.rb @@ -49,7 +49,7 @@ def self.ee? # 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 @@ def self.jh? @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 329bf5f7143607d026c0ffa047745fb0d5cb0884..21ad80b9acecd42cb8bcd3b3edc9cd870461a522 100644 --- a/qa/qa/page/merge_request/show.rb +++ b/qa/qa/page/merge_request/show.rb @@ -366,7 +366,7 @@ def try_to_merge! # 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 fcb6db750bb61cadda6fdd2da449af8cfa97e558..f9a0771ec7537f51a54f800c67b2e64ffb9f4c7f 100644 --- a/qa/qa/runtime/ip_address.rb +++ b/qa/qa/runtime/ip_address.rb @@ -13,7 +13,7 @@ module IPAddress 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 242293f9eefeee6c58409352977d991d8b2b7af5..90fc6733105ffafad1aba4db3bbe0fdc80d37d24 100644 --- a/qa/qa/support/run.rb +++ b/qa/qa/support/run.rb @@ -13,7 +13,7 @@ module Run 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 30d3a82fb1b7cee4ed946063b84a0b29c607fc5b..847a2d19e62fe68a75b22cf951c7a179dd6f5f4a 100644 --- a/qa/qa/tools/delete_test_users.rb +++ b/qa/qa/tools/delete_test_users.rb @@ -22,7 +22,7 @@ def initialize(delete_before: (Date.today - 1).to_s, dry_run: 'false', exclude_u 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 @@ def fetch_test_users 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 fcf4992a19d790e7ce1dded4983507c2ae75f011..16f23bb06c45abc8610b371fbbb94a303e43c95e 100644 --- a/rubocop/cop/gitlab/feature_available_usage.rb +++ b/rubocop/cop/gitlab/feature_available_usage.rb @@ -39,7 +39,7 @@ def on_send(node) 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 eb677aa4507c83316e63f2adeed8fda77d59b8b1..a86c31de2d495d78e318ed93ca92663b1ff6311a 100644 --- a/rubocop/cop/graphql/id_type.rb +++ b/rubocop/cop/graphql/id_type.rb @@ -21,7 +21,7 @@ def on_send(node) 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 02a0ef899b4ae5c8185c756d2b1ce8305b3857ef..6f2648c8f93704803056a6f71a861a5bee722333 100644 --- a/rubocop/cop/migration/add_reference.rb +++ b/rubocop/cop/migration/add_reference.rb @@ -41,7 +41,7 @@ def on_def(node) 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 8d7c73b99a0643a8ffbc37f3965a612d079d25d8..a770dac9794cdc93c94a6514decd918ad84f6457 100644 --- a/rubocop/cop/rspec/factory_bot/inline_association.rb +++ b/rubocop/cop/rspec/factory_bot/inline_association.rb @@ -99,7 +99,7 @@ def on_send(node) 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 556e2037edf14785f92b8995f332b8c45f625d67..a7ca6b7c5df449937aed6dd47b0b4353aeb76fec 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 c6cf09e056be8e2c0d85dabc08ab0f99f5bfe6b1..a346675099aa0bae737b5f95ecf8af16f10e4d03 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 676adc74be2c8a8d62abf08d9f49e8ef7f0a52fc..0f8b894cbd840934028a63b2c02f9a784f5117ad 100644 --- a/spec/lib/container_registry/blob_spec.rb +++ b/spec/lib/container_registry/blob_spec.rb @@ -100,7 +100,7 @@ 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 @@ 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 cb2da24b7123d11e7c71e6735be21ac053c63583..b3e454fdc42c296bf0d8c9fd15aa9968a1843068 100644 --- a/spec/lib/container_registry/client_spec.rb +++ b/spec/lib/container_registry/client_spec.rb @@ -180,7 +180,7 @@ # 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 bb3c8626d32d5329132d87f59eb3eea26d7d23d8..93bb01ce89546a94238a592b3080d2532115d5ec 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 @@ 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 005c1ae2d0aa52963148dafef736648684c05858..540231b8024b3e7847a96f09902553dbcc946439 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 @@ # 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 @@ def sql(query, comments: true) # 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 ecd174edec9bea80709fe3c260c754241a76df9b..25a472e2c2bdcf4fcd46d3d5a81338306b0fd468 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 @@ def html(actual) 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 72e23e6d5faa0f4c7ba11ad3d06d6acae7bf50b1..4d292d265a70e6d342675eca468b4e4e785b26c0 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 @@ 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 a4f6116f7d719afa7679ce10be31b40258def683..9b48f1fdd8e7a697fde9c0e200865bd70aa5e7e3 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -283,7 +283,7 @@ def dynamic_segment # 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 c7baf920314f96e183c8fc6273ec474717b738e1..32e8e40452061e424e44198eacfe8054a6eab4a4 100644 --- a/tooling/danger/specs.rb +++ b/tooling/danger/specs.rb @@ -132,7 +132,7 @@ def comment(comment_text) 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