Skip to content

Commit 587d704

Browse files
etagwerkerfaisal
andauthored
RubyCritic v5.0 (Support for Ruby 4.0) (#556)
* Changes needed for Ruby 4.0.0 * Test with Ruby 4.0 too * Patch FakeFS * Add a note about Ruby 4.0 * Apply patch by @faisal * Remove irb and bump dependency on fakefs * undef :path * Additional changes for 5.0 (Ruby 4 support) branch (#566) * Update version, and version compatibility, for 5.0 release. * run mdl with Ruby 4 # Conflicts: # CHANGELOG.md * Fixed up changelog - restored notes and one change that got dropped in rebasing - split out the changelog to include 4.12 release we haven't done yet * Require ostruct, because Ruby 4.0 no longer bundles it. * [CHANGE] Update byebug dependency, for Ruby 4.0 compatibility fixes * Small fix to avoid unnecessary strictness in comparison --------- Co-authored-by: Faisal N Jawdat <faisal@users.noreply.github.com>
1 parent e072f19 commit 587d704

9 files changed

Lines changed: 41 additions & 13 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- '3.2'
3232
- '3.3'
3333
- '3.4'
34+
- '4.0'
3435
experimental: [false]
3536
include:
3637
- ruby-version: 'ruby-head'
@@ -61,6 +62,7 @@ jobs:
6162
- '3.2'
6263
- '3.3'
6364
- '3.4'
65+
- '4.0'
6466
experimental: [false]
6567
include:
6668
- ruby-version: 'ruby-head'
@@ -91,6 +93,7 @@ jobs:
9193
- '3.2'
9294
- '3.3'
9395
- '3.4'
96+
- '4.0'
9497
experimental: [false]
9598
include:
9699
- ruby-version: 'ruby-head'
@@ -121,6 +124,7 @@ jobs:
121124
- '3.2'
122125
- '3.3'
123126
- '3.4'
127+
- '4.0'
124128
experimental: [false]
125129
include:
126130
- ruby-version: 'ruby-head'
@@ -149,7 +153,7 @@ jobs:
149153
- name: Set up Ruby
150154
uses: ruby/setup-ruby@v1
151155
with:
152-
ruby-version: '3.4'
156+
ruby-version: '4.0'
153157
bundler-cache: true
154158
cache-version: 1
155159
continue-on-error: ${{ matrix.experimental }}

CHANGELOG.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
# main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.11.0...main)
1+
# main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.12.0...main)
22

33
* [CHANGE] ...
44
* [BUGFIX] ...
55
* [CHORE] ...
66
* [FEATURE] ...
77

8-
* [CHORE] Sorted cops in .rubocop.yml to make it easier for maintainers to add or modify cop settings, and unified duplicate Metrics/MethodLength settings. (by [@faisal][])
9-
* [CHORE] Updated README with last supported Ruby versions for the older as well as the latest releases of Rubycritic/Ruby (by [@faisal][])
8+
* [CHORE] Bump byebug dependency (by [@faisal][])
9+
* [CHORE] Bump mdl and mocha dependencies (by [@faisal][])
10+
* [CHORE] Bump minitest dependency, and add minitest-mock dependency (by [@faisal][])
11+
* [CHORE] Bump fakefs dependency, and drop irb dependency (by [@faisal][])
12+
* [CHORE] In RubyCritic::Generator::Html::Line, require cgi/escape rather than cgi, as the latter is removed from Ruby 4.0 (by [@faisal][])
13+
* [CHORE] Run Markdown linting in CI using Ruby 4.0 (by [@faisal][])
14+
* [CHANGE] Sorted cops in .rubocop.yml to make it easier for maintainers to add or modify cop settings, and unified duplicate Metrics/MethodLength settings. (by [@faisal][])
1015
* [CHANGE] Drop support for Ruby 3.1.x and JRuby 9.4 (by [@faisal][])
1116
* [CHANGE] Add CI support for JRuby 10.0 (by [@faisal][])
17+
* [CHORE] Start testing library with Ruby 4.0 (by [@etagwerker][])
18+
19+
# v4.12.0 / 2026-01-01 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.11.0...v4.12.0)
20+
1221
* [CHANGE] Bump cucumber dependency (by [@faisal][])
1322
* [BUGFIX] Fixed regression in compatibility with Flog 4.9.0 (by [@faisal][])
1423
* [CHANGE] Bump mocha dependency (by [@faisal][])

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ RubyCritic is supporting Ruby versions:
246246
| 2.6 | [v4.7.0](https://github.com/whitesmith/rubycritic/tree/v4.7.0) |
247247
| 2.7 | [v4.9.1](https://github.com/whitesmith/rubycritic/tree/v4.9.1) |
248248
| 3.0 | [v4.9.2](https://github.com/whitesmith/rubycritic/tree/v4.9.1) |
249-
| 3.1 | [v4.11.0](https://github.com/whitesmith/rubycritic/tree/v4.11.0) |
249+
| 3.1 | [v4.12.0](https://github.com/whitesmith/rubycritic/tree/v4.12.0) |
250250
| 3.2 | latest |
251251
| 3.3 | latest |
252252
| 3.4 | latest |

features/step_definitions/rubycritic_steps.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
end
2222

2323
Then(/^it reports the current version$/) do
24-
expect(last_command_started).to have_output("RubyCritic #{RubyCritic::VERSION}\n")
24+
expect(last_command_started).to have_output(an_output_string_including("RubyCritic #{RubyCritic::VERSION}"))
2525
end
2626

2727
Then(/^it reports the error ['"](.*)['"]$/) do |string|

lib/rubycritic/analysers/smells/reek.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class ReekSmells
1010
include Colorize
1111

1212
def initialize(analysed_modules)
13-
@analysed_modules = analysed_modules.reject { Reek.configuration.path_excluded?(_1.pathname) }
13+
@analysed_modules = analysed_modules.reject do |mod|
14+
path_string = mod.pathname.to_s
15+
Reek.configuration.path_excluded?(Pathname.new(path_string))
16+
end
1417
end
1518

1619
def run

lib/rubycritic/generators/html/line.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'cgi'
3+
require 'cgi/escape'
44
require 'rubycritic/generators/html/base'
55

66
module RubyCritic

lib/rubycritic/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module RubyCritic
4-
VERSION = '4.12.0'
4+
VERSION = '5.0.0'
55
end

rubycritic.gemspec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
3434
spec.add_dependency 'flay', '~> 2.13'
3535
spec.add_dependency 'flog', '~> 4.7'
3636
spec.add_dependency 'launchy', '>= 2.5.2'
37+
spec.add_dependency 'ostruct'
3738
spec.add_dependency 'parser', '>= 3.3.0.5'
3839
spec.add_dependency 'prism', '>= 1.6.0'
3940
spec.add_dependency 'rainbow', '~> 3.1.1'
@@ -50,18 +51,16 @@ Gem::Specification.new do |spec|
5051
spec.add_development_dependency 'jar-dependencies', '~> 0.5.5'
5152
spec.add_development_dependency 'pry-debugger-jruby'
5253
else
53-
spec.add_development_dependency 'byebug', '~> 12.0', '>= 10.0'
54+
spec.add_development_dependency 'byebug', '~> 13.0', '>= 10.0'
5455
end
5556
spec.add_development_dependency 'cucumber', '~> 10.2.0', '>= 10.1.0'
5657
spec.add_development_dependency 'diff-lcs', '~> 1.3'
57-
spec.add_development_dependency 'fakefs', '~> 3.0.0'
58-
spec.add_development_dependency 'irb'
58+
spec.add_development_dependency 'fakefs', '~> 3.2.0'
5959
spec.add_development_dependency 'mdl', '~> 0.15.0', '>= 0.12.0'
6060
spec.add_development_dependency 'minitest', '~> 6.0.0'
6161
spec.add_development_dependency 'minitest-around', '~> 0.6.0'
6262
spec.add_development_dependency 'minitest-mock'
6363
spec.add_development_dependency 'mocha', '~> 3.0.0'
64-
spec.add_development_dependency 'ostruct'
6564
spec.add_development_dependency 'rake', '~> 13.3.0', '>= 11.0.0'
6665
spec.add_development_dependency 'rdoc'
6766
spec.add_development_dependency 'rexml', '>= 3.2.0'

test/fakefs_helper.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,16 @@ def home(user = Etc.getlogin)
2424
end
2525
end
2626
FakeFS::Dir.singleton_class.prepend(FakeFSPatch)
27+
28+
# Patch FakeFS::Pathname to include the path method for Ruby 4.0.0 compatibility
29+
# This is needed because Reek's configuration internally calls Pathname#== which
30+
# requires the path method to be present
31+
module FakeFS
32+
class Pathname
33+
undef :path
34+
35+
def path
36+
to_s
37+
end
38+
end
39+
end

0 commit comments

Comments
 (0)