Gemspec/RequiredRubyVersion
errors with only upper bounded requirement
#12714
Labels
Gemspec/RequiredRubyVersion
errors with only upper bounded requirement
#12714
Expected behavior
The
Gemspec/RequiredRubyVersion
cop should pass with only an upper bounded limit as the value.Example:
Actual behavior
The following error is raised:
Steps to reproduce the problem
Update a gem's
gemspec
to use only an upper bounded limit for therequired_ruby_version
:The problem lies here: https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cop/gemspec/required_ruby_version.rb#L100-L114
The regex used is
/[>=]/
and therefore it doesn't match<
and therefore returnsnil
. This regex can be updated to/[>=<]/
, but then the it adds an offense here: https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cop/gemspec/required_ruby_version.rb#L89 for the Ruby version not matching the version in the.rubocop.yml
, which we wouldn't want in this case. I am not entirely sure the best way to solve that problem, otherwise I would have submitted a Pull Request to update the regex.RuboCop version
The text was updated successfully, but these errors were encountered: