Skip to content

Add cop Style/RegexpLiteralMixedPreserve [RUN AS-IF-FOSS]

Description of the proposal

This MR adds a new 👮 Style/RegexpLiteralMixedPreserve which is based on Style/RegexpLiteral but adds a new EnforcedStyle option mixed_preserve.

See the upstream patch https://github.com/rubocop/rubocop/pull/9688 for more information.

Inspired by !57921 (diffs, comment 542055521).

Example

# bad (inner slash)
path =~ /home\//

# bad (inner slash)
path =~ /
  home\/
/x

# good (inner slash)
path =~ %r{home/}

# good (inner slash)
path =~ %r{
  home/
}x

# good (no inner slash)
regex = /
  foo
  (bar)
  (baz)
/x

# good (no inner slash)
snake_case = /^[\dA-Z_]+$/

# good (no inner slash)
regex = %r{
  foo
  (bar)
  (baz)
}x

It enforces %r{...} only if the regexp contains a slash and AllowInnerSlashes=false.

Why this option?

See "Motivation" in https://github.com/rubocop/rubocop/pull/9688.

Currently, Style/RegexpLiteral allows:

  • /.../ only OR (slashes)
  • %r{...} only OR (percent_r)
  • /.../ for single-line and %r{...} for multi-line (mixed)

There's no way of using %r{...} (without inner slashes) in a single line.

Why a new cop?

I've tried to prepend a patch to the existing cop Style/RegexpLiteral but failed to make RuboCop accept the new option SupportedStyle in .rubocop.yml 😞

Offenses

bundle exec rubocop -P --only Style/RegexpLiteralMixedPreserve:

Inspecting 22615 files

Offenses:

app/controllers/projects/repositories_controller.rb:120:23: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    data = path.match(/(.*)\/(.*)/)
                      ^^^^^^^^^^^^
app/helpers/ci/variables_helper.rb:51:71: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      Ci::Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/')
                                                                      ^^^^^
