Commit ce44738c authored by Dmitriy Zaporozhets (DZ)'s avatar Dmitriy Zaporozhets (DZ)

Merge branch...

Merge branch '327490-fix-cop-remaining-cop-offenses-for-style-regexpliteralmixedpreserve-d1' into 'master'

Fix offenses for Style/RegexpLiteralMixedPreserve part1

See merge request gitlab-org/gitlab!65360
parents 19ac754d a173249e
...@@ -2443,17 +2443,6 @@ Gitlab/FeatureAvailableUsage: ...@@ -2443,17 +2443,6 @@ Gitlab/FeatureAvailableUsage:
# WIP See https://gitlab.com/gitlab-org/gitlab/-/issues/327490 # WIP See https://gitlab.com/gitlab-org/gitlab/-/issues/327490
Style/RegexpLiteralMixedPreserve: Style/RegexpLiteralMixedPreserve:
Exclude: 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/models/status_page/project_setting.rb'
- 'ee/app/presenters/vulnerability_presenter.rb' - 'ee/app/presenters/vulnerability_presenter.rb'
- 'ee/lib/api/geo_nodes.rb' - 'ee/lib/api/geo_nodes.rb'
......
...@@ -117,7 +117,7 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -117,7 +117,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
# from Redis. # from Redis.
def extract_ref_and_filename(id) def extract_ref_and_filename(id)
path = id.strip path = id.strip
data = path.match(/(.*)\/(.*)/) data = path.match(%r{(.*)/(.*)})
if data if data
[data[1], data[2]] [data[1], data[2]]
......
...@@ -48,7 +48,7 @@ module Ci ...@@ -48,7 +48,7 @@ module Ci
end end
def ci_variable_maskable_regex 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 end
end end
...@@ -210,7 +210,7 @@ module AlertManagement ...@@ -210,7 +210,7 @@ module AlertManagement
end end
def self.link_reference_pattern 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 end
def self.reference_valid?(reference) def self.reference_valid?(reference)
......
...@@ -293,7 +293,7 @@ class ApplicationSetting < ApplicationRecord ...@@ -293,7 +293,7 @@ class ApplicationSetting < ApplicationRecord
validates :user_default_internal_regex, js_regex: true, allow_nil: true validates :user_default_internal_regex, js_regex: true, allow_nil: true
validates :personal_access_token_prefix, 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 '.'") }, 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)') }, length: { maximum: 20, message: _('is too long (maximum is %{count} characters)') },
allow_blank: true allow_blank: true
...@@ -590,7 +590,7 @@ class ApplicationSetting < ApplicationRecord ...@@ -590,7 +590,7 @@ class ApplicationSetting < ApplicationRecord
end end
def sourcegraph_url_is_com? def sourcegraph_url_is_com?
!!(sourcegraph_url =~ /\Ahttps:\/\/(www\.)?sourcegraph\.com/) !!(sourcegraph_url =~ %r{\Ahttps://(www\.)?sourcegraph\.com})
end end
def instance_review_permitted? def instance_review_permitted?
......
...@@ -5,13 +5,13 @@ module BlobViewer ...@@ -5,13 +5,13 @@ module BlobViewer
include ServerSide include ServerSide
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
MODULE_REGEX = / MODULE_REGEX = %r{
\A (?# beginning of file) \A (?# beginning of file)
module\s+ (?# module directive) module\s+ (?# module directive)
(?<name>.*?) (?# module name) (?<name>.*?) (?# module name)
\s*(?:\/\/.*)? (?# comment) \s*(?://.*)? (?# comment)
(?:\n|\z) (?# newline or end of file) (?:\n|\z) (?# newline or end of file)
/x.freeze }x.freeze
self.file_types = %i(go_mod go_sum) self.file_types = %i(go_mod go_sum)
......
...@@ -11,7 +11,7 @@ module Ci ...@@ -11,7 +11,7 @@ module Ci
# * Minimal length of 8 characters # * Minimal length of 8 characters
# * Characters must be from the Base64 alphabet (RFC4648) with the addition of '@', ':', '.', and '~' # * Characters must be from the Base64 alphabet (RFC4648) with the addition of '@', ':', '.', and '~'
# * Absolutely no fun is allowed # * 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 included do
validates :masked, inclusion: { in: [true, false] } validates :masked, inclusion: { in: [true, false] }
......
...@@ -80,7 +80,7 @@ module Operations ...@@ -80,7 +80,7 @@ module Operations
end end
def link_reference_pattern 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 end
def reference_postfix def reference_postfix
......
...@@ -33,7 +33,7 @@ module Packages ...@@ -33,7 +33,7 @@ module Packages
end end
def path_valid?(major) def path_valid?(major)
m = /\/v(\d+)$/i.match(@name) m = %r{/v(\d+)$}i.match(@name)
case major case major
when 0, 1 when 0, 1
......
...@@ -41,7 +41,7 @@ module Packages ...@@ -41,7 +41,7 @@ module Packages
end end
def search_for_single_package(query) 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) full_path = Packages::Conan::Metadatum.full_path_from(package_username: username)
project = Project.find_by_full_path(full_path) project = Project.find_by_full_path(full_path)
return unless Ability.allowed?(current_user, :read_package, project) return unless Ability.allowed?(current_user, :read_package, project)
......
...@@ -65,7 +65,7 @@ module Projects ...@@ -65,7 +65,7 @@ module Projects
# TODO: Support LFS sync over SSH # TODO: Support LFS sync over SSH
# https://gitlab.com/gitlab-org/gitlab/-/issues/249587 # 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? return unless remote_mirror.password_auth?
Lfs::PushService.new( Lfs::PushService.new(
......
...@@ -61,7 +61,7 @@ RspecProfiling.configure do |config| ...@@ -61,7 +61,7 @@ RspecProfiling.configure do |config|
RspecProfiling::Run.prepend(RspecProfilingExt::Run) RspecProfiling::Run.prepend(RspecProfilingExt::Run)
config.collector = RspecProfilingExt::Collectors::CSVWithTimestamps config.collector = RspecProfilingExt::Collectors::CSVWithTimestamps
config.csv_path = -> do 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" "rspec_profiling/#{prefix}#{Time.now.to_i}-#{SecureRandom.hex(8)}-rspec-data.csv"
end end
end end
......
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