From 3ae77b43407b61b5646d62765ec94e9e3c7a1bc5 Mon Sep 17 00:00:00 2001 From: Peter Leitzen Date: Mon, 26 Aug 2024 12:59:15 +0200 Subject: [PATCH 1/2] Run RuboCop with experimental Prism parser This requires to bump the Ruby target version to 3.3. --- .rubocop.yml | 3 ++- Gemfile | 1 + Gemfile.checksum | 2 +- Gemfile.lock | 3 ++- Gemfile.next.checksum | 2 +- Gemfile.next.lock | 3 ++- ee/spec/lib/gitlab/llm/utils/code_suggestion_formatter_spec.rb | 2 +- ee/spec/requests/ee/admin/groups_controller_spec.rb | 2 +- spec/lib/gitlab/encoding_helper_spec.rb | 2 -- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e67a5022d1d948..ad53188f34af40 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -29,7 +29,8 @@ inherit_mode: AllCops: # The oldest supported Ruby version. - TargetRubyVersion: 3.2 + TargetRubyVersion: 3.3 + ParserEngine: parser_prism TargetRailsVersion: 7.0 DefaultFormatter: <%= ENV['CI'] == '1' ? 'clang' : 'progress' %> Exclude: diff --git a/Gemfile b/Gemfile index 3a45a24b241ce3..afb1a531fd4656 100644 --- a/Gemfile +++ b/Gemfile @@ -519,6 +519,7 @@ group :development, :test do gem 'spring', '~> 4.3.0', feature_category: :shared gem 'spring-commands-rspec', '~> 1.0.4', feature_category: :shared + gem 'prism', '~> 1.4.0', feature_category: :tooling gem 'gitlab-styles', '~> 13.1.0', feature_category: :tooling, require: false gem 'haml_lint', '~> 0.58', feature_category: :tooling, require: false diff --git a/Gemfile.checksum b/Gemfile.checksum index 1a4f45f24db954..c682b9111d53f4 100644 --- a/Gemfile.checksum +++ b/Gemfile.checksum @@ -526,7 +526,7 @@ {"name":"premailer-rails","version":"1.12.0","platform":"ruby","checksum":"c13815d161b9bc7f7d3d81396b0bb0a61a90fa9bd89931548bf4e537c7710400"}, {"name":"prettyprint","version":"0.2.0","platform":"ruby","checksum":"2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193"}, {"name":"prime","version":"0.1.3","platform":"ruby","checksum":"baf031c50d6ce923594913befc8ac86a3251bffb9d6a5e8b03687962054e53e3"}, -{"name":"prism","version":"1.2.0","platform":"ruby","checksum":"24ff9cd3232346e68052659f14c9a618022ea98935f774df465206aba5c06d2f"}, +{"name":"prism","version":"1.4.0","platform":"ruby","checksum":"dc0e3e00e93160213dc2a65519d9002a4a1e7b962db57d444cf1a71565bb703e"}, {"name":"proc_to_ast","version":"0.1.0","platform":"ruby","checksum":"92a73fa66e2250a83f8589f818b0751bcf227c68f85916202df7af85082f8691"}, {"name":"prometheus-client-mmap","version":"1.2.10","platform":"aarch64-linux-gnu","checksum":"a014e7748ba72928e58538f155b18479ce315396e9c7ab2115a80ea0a86001ac"}, {"name":"prometheus-client-mmap","version":"1.2.10","platform":"aarch64-linux-musl","checksum":"ba6c4b091c8a249b207ed7e482bcf58095b2631d29c3e51a463ab7f6cc01b8bd"}, diff --git a/Gemfile.lock b/Gemfile.lock index b65917a5f973b6..64c4fba9e51933 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1486,7 +1486,7 @@ GEM prime (0.1.3) forwardable singleton - prism (1.2.0) + prism (1.4.0) proc_to_ast (0.1.0) coderay parser @@ -2317,6 +2317,7 @@ DEPENDENCIES prawn prawn-svg premailer-rails (~> 1.12.0) + prism (~> 1.4.0) prometheus-client-mmap (~> 1.2.8) pry-byebug pry-rails (~> 0.3.9) diff --git a/Gemfile.next.checksum b/Gemfile.next.checksum index 98483921c7f39f..a890159834c77e 100644 --- a/Gemfile.next.checksum +++ b/Gemfile.next.checksum @@ -526,7 +526,7 @@ {"name":"premailer-rails","version":"1.12.0","platform":"ruby","checksum":"c13815d161b9bc7f7d3d81396b0bb0a61a90fa9bd89931548bf4e537c7710400"}, {"name":"prettyprint","version":"0.2.0","platform":"ruby","checksum":"2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193"}, {"name":"prime","version":"0.1.3","platform":"ruby","checksum":"baf031c50d6ce923594913befc8ac86a3251bffb9d6a5e8b03687962054e53e3"}, -{"name":"prism","version":"1.2.0","platform":"ruby","checksum":"24ff9cd3232346e68052659f14c9a618022ea98935f774df465206aba5c06d2f"}, +{"name":"prism","version":"1.4.0","platform":"ruby","checksum":"dc0e3e00e93160213dc2a65519d9002a4a1e7b962db57d444cf1a71565bb703e"}, {"name":"proc_to_ast","version":"0.1.0","platform":"ruby","checksum":"92a73fa66e2250a83f8589f818b0751bcf227c68f85916202df7af85082f8691"}, {"name":"prometheus-client-mmap","version":"1.2.10","platform":"aarch64-linux-gnu","checksum":"a014e7748ba72928e58538f155b18479ce315396e9c7ab2115a80ea0a86001ac"}, {"name":"prometheus-client-mmap","version":"1.2.10","platform":"aarch64-linux-musl","checksum":"ba6c4b091c8a249b207ed7e482bcf58095b2631d29c3e51a463ab7f6cc01b8bd"}, diff --git a/Gemfile.next.lock b/Gemfile.next.lock index 3d1d266f5af951..e8add5c7a2e5ea 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -1480,7 +1480,7 @@ GEM prime (0.1.3) forwardable singleton - prism (1.2.0) + prism (1.4.0) proc_to_ast (0.1.0) coderay parser @@ -2312,6 +2312,7 @@ DEPENDENCIES prawn prawn-svg premailer-rails (~> 1.12.0) + prism (~> 1.4.0) prometheus-client-mmap (~> 1.2.8) pry-byebug pry-rails (~> 0.3.9) diff --git a/ee/spec/lib/gitlab/llm/utils/code_suggestion_formatter_spec.rb b/ee/spec/lib/gitlab/llm/utils/code_suggestion_formatter_spec.rb index 568c35f4168b34..a31accbf8f85e6 100644 --- a/ee/spec/lib/gitlab/llm/utils/code_suggestion_formatter_spec.rb +++ b/ee/spec/lib/gitlab/llm/utils/code_suggestion_formatter_spec.rb @@ -174,7 +174,7 @@ it 'returns the comment without the suggestions' do expect(parse[:from]).to eq <<~FROM - \ + \ first offending line second offending line third offending line diff --git a/ee/spec/requests/ee/admin/groups_controller_spec.rb b/ee/spec/requests/ee/admin/groups_controller_spec.rb index 90d79bb5573695..d1f826a2106e82 100644 --- a/ee/spec/requests/ee/admin/groups_controller_spec.rb +++ b/ee/spec/requests/ee/admin/groups_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Admin::GroupsController, :enable_admin_mode, type: :request, feature_category: :groups_and_projects do +RSpec.describe Admin::GroupsController, :enable_admin_mode, feature_category: :groups_and_projects do let_it_be(:admin) { create(:admin) } before do diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb index db7961fc0c9adf..57f7012c0b4789 100644 --- a/spec/lib/gitlab/encoding_helper_spec.rb +++ b/spec/lib/gitlab/encoding_helper_spec.rb @@ -293,7 +293,6 @@ end # This cop's alternative to .dup doesn't work in this context for some reason. - # rubocop: disable Performance/UnfreezeString describe "#force_encode_utf8" do let(:stringish) do Class.new(String) do @@ -325,5 +324,4 @@ expect(described_class.force_encode_utf8(string)).to eq("bår") end end - # rubocop: enable Performance/UnfreezeString end -- GitLab From 05122b4c3ceb04371f5c3493e71d9f5148f6020c Mon Sep 17 00:00:00 2001 From: Peter Leitzen Date: Fri, 11 Jul 2025 14:46:48 +0200 Subject: [PATCH 2/2] Use HAML's `- ` for `return` statement This sidesteps a syntax error in RuboCop with Prism parser. See https://gitlab.com/gitlab-org/gitlab/-/jobs/7666000648 --- ee/app/views/groups/saml_providers/_test_button.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/app/views/groups/saml_providers/_test_button.html.haml b/ee/app/views/groups/saml_providers/_test_button.html.haml index 978c3117f63642..ffb30338898db4 100644 --- a/ee/app/views/groups/saml_providers/_test_button.html.haml +++ b/ee/app/views/groups/saml_providers/_test_button.html.haml @@ -1,4 +1,4 @@ -= return unless saml_provider.persisted? +- return unless saml_provider.persisted? = saml_link_for_provider _('Verify SAML Configuration'), saml_provider, redirect: ::OmniAuth::Strategies::GroupSaml::VERIFY_SAML_RESPONSE, data: { testid: 'saml-settings-test-button' } = render Pajamas::ButtonComponent.new(button_options: { class: 'gl-hidden', disabled: true }) do -- GitLab