diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index f3d5b18e05c3337168a1d3014a1c9d2b193512ba..091cac8b6305bd4b7cd824bc1b88fd103949f5fc 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -2444,17 +2444,6 @@ Gitlab/FeatureAvailableUsage: # WIP See https://gitlab.com/gitlab-org/gitlab/-/issues/327490 Style/RegexpLiteralMixedPreserve: Exclude: - - 'app/controllers/projects/repositories_controller.rb' - - 'app/helpers/ci/variables_helper.rb' - - 'app/models/alert_management/alert.rb' - - 'app/models/application_setting.rb' - - 'app/models/blob_viewer/go_mod.rb' - - 'app/models/concerns/ci/maskable.rb' - - 'app/models/operations/feature_flag.rb' - - 'app/models/packages/go/module.rb' - - 'app/services/packages/conan/search_service.rb' - - 'app/services/projects/update_remote_mirror_service.rb' - - 'config/initializers/rspec_profiling.rb' - 'ee/app/models/status_page/project_setting.rb' - 'ee/app/presenters/vulnerability_presenter.rb' - 'ee/lib/api/geo_nodes.rb' diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 8f64a8aa1d3764904a0f038d4774f23126d9b3fb..8beebb5298085443e1a385a2b11788cadfe240bc 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -117,7 +117,7 @@ class Projects::RepositoriesController < Projects::ApplicationController # from Redis. def extract_ref_and_filename(id) path = id.strip - data = path.match(/(.*)\/(.*)/) + data = path.match(%r{(.*)/(.*)}) if data [data[1], data[2]] diff --git a/app/helpers/ci/variables_helper.rb b/app/helpers/ci/variables_helper.rb index b20390d58e942cf8760d06c1143a9cc8028e1563..84572363a8d41d4ec5f5a061b9914d21c5db2971 100644 --- a/app/helpers/ci/variables_helper.rb +++ b/app/helpers/ci/variables_helper.rb @@ -48,7 +48,7 @@ module Ci end def ci_variable_maskable_regex - Ci::Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/') + Ci::Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(%r{^/}, '').sub(%r{/[a-z]*$}, '').gsub('\/', '/') end end end diff --git a/app/models/alert_management/alert.rb b/app/models/alert_management/alert.rb index 0cd89f91b1ad3d2f508ef1a9f905910642cc9989..679406e68d764f96419cd5a0bec9c2bfe314f98e 100644 --- a/app/models/alert_management/alert.rb +++ b/app/models/alert_management/alert.rb @@ -210,7 +210,7 @@ module AlertManagement end def self.link_reference_pattern - @link_reference_pattern ||= super("alert_management", /(?<alert>\d+)\/details(\#)?/) + @link_reference_pattern ||= super("alert_management", %r{(?<alert>\d+)/details(\#)?}) end def self.reference_valid?(reference) diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index cbde2db803a39df6b10182880da68b3e700156a8..a7140cc071858d7ab284d3821fa9798878b083fe 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -293,7 +293,7 @@ class ApplicationSetting < ApplicationRecord validates :user_default_internal_regex, js_regex: true, allow_nil: true validates :personal_access_token_prefix, - format: { with: /\A[a-zA-Z0-9_+=\/@:.-]+\z/, + format: { with: %r{\A[a-zA-Z0-9_+=/@:.-]+\z}, message: _("can contain only letters of the Base64 alphabet (RFC4648) with the addition of '@', ':' and '.'") }, length: { maximum: 20, message: _('is too long (maximum is %{count} characters)') }, allow_blank: true @@ -590,7 +590,7 @@ class ApplicationSetting < ApplicationRecord end def sourcegraph_url_is_com? - !!(sourcegraph_url =~ /\Ahttps:\/\/(www\.)?sourcegraph\.com/) + !!(sourcegraph_url =~ %r{\Ahttps://(www\.)?sourcegraph\.com}) end def instance_review_permitted? diff --git a/app/models/blob_viewer/go_mod.rb b/app/models/blob_viewer/go_mod.rb index ae57e2c05268535f7dda8b3c66cfdee27bf2c4ce..d4d117f899c0e0de015b1f9e8df65bff2b251f88 100644 --- a/app/models/blob_viewer/go_mod.rb +++ b/app/models/blob_viewer/go_mod.rb @@ -5,13 +5,13 @@ module BlobViewer include ServerSide include Gitlab::Utils::StrongMemoize - MODULE_REGEX = / + MODULE_REGEX = %r{ \A (?# beginning of file) module\s+ (?# module directive) (?<name>.*?) (?# module name) - \s*(?:\/\/.*)? (?# comment) + \s*(?://.*)? (?# comment) (?:\n|\z) (?# newline or end of file) - /x.freeze + }x.freeze self.file_types = %i(go_mod go_sum) diff --git a/app/models/concerns/ci/maskable.rb b/app/models/concerns/ci/maskable.rb index e1ef453184546ac83b5aee3326b71cd6036c8102..62be0150ee0715f1f587f8f1d0c31b098e5e1494 100644 --- a/app/models/concerns/ci/maskable.rb +++ b/app/models/concerns/ci/maskable.rb @@ -11,7 +11,7 @@ module Ci # * Minimal length of 8 characters # * Characters must be from the Base64 alphabet (RFC4648) with the addition of '@', ':', '.', and '~' # * Absolutely no fun is allowed - REGEX = /\A[a-zA-Z0-9_+=\/@:.~-]{8,}\z/.freeze + REGEX = %r{\A[a-zA-Z0-9_+=/@:.~-]{8,}\z}.freeze included do validates :masked, inclusion: { in: [true, false] } diff --git a/app/models/operations/feature_flag.rb b/app/models/operations/feature_flag.rb index 8b052f80395003d07883b6585a46404245e0c3bb..450a5970ad8b14d9d6c729ddb19e57995fbe2148 100644 --- a/app/models/operations/feature_flag.rb +++ b/app/models/operations/feature_flag.rb @@ -80,7 +80,7 @@ module Operations end def link_reference_pattern - @link_reference_pattern ||= super("feature_flags", /(?<feature_flag>\d+)\/edit/) + @link_reference_pattern ||= super("feature_flags", %r{(?<feature_flag>\d+)/edit}) end def reference_postfix diff --git a/app/models/packages/go/module.rb b/app/models/packages/go/module.rb index 00d51c2188178e712fcf7b4e562d4bad14f5550b..a029437c82d4848dd93dc80f66daaed7c0cef28d 100644 --- a/app/models/packages/go/module.rb +++ b/app/models/packages/go/module.rb @@ -33,7 +33,7 @@ module Packages end def path_valid?(major) - m = /\/v(\d+)$/i.match(@name) + m = %r{/v(\d+)$}i.match(@name) case major when 0, 1 diff --git a/app/services/packages/conan/search_service.rb b/app/services/packages/conan/search_service.rb index 143fd8a627b64e3b56dc0734961ba2bdebd33453..31ee9bea084a775784d95de71d5c5b59828ba764 100644 --- a/app/services/packages/conan/search_service.rb +++ b/app/services/packages/conan/search_service.rb @@ -41,7 +41,7 @@ module Packages end def search_for_single_package(query) - name, version, username, _ = query.split(/[@\/]/) + name, version, username, _ = query.split(%r{[@/]}) full_path = Packages::Conan::Metadatum.full_path_from(package_username: username) project = Project.find_by_full_path(full_path) return unless Ability.allowed?(current_user, :read_package, project) diff --git a/app/services/projects/update_remote_mirror_service.rb b/app/services/projects/update_remote_mirror_service.rb index eac84337967e83edb42103b3f9a2140ea4c6a954..6c29ba81910b0a210e98bfc0f0e80781f1c0465b 100644 --- a/app/services/projects/update_remote_mirror_service.rb +++ b/app/services/projects/update_remote_mirror_service.rb @@ -65,7 +65,7 @@ module Projects # TODO: Support LFS sync over SSH # https://gitlab.com/gitlab-org/gitlab/-/issues/249587 - return unless remote_mirror.url =~ /\Ahttps?:\/\//i + return unless remote_mirror.url =~ %r{\Ahttps?://}i return unless remote_mirror.password_auth? Lfs::PushService.new( diff --git a/config/initializers/rspec_profiling.rb b/config/initializers/rspec_profiling.rb index 1288fad8a94224cf8c6f976da4bb625240496242..5edea6489ed4a2ba5c536f43685556f60fa5d7b9 100644 --- a/config/initializers/rspec_profiling.rb +++ b/config/initializers/rspec_profiling.rb @@ -61,7 +61,7 @@ RspecProfiling.configure do |config| RspecProfiling::Run.prepend(RspecProfilingExt::Run) config.collector = RspecProfilingExt::Collectors::CSVWithTimestamps config.csv_path = -> do - prefix = "#{ENV['CI_JOB_NAME']}-".gsub(/[ \/]/, '-') if ENV['CI_JOB_NAME'] + prefix = "#{ENV['CI_JOB_NAME']}-".gsub(%r{[ /]}, '-') if ENV['CI_JOB_NAME'] "rspec_profiling/#{prefix}#{Time.now.to_i}-#{SecureRandom.hex(8)}-rspec-data.csv" end end