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
Gem::Requirement.new(['>= x', '< y'])
in required_ruby_version
crashes RuboCop
#12105
Comments
This seems to fail because the def_node_matcher :gem_requirement?, <<~PATTERN
(send (const(const _ :Gem):Requirement) :new $str)
PATTERN |
Hi @ItsEcholot , s.required_ruby_version = Gem::Requirement.new(">= 3.1".freeze, "< 3.3".freeze) See the test case https://github.com/rubocop/rubocop/blob/master/spec/rubocop/cop/gemspec/required_ruby_version_spec.rb#L43 |
Hey @alexeyschepin,
Also does not work returning the following error: undefined method `value' for s(:send,
s(:const,
s(:const, nil, :Gem), :Requirement), :new,
s(:send,
s(:str, ">= 3.1"), :freeze),
s(:send,
s(:str, "< 3.3"), :freeze)):RuboCop::AST::SendNode Using the exact line from the test case you linked also doesn't work? s.required_ruby_version = Gem::Requirement.new(">= 2.7.0", "<= 2.8") undefined method `value' for s(:send,
s(:const,
s(:const, nil, :Gem), :Requirement), :new,
s(:str, ">= 2.7.0"),
s(:str, "<= 2.8")):RuboCop::AST::SendNode |
While the it 'sets first known ruby version that satisfies range requirement' do
content =
<<-HEREDOC
Gem::Specification.new do |s|
s.name = 'test'
s.required_ruby_version = Gem::Requirement.new('>= 2.3.1', '< 3.0.0')
s.licenses = ['MIT']
end
HEREDOC
create_file(gemspec_file_path, content)
expect(target_ruby.version).to eq default_version
end
end It fails with the same exception I experienced and reported in the first post. |
…n_gem_requirement_matching [Fix #12105] Adjust target ruby gem requirement matcher and version parsing to support multiple version constraints
RuboCop crashes when specifying the
required_ruby_version
in thegemspec
using multiple version constraints in theGem::Requirement
initializer.Expected behavior
RuboCop should be able to handle multiple version constraints in the
Gem::Requirement
initializer.Actual behavior
Steps to reproduce the problem
Add the following to a
*.gemspec
file:s.required_ruby_version = Gem::Requirement.new([">= 3.1".freeze, "< 3.3".freeze])
Or, add the following to a
Rakefile
and generate a new gemspec:spec.required_ruby_version = '>= 3.1', '< 3.3'
RuboCop version
This call also fails with the above content in the
gemspec
.Here the output with
required_ruby_version
removed:The text was updated successfully, but these errors were encountered: