From c2477241e67a6a911e0cc8b9baf429582a540f68 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 6 Jan 2026 16:40:00 +0100 Subject: [PATCH 1/2] Drop Ruby 2.5 / 2.6 support In the past CI was adjusted to Require Ruby 2.7 or newer, but we didn't drop the old versions from the gemspec. While it claims to support Ruby 2.5 & 2.6, it doesn't work in reality. This changes fixes this. Ruby 2.5 was used in puppet AIO 6 / and jruby 9.3 (compatible with Ruby 2.6) in puppetserver 7. Both are EoL since ages. Signed-off-by: Tim Meusel --- .rubocop.yml | 2 +- openfact.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 89c241947..e36dbb8c2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,7 +2,7 @@ inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.7 Exclude: - acceptance/**/* - vendor/**/* diff --git a/openfact.gemspec b/openfact.gemspec index 0bec1f2c9..4e51b4a77 100644 --- a/openfact.gemspec +++ b/openfact.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |spec| base = "#{__dir__}#{File::SEPARATOR}" spec.files = dirs.map { |path| path.sub(base, '') } - spec.required_ruby_version = '>= 2.5' + spec.required_ruby_version = '>= 2.7' spec.bindir = 'bin' spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ['lib'] From 4062bb30b21f346812f400a9ccba73645c4343b3 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Tue, 6 Jan 2026 16:47:58 +0100 Subject: [PATCH 2/2] rubocop: autofix Signed-off-by: Tim Meusel --- .rubocop_todo.yml | 13 +++++++++++++ lib/docs/generate.rb | 6 +----- lib/facter/framework/cli/cli.rb | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f6b9fbab6..6d5eef8f8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -85,3 +85,16 @@ Style/Documentation: Style/OptionalBooleanParameter: Exclude: - 'lib/facter/util/resolvers/http.rb' + +# Offense count: 13 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Exclude: + - 'install.rb' + - 'lib/facter/facts/solaris/ldom.rb' + - 'lib/facter/framework/cli/cli.rb' + - 'lib/facter/resolvers/aix/serialnumber.rb' + - 'lib/facter/resolvers/freebsd/swap_memory.rb' + - 'lib/facter/resolvers/networking.rb' + - 'lib/facter/resolvers/partitions.rb' + - 'lib/facter/util/api_debugger.rb' diff --git a/lib/docs/generate.rb b/lib/docs/generate.rb index 9ed92a011..4ea43d8e7 100755 --- a/lib/docs/generate.rb +++ b/lib/docs/generate.rb @@ -18,11 +18,7 @@ def format_facts(fact_hash) facts: fact_hash }) - erb = if ERB.instance_method(:initialize).parameters.assoc(:key) # Ruby 2.6+ - ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-') - else - ERB.new(File.read(PATH_TO_TEMPLATE), nil, '-') - end + erb = ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-') erb.result(scope.instance_eval { binding }) end diff --git a/lib/facter/framework/cli/cli.rb b/lib/facter/framework/cli/cli.rb index eb8f98aa6..1b94f3d82 100755 --- a/lib/facter/framework/cli/cli.rb +++ b/lib/facter/framework/cli/cli.rb @@ -113,7 +113,7 @@ def man(*args) negate_options = %w[block cache custom_facts external_facts] template = File.join(File.dirname(__FILE__), '..', '..', 'templates', 'man.erb') - erb = ERB.new(File.read(template), nil, '-') + erb = ERB.new(File.read(template), trim_mode: '-') erb.filename = template puts erb.result(binding) end