From 274eaacae523efb5b162cd01267a0813a65b9db1 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Wed, 27 Dec 2023 23:29:34 +0100 Subject: [PATCH 1/3] Fix subject URL generation on Ruby 3.3 Use an alternative implementation to dasherize subjects, because the regular expression implementation sometimes does not work on Ruby 3.3. This is possibly related to https://bugs.ruby-lang.org/issues/20095. --- lib/reek/documentation_link.rb | 8 +++----- spec/reek/documentation_link_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/reek/documentation_link.rb b/lib/reek/documentation_link.rb index 24ef1ac95..8bcd66112 100644 --- a/lib/reek/documentation_link.rb +++ b/lib/reek/documentation_link.rb @@ -17,12 +17,10 @@ def build(subject) Kernel.format(HELP_LINK_TEMPLATE, version: Version::STRING, item: name_to_param(subject)) end - # Convert the given subject name to a form that is acceptable in a URL. + # Convert the given subject name to a form that is acceptable in a URL, by + # dasherizeing it at the start of capitalized words. Spaces are discared. def name_to_param(name) - # Splits the subject on the start of capitalized words, optionally - # preceded by a space. The space is discarded, the start of the word is - # not. - name.split(/ *(?=[A-Z][a-z])/).join('-') + name.split(/([A-Z][a-z][a-z]*)/).map(&:strip).reject(&:empty?).join('-') end end end diff --git a/spec/reek/documentation_link_spec.rb b/spec/reek/documentation_link_spec.rb index 7c872ec9d..c02e2d42a 100644 --- a/spec/reek/documentation_link_spec.rb +++ b/spec/reek/documentation_link_spec.rb @@ -7,6 +7,12 @@ to eq "https://github.com/troessner/reek/blob/v#{Reek::Version::STRING}/docs/Feature-Envy.md" end + it 'returns the correct link for a smell type with another name' do + expect(described_class.build('UncommunicativeMethodName')). + to eq "https://github.com/troessner/reek/blob/v#{Reek::Version::STRING}" \ + '/docs/Uncommunicative-Method-Name.md' + end + it 'returns the correct link for general documentation' do expect(described_class.build('Rake Task')). to eq "https://github.com/troessner/reek/blob/v#{Reek::Version::STRING}/docs/Rake-Task.md" From a7c0985564bbd5c982ff101989db2dde62de8215 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Wed, 27 Dec 2023 23:39:50 +0100 Subject: [PATCH 2/3] Add bigdecimal gem to silence warnings --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index bc65cd197..405861803 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ ruby RUBY_VERSION group :development do gem 'aruba', '~> 2.1' + gem 'bigdecimal', '>= 2.0.0', '< 4.0' gem 'codeclimate-engine-rb', '~> 0.4.0' gem 'cucumber', '~> 9.0' gem 'kramdown', '~> 2.1' From be810ffbe9b17c29c4b388f457455b4d37bca4dc Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Wed, 27 Dec 2023 23:41:02 +0100 Subject: [PATCH 3/3] Build on Ruby 3.3 in CI --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index f81a92b51..f9fd01fd4 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - ruby: ["2.7", "3.0", "3.1", "3.2", "jruby-9.4"] + ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "jruby-9.4"] steps: - uses: actions/checkout@v4