Skip to content

Performance/RegexpMatch: Re-enable rule again and put in grace period

Peter Leitzen requested to merge pl-rubocop-enable-performance-regexp-match into master

What does this MR do and why?

This MR re-enables the 👮 rule Performance/RegexpMatch

This rule has been disabled because its auto-correction wasn't safe. See gitlab-foss!24804 (merged)

It seems that the auto-correction is now safe again. See #417019 (comment 1458046376)

We are following the steps from https://docs.gitlab.com/ee/development/rubocop_development_guide.html#enabling-a-new-cop to enable a 🆕 cop rule.

Offenses

91 files inspected, 111 offenses detected, 111 offenses autocorrectable

Click to expand
Inspecting 91 files
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

Offenses:

app/controllers/concerns/internal_redirect.rb:9:19: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    return unless path =~ %r{\A/[-\w].*\z}
                  ^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/import/bitbucket_server_controller.rb:106:66: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    return render_validation_error('Invalid project key') unless @project_key =~ VALID_BITBUCKET_PROJECT_CHARS
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/import/bitbucket_server_controller.rb:107:70: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    return render_validation_error('Invalid repository slug') unless @repo_slug =~ VALID_BITBUCKET_CHARS
                                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/finders/ci/pipelines_finder.rb:167:17: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      sort = if params[:sort] =~ /\A(ASC|DESC)\z/i
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/helpers/application_helper.rb:351:8: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    if name =~ %r{\Ahttps?://(www\.)?linkedin\.com/in/}
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/helpers/application_helper.rb:360:8: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    if name =~ %r{\Ahttps?://(www\.)?twitter\.com/}
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/helpers/colors_helper.rb:7:68: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    raise ArgumentError, "invalid hex color `#{hex_color}`" unless hex_color =~ HEX_COLOR_PATTERN
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/helpers/emails_helper.rb:44:8: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    if name =~ URI::DEFAULT_PARSER.regexp[:URI_REF]
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/commit_range.rb:67:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    unless range_string =~ /\A#{PATTERN}\z/o
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/commit_status.rb:293:7: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      v =~ /\d+/ ? v.to_i : v
      ^^^^^^^^^^
app/models/concerns/ignorable_columns.rb:21:215: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      raise ArgumentError, 'Please indicate when we can stop ignoring columns with remove_after (date string YYYY-MM-DD), example: ignore_columns(:name, remove_after: \'2019-12-01\', remove_with: \'12.6\')' unless remove_after =~ Gitlab::Regex.utc_date_regex
                                                                                                                                                                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/external_issue.rb:47:24: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    return "##{id}" if id =~ /^\d+$/
                       ^^^^^^^^^^^^^
app/models/hooks/web_hook_log.rb:69:7: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      value.to_s =~ URI::MailTo::EMAIL_REGEXP ? _('[REDACTED]') : value
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/projects/topic.rb:74:21: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      return unless name =~ /\R/
                    ^^^^^^^^^^^^
app/models/repository.rb:841:19: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      next unless item =~ regex
                  ^^^^^^^^^^^^^
app/models/user.rb:1544:39: C: [Correctable] Performance/RegexpMatch: Use match? instead of !~ when MatchData is not used.
    return "http://#{website_url}" if website_url !~ %r{\Ahttps?://}
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/bulk_imports/create_service.rb:108:10: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      if source_full_path =~ /^[0-9]+$/
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/bulk_imports/create_service.rb:157:17: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      return if destination_slug =~ Gitlab::Regex.oci_repository_path_regex
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/clusters/cleanup/project_namespace_service.rb:32:26: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            raise unless e.message =~ /unauthorized|forbidden|certificate verify failed/i
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/clusters/cleanup/service_account_service.rb:30:22: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        raise unless e.message =~ /unauthorized|forbidden|certificate verify failed/i
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/projects/update_remote_mirror_service.rb:96:21: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      return unless remote_mirror.url =~ %r{\Ahttps?://}i
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/uploaders/file_uploader.rb:168:32: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    raise InvalidSecret unless @secret =~ VALID_SECRET_PATTERN
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/validators/abstract_path_validator.rb:24:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    unless value =~ self.class.format_regex
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/validators/cluster_name_validator.rb:19:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      unless value =~ Gitlab::Regex.kubernetes_namespace_regex
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/validators/devise_email_validator.rb:34:51: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    record.errors.add(attribute, :invalid) unless value =~ options[:regexp]
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
app/validators/line_code_validator.rb:10:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    unless value =~ PATTERN
           ^^^^^^^^^^^^^^^^
config/initializers/wikicloth_redos_patch.rb:212:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        if self.element_attributes['href'] =~ /:\/\//
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/controllers/concerns/audit_events/enforces_valid_date_params.rb:28:27: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      return false unless date =~ Gitlab::Regex.utc_date_regex
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/lib/ee/banzai/filter/references/vulnerability_reference_filter.rb:26:28: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            return href if href =~ object_class.reference_pattern
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/lib/elastic/latest/git_class_proxy.rb:65:15: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
              rid =~ /wiki_project_\d+/ ? [rid, rid.gsub(/wiki_project/, 'wiki')] : rid
              ^^^^^^^^^^^^^^^^^^^^^^^^^
ee/lib/gitlab/llm/chain/utils/text_processing.rb:17:29: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
                 .map { |x| x =~ /^(\d)+$/ ? Integer(x) : x }
                            ^^^^^^^^^^^^^^
ee/lib/gitlab/llm/open_ai/response_modifiers/tanuki_bot.rb:22:26: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            sources = if msg =~ NO_ANSWER_REGEX
                         ^^^^^^^^^^^^^^^^^^^^^^
ee/lib/gitlab/middleware/ip_restrictor.rb:11:34: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        return @app.call(env) if env['PATH_INFO'] =~ %r{^/api/v\d+/internal/}
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/spec_helper.rb:18:52: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    metadata[:geo] = metadata.fetch(:geo, true) if location =~ %r{[/_]geo[/_]}
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/helpers.rb:176:10: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      if id.to_s =~ INTEGER_ID_REGEX
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/helpers.rb:212:10: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      if id.to_s =~ INTEGER_ID_REGEX
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/helpers/common_helpers.rb:30:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          if param_type =~ %r(\[\w*\])
             ^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/validations/validators/bulk_imports.rb:10:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
              return if params[attr_name] =~ Gitlab::Regex.group_path_regex
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/validations/validators/bulk_imports.rb:19:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
              return if params[attr_name] =~ Gitlab::Regex.oci_repository_path_regex
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/validations/validators/bulk_imports.rb:36:23: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            return if params[attr_name] =~ Gitlab::Regex.bulk_import_destination_namespace_path_regex
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/validations/validators/bulk_imports.rb:47:23: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            return if params[attr_name] =~ Gitlab::Regex.bulk_import_source_full_path_regex
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/banzai/color_parser.rb:43:15: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      text if COLOR_FORMAT =~ text
              ^^^^^^^^^^^^^^^^^^^^
lib/banzai/filter/ascii_doc_sanitization_filter.rb:80:23: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            return if node['id'] =~ PREFIXED_ID_PATTERN
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/banzai/filter/ascii_doc_sanitization_filter.rb:83:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
              return if node['id'] =~ pattern
                        ^^^^^^^^^^^^^^^^^^^^^
lib/banzai/filter/references/abstract_reference_filter.rb:157:20: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
                if link =~ link_pattern_anchor
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/banzai/filter/references/reference_filter.rb:55:20: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
                if link =~ ref_pattern_start
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
lib/bulk_imports/path_normalization.rb:9:22: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      return path if path =~ Gitlab::Regex.oci_repository_path_regex
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/feature/definition.rb:43:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      unless VALID_FEATURE_NAME =~ name
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/authorized_keys.rb:156:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      unless /\A[a-z0-9-]+\z/ =~ id
             ^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/checks/branch_check.rb:46:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        if branch_name =~ %r{\A\h{40}(/|\z)}
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/ci/build/artifacts/metadata.rb:73:29: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
                next unless path =~ match_pattern
                            ^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/ci/build/artifacts/metadata.rb:74:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
                next if path =~ INVALID_PATH_PATTERN
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/ci/build/artifacts/metadata.rb:93:22: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
              unless version_string =~ VERSION_PATTERN
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/ci/build/artifacts/metadata/entry.rb:105:34: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
                (entry[:size] if path =~ descendant_pattern).to_i
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/ci/project_config/remote.rb:9:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            next unless ci_config_path =~ URI::DEFAULT_PARSER.make_regexp(%w[http https])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_constraint.rb:20:16: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        unless identifier =~ Gitlab::Database::FULLY_QUALIFIED_IDENTIFIER
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_foreign_key.rb:24:16: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        unless identifier =~ Database::FULLY_QUALIFIED_IDENTIFIER
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_foreign_key.rb:34:16: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        unless identifier =~ Database::FULLY_QUALIFIED_IDENTIFIER
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_foreign_key.rb:44:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        if name =~ Database::FULLY_QUALIFIED_IDENTIFIER
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_index.rb:17:16: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        unless identifier =~ Gitlab::Database::FULLY_QUALIFIED_IDENTIFIER
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_partition.rb:13:16: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        unless identifier =~ Gitlab::Database::FULLY_QUALIFIED_IDENTIFIER
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_partition.rb:25:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        if parent_table =~ Database::FULLY_QUALIFIED_IDENTIFIER
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/postgres_partitioned_table.rb:13:16: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        unless identifier =~ Gitlab::Database::FULLY_QUALIFIED_IDENTIFIER
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/database/reindexing/reindex_concurrently.rb:23:104: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          raise ReindexError, 'index is a left-over temporary index from a previous reindexing run' if index.name =~ /#{TEMPORARY_INDEX_PATTERN}/o
                                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/dependency_linker/base_linker.rb:34:19: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        return if external_ref =~ GIT_INVALID_URL_REGEX
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/dependency_linker/composer_json_linker.rb:16:53: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        "https://packagist.org/packages/#{name}" if name =~ /\A#{REPO_REGEX}\z/o
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/diff/parser.rb:28:16: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            if line =~ /^@@ -/
               ^^^^^^^^^^^^^^^
lib/gitlab/email/reply_parser.rb:57:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        if decoded =~ %r{(Content\-Type\:|multipart/alternative|text/plain)}
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/git/gitmodules_parser.rb:53:19: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          next if text =~ /^\s*#/
                  ^^^^^^^^^^^^^^^
lib/gitlab/metrics/samplers/threads_sampler.rb:57:17: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          elsif thread_name =~ /puma threadpool \d+/
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/middleware/sidekiq_web_static.rb:18:47: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        env.delete('HTTP_X_SENDFILE_TYPE') if env['PATH_INFO'] =~ SIDEKIQ_REGEX
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/middleware/static.rb:9:34: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        return @app.call(env) if env['PATH_INFO'] =~ UPLOADS_REGEX
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/url_blocker.rb:261:24: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        return true if url =~ /\n|\r/
                       ^^^^^^^^^^^^^^
lib/gitlab/url_blocker.rb:285:19: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        return if value =~ /\A\p{Alnum}/
                  ^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/url_blocker.rb:293:19: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        return if value =~ /\A\p{Alnum}/
                  ^^^^^^^^^^^^^^^^^^^^^^
lib/tasks/gitlab/update_templates.rake:142:58: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      FileUtils.rm_rf(File.join(directory, file)) unless file =~ regex
                                                         ^^^^^^^^^^^^^
lib/uploaded_file.rb:95:26: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    name = "_#{name}" if name =~ /\A\.+\z/
                         ^^^^^^^^^^^^^^^^^
qa/qa/flow/integrations/slack.rb:44:28: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            break(true) if chat_page.messages.last.text =~ /404 not found!/i
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
qa/qa/git/location.rb:17:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          if git_uri =~ %r{\A(?:ssh|http|https)://}
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
qa/qa/resource/api_fabricator.rb:117:22: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            action = post_body =~ /mutation {\s+destroy/ ? 'Deletion' : 'Fabrication'
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
qa/qa/runtime/search.rb:116:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        if response.code.to_s =~ /5[0-9][0-9]/
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
qa/qa/service/cluster_provider/k3d.rb:57:23: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            config if config =~ /kubeconfig.yaml/
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
qa/qa/specs/spec_helper.rb:113:30: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    non_quarantine_retries = QA::Runtime::Env.ci_project_name =~ /staging|canary|production/ ? 3 : 2
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
qa/qa/tools/ci/ff_changes.rb:53:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          return unless change[:path] =~ %r{/feature_flags/(development|ops)/.*\.yml}
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rubocop/cop/project_path_helper.rb:15:23: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        return unless method_name(node).to_s =~ METHOD_NAME_PATTERN
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rubocop/cop/qa/selector_usage.rb:30:63: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          add_offense(node, message: MESSAGE % node.value) if SELECTORS =~ node.value
                                                              ^^^^^^^^^^^^^^^^^^^^^^^
scripts/changed-feature-flags:45:19: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    return unless File.expand_path(path).to_s =~ %r{/feature_flags/(development|ops)/.*\.yml}
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/failed_tests.rb:51:56: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        hash[suite_name].merge(failed_cases(suite)) if suite['name'] =~ suite_collection_regex
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/lib/glfm/parse_examples.rb:106:27: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          headers = [] if line =~ h1_regex
                          ^^^^^^^^^^^^^^^^
scripts/lib/glfm/update_specification.rb:139:17: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      return if version_line =~ /\Aversion: #{GHFM_SPEC_VERSION}\Z/o
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/lint-docs-blueprints.rb:62:15: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    return if @metadata['creation-date'] =~ /\d{4}-[01]\d-[0123]\d/
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/perf/query_limiting_report.rb:120:15: C: [Correctable] Performance/RegexpMatch: Use match? instead of !~ when MatchData is not used.
      next if filename !~ /\.rb\Z/
              ^^^^^^^^^^^^^^^^^^^^
scripts/perf/query_limiting_report.rb:127:21: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        next unless line =~ /#{CODE_LINES_SEARCH_STRING}/o
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/qa/testcases-check:25:8: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
unless file =~ %r{.*\"examples\":\[\{\"id\"\:.*}
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/qa/testcases-check:36:11: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
  next if test['id'] =~ %r{.\/qa\/specs\/features\/sanity\/*}
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/qa/testcases-check:41:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    unless TESTCASE_FORMAT =~ test['testcase']
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scripts/trigger-build.rb:201:10: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      if raw_version =~ Regexp.compile(/^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sidekiq_cluster/cli.rb:74:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          if queues_or_query_string =~ /[\r\n]/
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/gitlab/cluster/mixins/puma_cluster_spec.rb:101:18: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        break if line =~ output
                 ^^^^^^^^^^^^^^
spec/mailers/emails/in_product_marketing_spec.rb:83:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          if track =~ /(create|verify)/
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/spec_helper.rb:153:44: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    metadata[:enable_admin_mode] = true if location =~ %r{(ee)?/spec/controllers/admin/}
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/capybara.rb:120:45: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
  options.add_argument("--headless") unless ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/helpers/test_env.rb:526:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
    return false unless expected_version =~ ::Gitlab::Git::COMMIT_ID
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/shared_contexts/features/integrations/integrations_shared_context.rb:59:13: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
      elsif k =~ /^(.*_url|url|webhook)/
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/shared_examples/features/discussion_comments_shared_example.rb:287:12: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        if resource_name =~ /(issue|merge request)/
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/shared_examples/features/discussion_comments_shared_example.rb:376:14: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          if resource_name =~ /(issue|merge request)/
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/shared_examples/features/discussion_comments_shared_example.rb:405:6: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
  if resource_name =~ /(issue|merge request)/
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/tooling/quality/test_level_spec.rb:241:17: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        next if path =~ %r{\A(ee/)?spec/(benchmarks|docs_screenshots|fixtures|frontend_integration|support)/}
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tooling/danger/analytics_instrumentation.rb:80:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            next unless mod_line =~ /^\+\s+scope :\w+/
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tooling/danger/database_dictionary.rb:17:54: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
        files.filter_map { |path| Found.new(path) if path =~ DICTIONARY_PATH_REGEXP }
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tooling/danger/specs/feature_category_suggestion.rb:21:25: C: [Correctable] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            next unless changed_line =~ RSPEC_TOP_LEVEL_DESCRIBE_REGEX
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

91 files inspected, 111 offenses detected, 111 offenses autocorrectable

MR train 🚋

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports