Skip to content

Support Ruby 3.1 through 3.4 #1797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

strategy:
matrix:
ruby: ["3.0", "3.1", "3.2", "jruby-9.4", "3.3"]
ruby: ["3.1", "3.2", "jruby-9.4", "3.3", "3.4"]

steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 1 addition & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllCops:
Exclude:
- 'samples/**/*'
NewCops: enable
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1

# Tables are nice
Layout/HashAlignment:
Expand Down Expand Up @@ -84,13 +84,6 @@ RSpec/ExampleLength:
Style/AndOr:
EnforcedStyle: conditionals

# Require comment for files in lib and bin
Style/FrozenStringLiteralComment:
Include:
- 'bin/*'
- 'lib/**/*'
EnforcedStyle: always

# Allow multiline block chains
Style/MultilineBlockChain:
Enabled: false
Expand Down
2 changes: 2 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

SimpleCov.start do
track_files 'lib/**/*.rb'
add_filter 'lib/reek/version.rb' # version.rb is loaded too early to test
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/clean'

Expand Down
2 changes: 2 additions & 0 deletions docs/templates/default/docstring/setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def init
super
return unless show_api_marker_section?
Expand Down
2 changes: 2 additions & 0 deletions docs/yard_plugin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'yard'

# Template helper to modify processing of links in HTML generated from our
Expand Down
2 changes: 2 additions & 0 deletions features/step_definitions/reek_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

When /^I run reek (.*)$/ do |args|
reek(args)
end
Expand Down
2 changes: 2 additions & 0 deletions features/step_definitions/sample_file_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../samples/paths'

Given(/^the smelly file '(.+)'$/) do |filename|
Expand Down
2 changes: 2 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../lib/reek'
require_relative '../../lib/reek/cli/application'
require 'aruba/cucumber'
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/context/code_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def initialize(exp)
# @param type [Symbol] the type of the nodes we are looking for, e.g. :defs.
# @yield block that is executed for every node.
#
def local_nodes(type, ignored = [], &blk)
def local_nodes(type, ignored = [], &)
ignored |= [:class, :module]
exp.each_node(type, ignored, &blk)
exp.each_node(type, ignored, &)
end

# Iterate over `self` and child contexts.
Expand Down
16 changes: 11 additions & 5 deletions lib/reek/source/source_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ def origin

def code
@code ||=
case source
when File, Pathname then source.read
when IO then source.readlines.join
when String then source
end.force_encoding(Encoding::UTF_8)
begin
str =
case source
when File, Pathname then source.read
when IO then source.readlines.join
when String then source
end

str = str.dup if str.frozen?
str.force_encoding(Encoding::UTF_8)
end
end

attr_reader :parser, :source
Expand Down
4 changes: 3 additions & 1 deletion reek.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'lib/reek/version'

Gem::Specification.new do |spec|
Expand All @@ -21,7 +23,7 @@ Gem::Specification.new do |spec|

spec.executables = spec.files.grep(%r{^bin/}).map { |path| File.basename(path) }
spec.rdoc_options = %w(--main README.md -x assets/|bin/|config/|features/|spec/|tasks/)
spec.required_ruby_version = '>= 3.0.0'
spec.required_ruby_version = '>= 3.1.0'

spec.metadata = {
'homepage_uri' => 'https://github.com/troessner/reek',
Expand Down
2 changes: 2 additions & 0 deletions spec/performance/reek/smell_detectors/runtime_speed_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../../spec_helper'
require_lib 'reek/examiner'

Expand Down
2 changes: 2 additions & 0 deletions spec/quality/documentation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'
require 'kramdown'

Expand Down
2 changes: 2 additions & 0 deletions spec/quality/reek_source_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'

RSpec.describe 'Reek source code' do
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/ast/node_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/ast/node'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/ast/object_refs_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/ast/object_refs'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/ast/reference_collector_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/ast/reference_collector'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/ast/sexp_extensions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/ast/sexp_extensions'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/cli/application_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/cli/application'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/cli/command/report_command_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../../spec_helper'
require_lib 'reek/cli/command/report_command'
require_lib 'reek/cli/options'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/cli/command/todo_list_command_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../../spec_helper'
require_lib 'reek/cli/command/todo_list_command'
require_lib 'reek/cli/options'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/cli/options_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/cli/options'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/cli/silencer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/cli/silencer'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/code_climate/code_climate_configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/code_climate/code_climate_configuration'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/code_climate/code_climate_fingerprint_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/code_climate/code_climate_fingerprint'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/code_climate/code_climate_formatter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/code_climate/code_climate_formatter'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/code_climate/code_climate_report_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/code_climate'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/code_comment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'
require_lib 'reek/code_comment'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/app_configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'pathname'
require_relative '../../spec_helper'
require_lib 'reek/configuration/app_configuration'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/configuration_file_finder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'fileutils'
require 'pathname'
require 'tmpdir'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/default_directive_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/configuration/default_directive'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/directory_directives_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/errors/config_file_error'
require_lib 'reek/configuration/directory_directives'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/excluded_paths_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/errors/config_file_error'
require_lib 'reek/configuration/excluded_paths'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/rake_task_converter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/configuration/rake_task_converter'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/schema_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/configuration/schema'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/configuration/schema_validator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/configuration/schema_validator'
require_lib 'reek/errors/config_file_error'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/context/code_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/context/method_context'
require_lib 'reek/context/module_context'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/context/ghost_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/context/code_context'
require_lib 'reek/context/ghost_context'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/context/method_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/context/method_context'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/context/module_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/context/module_context'
require_lib 'reek/context/root_context'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/context/root_context_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/context/root_context'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/context/statement_counter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/context/statement_counter'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/context_builder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'
require_lib 'reek/context_builder'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/detector_repository_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'
require_lib 'reek/smell_detectors/base_detector'
require_lib 'reek/detector_repository'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/documentation_link_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'

RSpec.describe Reek::DocumentationLink do
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/errors/base_error_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'

require_lib 'reek/errors/base_error'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/examiner_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/logging_error_handler'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/logging_error_handler_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../spec_helper'
require_lib 'reek/logging_error_handler'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/rake/task_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/rake/task'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/report/github_report_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/report/json_report'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/report/html_report_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/report/html_report'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/report/json_report_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/report/json_report'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/report/location_formatter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/report/location_formatter'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/report/progress_formatter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/report/progress_formatter'

Expand Down
2 changes: 2 additions & 0 deletions spec/reek/report/text_report_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/report/text_report'
Expand Down
2 changes: 2 additions & 0 deletions spec/reek/report/xml_report_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative '../../spec_helper'
require_lib 'reek/examiner'
require_lib 'reek/report/xml_report'
Expand Down
Loading
Loading