Skip to content
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

Require Ruby 2.6 or newer #2751

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
ruby:
- '2.5'
- '2.6'
- '2.7'
- '3.0'
- '3.2'
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.6
Exclude:
- acceptance/**/*
- vendor/**/*
Expand Down
49 changes: 27 additions & 22 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-01-08 20:12:30 UTC using RuboCop version 1.59.0.
# on 2024-09-06 09:41:23 UTC using RuboCop version 1.50.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -18,35 +18,40 @@ Performance/RegexpMatch:
RSpec/FilePath:
Enabled: false

# Need to remove logger class variables
# Offense count: 14
Style/ClassVars:
Exclude:
- 'lib/facter/framework/logging/logger.rb'
- 'spec/custom_facts/puppetlabs_spec/files.rb'
- 'spec/facter/util/file_helper_spec.rb'
- 'spec/framework/core/fact/internal/internal_fact_manager_spec.rb'
- 'spec/framework/logging/logger_spec.rb'

# Offense count: 977
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/IdenticalConditionalBranches:
Exclude:
- 'lib/facter.rb' # should be documented
- 'lib/facter/config.rb' # should be documented
- 'lib/facter/custom_facts/**/*' # should be documented
- 'lib/facter/facts/**/*' # don't care
- 'lib/facter/framework/**/*' # should be documented
- 'lib/facter/models/**/*' # should be documented
- 'lib/facter/resolvers/**/*' # don't care
- 'lib/facter/util/**/*'
- 'lib/facter/version.rb' # auto updated
- 'spec/**/*'
- 'spec_integration/**/*'
- 'scripts/*'
- 'install.rb'
- 'lib/docs/generate.rb'

# While it would be preferable to use a keyword argument for the proxy setting in #get_request and #put_request, if we
# add keyword arguments to those methods Ruby < 3 misinterprets earlier positional arguments as a keyword arguments.
# This is because those positional arguments are hashes that use symbols as keys.
# TODO: revisit this after we drop Ruby < 3 support.
# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/facter/util/resolvers/http.rb'
- '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'
8 changes: 4 additions & 4 deletions facter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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', '< 4.0'
spec.required_ruby_version = '>= 2.6', '< 4.0'
spec.bindir = 'bin'
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
Expand All @@ -38,14 +38,14 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'ffi', '>= 1.15.5', '< 1.17.0', '!= 1.16.0', '!= 1.16.1', '!= 1.16.2'
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rubocop', '~> 1.28' # last version to support 2.5
spec.add_development_dependency 'rubocop', '~> 1.50.0' # last version to support 2.6
spec.add_development_dependency 'rubocop-performance', '~> 1.5.2'
spec.add_development_dependency 'rubocop-rspec', '~> 2.10' # last version to support 2.5
spec.add_development_dependency 'rubocop-rspec', '~> 2.20.0' # last version to support 2.6
spec.add_development_dependency 'simplecov', '~> 0.17.1'
spec.add_development_dependency 'sys-filesystem', '~> 1.4'
spec.add_development_dependency 'webmock', '~> 3.12'
spec.add_development_dependency 'yard', '~> 0.9'

spec.add_runtime_dependency 'hocon', '~> 1.3'
spec.add_runtime_dependency 'thor', ['>= 1.0.1', '< 1.3'] # Thor 1.3.0 drops support for Ruby 2.5
spec.add_runtime_dependency 'thor', '~> 1.0'
end
2 changes: 1 addition & 1 deletion lib/docs/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def format_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, '-')
ERB.new(File.read(PATH_TO_TEMPLATE), trim_mode: '-')
end
erb.result(scope.instance_eval { binding })
end
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/framework/cli/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/custom_facts/util/collection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def load(collection)
end

it 'converts the fact name to a string' do
collection.each do |fact, _value| # rubocop:disable Style/HashEachMethods
collection.each do |fact, _value|
expect(fact).to be_instance_of(String)
end
end
Expand Down