app/helpers/ci/variables_helper.rb:51:86: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      Ci::Maskable::REGEX.inspect.sub('\\A', '^').sub('\\z', '$').sub(/^\//, '').sub(/\/[a-z]*$/, '').gsub('\/', '/')
                                                                                     ^^^^^^^^^^^
app/models/alert_management/alert.rb:207:61: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      @link_reference_pattern ||= super("alert_management", /(?<alert>\d+)\/details(\#)?/)
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/application_setting.rb:269:29: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
            format: { with: /\A[a-zA-Z0-9_+=\/@:.-]+\z/,
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/application_setting.rb:531:27: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    !!(sourcegraph_url =~ /\Ahttps:\/\/(www\.)?sourcegraph\.com/)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/blob_viewer/go_mod.rb:8:20: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    MODULE_REGEX = / ...
                   ^
app/models/concerns/ci/maskable.rb:14:13: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    REGEX = /\A[a-zA-Z0-9_+=\/@:.-]{8,}\z/.freeze
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/operations/feature_flag.rb:81:60: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        @link_reference_pattern ||= super("feature_flags", /(?<feature_flag>\d+)\/edit/)
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/models/packages/go/module.rb:36:13: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        m = /\/v(\d+)$/i.match(@name)
            ^^^^^^^^^^^^
app/models/project_services/chat_message/base_message.rb:5:27: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    RELATIVE_LINK_REGEX = /!\[[^\]]*\]\((\/uploads\/[^\)]*)\)/.freeze
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/packages/conan/search_service.rb:44:50: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        name, version, username, _ = query.split(/[@\/]/)
                                                 ^^^^^^^
app/services/projects/update_remote_mirror_service.rb:64:42: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      return unless remote_mirror.url =~ /\Ahttps?:\/\//i
                                         ^^^^^^^^^^^^^^^^
config/initializers/rspec_profiling.rb:64:46: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      prefix = "#{ENV['CI_JOB_NAME']}-".gsub(/[ \/]/, '-') if ENV['CI_JOB_NAME']
                                             ^^^^^^^
ee/app/models/status_page/project_setting.rb:8:30: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    AWS_SECRET_KEY_REGEXP  = /\A[A-Za-z0-9\/+=]{40}\z/.freeze
                             ^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/presenters/vulnerability_presenter.rb:74:22: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    path = path.gsub(/^\//, '')
                     ^^^^^
ee/lib/api/geo_nodes.rb:28:45: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        request.put? && request.path.match?(/\/geo_nodes\/\d+/)
                                            ^^^^^^^^^^^^^^^^^^
ee/lib/gitlab/vulnerabilities/standard_vulnerability.rb:34:19: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        path.gsub(/^\//, '')
                  ^^^^^
ee/spec/controllers/concerns/ee/routable_actions/sso_enforcement_redirect_spec.rb:86:51: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(subject.sso_redirect_url).to match(/groups\/#{root_group.to_param}\/-\/saml\/sso\?redirect=#{redirect_url}&token=/)
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/controllers/concerns/routable_actions_spec.rb:46:46: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          expect(response.location).to match(/groups\/.*\/-\/saml\/sso\?redirect=.+&token=/)
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/controllers/groups/groups_controller_spec.rb:93:44: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(response.location).to match(/groups\/#{group.to_param}\/-\/saml\/sso\?redirect=.+&token=/)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/groups/saml_enforcement_spec.rb:29:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(current_url).to match(/groups\/#{group.to_param}\/-\/saml\/sso\?redirect=.+&token=/)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/features/markdown/metrics_spec.rb:84:31: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      stub_prometheus_request(/prometheus\/api\/v1/, body: prometheus_values_body)
                              ^^^^^^^^^^^^^^^^^^^^^
ee/spec/lib/gitlab/database/load_balancing/load_balancer_spec.rb:295:50: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      expect(lb.primary_write_location).to match(/[A-F0-9]{1,8}\/[A-F0-9]{1,8}/)
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/models/project_services/jira_service_spec.rb:180:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          WebMock.stub_request(:get, /api\/2\/project\/GL/).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: project_info_result.to_json )
                                     ^^^^^^^^^^^^^^^^^^^^^
ee/spec/models/project_services/jira_service_spec.rb:181:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          WebMock.stub_request(:get, /api\/2\/project\/GL\z/).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).to_return(body: { 'id' => '10000' }.to_json, headers: headers)
                                     ^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/models/project_services/jira_service_spec.rb:182:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          WebMock.stub_request(:get, /api\/2\/issuetype\z/).to_return(body: issue_types_response.to_json, headers: headers)
                                     ^^^^^^^^^^^^^^^^^^^^^
ee/spec/models/project_services/jira_service_spec.rb:183:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          WebMock.stub_request(:get, /api\/2\/issuetypescheme\/project\?projectId\=10000\z/).to_return(body: issue_type_scheme_response.to_json, headers: headers)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/models/project_services/jira_service_spec.rb:184:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          WebMock.stub_request(:get, /api\/2\/issuetypescheme\/mapping\?issueTypeSchemeId\=10126\z/).to_return(body: issue_type_mapping_response.to_json, headers: headers)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/jira/requests/issues/list_service_spec.rb:41:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        let(:expected_url_pattern) { /.*jira.example.com\/rest\/api\/2\/search.*/ }
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/spec/services/jira/requests/issues/list_service_spec.rb:60:40: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          let(:expected_url_pattern) { /.*jira.example.com\/jira\/rest\/api\/2\/search.*/ }
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/api/invitations.rb:60:62: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        put ":id/invitations/:email", requirements: { email: /[^\/]+/ } do
                                                             ^^^^^^^^
lib/api/invitations.rb:89:65: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        delete ":id/invitations/:email", requirements: { email: /[^\/]+/ } do
                                                                ^^^^^^^^
lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb:14:33: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
              super(regexp.gsub(/\\\//, '/'))
                                ^^^^^^
lib/gitlab/metrics/requests_rack_middleware.rb:16:25: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      HEALTH_ENDPOINT = /^\/-\/(liveness|readiness|health|metrics)\/?$/.freeze
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/metrics/subscribers/active_record.rb:12:44: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        SQL_COMMANDS_WITH_COMMENTS_REGEX = /\A(\/\*.*\*\/\s)?((?!(.*[^\w'"](DELETE|UPDATE|INSERT INTO)[^\w'"])))(WITH.*)?(SELECT)((?!(FOR UPDATE|FOR SHARE)).)*$/i.freeze
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/regex.rb:168:31: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        @go_package_regex ||= / ...
                              ^
lib/gitlab/regex.rb:400:25: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      @base64_regex ||= /(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?/.freeze
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/gitlab/utils.rb:16:20: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      path_regex = /(\A(\.{1,2})\z|\A\.\.[\/\\]|[\/\\]\.\.\z|[\/\\]\.\.[\/\\]|\n)/
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/product_analytics/tracker.rb:9:50: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    COLLECTOR_URL = Gitlab.config.gitlab.url.sub(/\Ahttps?\:\/\//, '') + '/-/collector'
                                                 ^^^^^^^^^^^^^^^^
qa/qa/page/project/settings/advanced.rb:54:46: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
            search_and_select(namespace.gsub(/([^\s])\/([^\s])/, '\1 / \2'))
                                             ^^^^^^^^^^^^^^^^^^
qa/spec/service/docker_run/gitlab_runner_spec.rb:133:59: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
            expect(subject).to have_received(:shell).with(/-v \/var\/run\/docker.sock:\/var\/run\/docker.sock /)
                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
rubocop/cop/gitlab/duplicate_spec_location.rb:28:47: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          path = file_path_for_node(node).sub(/\A#{rails_root}\//, '')
                                              ^^^^^^^^^^^^^^^^^^^
spec/features/clusters/cluster_health_dashboard_spec.rb:85:31: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      stub_prometheus_request(/prometheus\/api\/v1/, status: 204, body: {})
                              ^^^^^^^^^^^^^^^^^^^^^
spec/features/clusters/cluster_health_dashboard_spec.rb:90:31: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      stub_prometheus_request(/prometheus\/api\/v1/, body: prometheus_values_body)
                              ^^^^^^^^^^^^^^^^^^^^^
spec/features/markdown/metrics_spec.rb:179:31: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      stub_prometheus_request(/prometheus\/api\/v1/, body: prometheus_values_body)
                              ^^^^^^^^^^^^^^^^^^^^^
spec/features/search/user_searches_for_code_spec.rb:24:57: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      expect(page).to have_link('application.js', href: /master\/files\/js\/application.js/)
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/search/user_searches_for_code_spec.rb:48:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(current_url).to match(/master\/.gitignore#L3/)
                                     ^^^^^^^^^^^^^^^^^^^^^^^
spec/features/search/user_searches_for_code_spec.rb:66:48: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(find("#L1502")[:href]).to match(/v1.0.0\/files\/markdown\/ruby-style-guide.md#L1502/)
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/snippets/embedded_snippet_spec.rb:30:53: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(page).to have_link('Open raw', href: /-\/snippets\/#{snippet.id}\/raw\/master\/#{blob.path}/)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/features/snippets/embedded_snippet_spec.rb:31:53: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(page).to have_link('Download', href: /-\/snippets\/#{snippet.id}\/raw\/master\/#{blob.path}\?inline=false/)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/helpers/diff_helper_spec.rb:378:32: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      expect(subject).to match(/foo\/bar\/-\/commit\/#{commit.sha}\/diff_for_path/)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/helpers/releases_helper_spec.rb:8:44: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      expect(helper.illustration).to match(/illustrations\/releases-(\w+)\.svg/)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/gitlab/ci/reports/test_case_spec.rb:69:62: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(attachment_test_case.attachment_url).to match(/file\/some\/path.png/)
                                                             ^^^^^^^^^^^^^^^^^^^^^^
spec/lib/gitlab/consul/internal_spec.rb:137:24: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    stub_request(:get, /v1\/catalog\/service\/prometheus/)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/gitlab/import_export/shared_spec.rb:29:46: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        expect(subject.export_path).to match(/#{base_path}\h{32}\/\h{32}/)
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/lib/gitlab/utils/usage_data_spec.rb:380:30: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          stub_request(:get, /\/-\/ready/)
                             ^^^^^^^^^^^^
spec/lib/gitlab/utils/usage_data_spec.rb:390:32: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
            stub_request(:get, /https:\/\/.*/).to_raise(Errno::ECONNREFUSED)
                               ^^^^^^^^^^^^^^
spec/lib/gitlab/utils/usage_data_spec.rb:399:34: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
              stub_request(:get, /http:\/\/.*/).to_raise(Errno::ECONNREFUSED)
                                 ^^^^^^^^^^^^^
spec/lib/gitlab/utils/usage_data_spec.rb:409:30: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          stub_request(:get, /\/-\/ready/)
                             ^^^^^^^^^^^^
spec/presenters/ci/build_runner_presenter_spec.rb:196:35: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      expect(subject[0]).to match(/^\+[0-9a-f]{40}:refs\/pipelines\/[0-9]+$/)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/requests/api/projects_spec.rb:797:32: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
            url = links&.match(/<[^>]+(\/projects\?[^>]+)>; rel="next"/) do |match|
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/requests/api/projects_spec.rb:802:31: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
            url = link&.match(/<[^>]+(\/projects\?[^>]+)>; rel="next"/) do |match|
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/jira/requests/projects/list_service_spec.rb:40:38: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        let(:expected_url_pattern) { /.*jira.example.com\/rest\/api\/2\/project/ }
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/services/jira/requests/projects/list_service_spec.rb:63:40: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
          let(:expected_url_pattern) { /.*jira.example.com\/jira\/rest\/api\/2\/project/ }
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/capybara.rb:197:29: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
        if error.message =~ /unknown command: session\/[0-9a-zA-Z]+(?:\/se)?\/log/
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/helpers/grafana_api_helpers.rb:34:24: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
    stub_request(:any, /#{base_url}\/api\/datasources\/proxy/)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/helpers/query_recorder.rb:28:27: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      matches = sql.match(/,line:(?<line>.*):in\s+`(?<method>.*)'\*\//)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/helpers/require_migration.rb:18:23: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
  SPEC_FILE_PATTERN = /.+\/(?<file_name>.+)_spec\.rb/.freeze
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/shared_examples/models/slack_mattermost_notifications_shared_examples.rb:189:71: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      it_behaves_like 'calls the service API with the event message', / created (.*?)wikis\/(.*?)|wiki page> in/
                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/views/layouts/_head.html.haml_spec.rb:103:33: C: Style/RegexpLiteralMixedPreserve: Use %r around regular expression.
      expect(rendered).to match(/<script.*>.*var u="\/\/#{matomo_host}\/".*<\/script>/m)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

22615 files inspected, 71 offenses detected, 71 offenses auto-correctable
22615 files inspected, 71 offenses detected, 71 offenses auto-correctable

With Style/RegexpLiteral (EnforcedStyle=mixed) we had

22615 files inspected, 218 offenses detected, 218 offenses auto-correctable

Check-list

  • Make sure this MR enables a static analysis check rule for new usage but ignores current offenses
  • Mention this proposal in the relevant Slack channels (e.g. #development, #backend, #frontend)
  • [-] If there is a choice to make between two potential styles, set up an emoji vote in the MR:
    • CHOICE_A: 🅰
    • CHOICE_B: 🅱
    • Vote yourself for both choices so that people know these are the choices
  • The MR doesn't have significant objections, and is getting a majority of 👍 vs 👎 (remember that we don't need to reach a consensus)
  • [-] (If applicable) One style is getting a majority of vote (compared to the other choice)
  • [-] (If applicable) Update the MR with the chosen style
  • Create a follow-up issue to fix the current offenses as a separate iteration: #327490 (closed)
  • Follow the review process as usual
  • Once approved and merged by a maintainer, mention it again:
    • In the relevant Slack channels (e.g. #development, #backend, #frontend)
    • (Optional depending on the impact of the change) In the Engineering Week in Review

Does this MR meet the acceptance criteria?

Conformity

Edited by Mayra Cabrera

Merge request reports