-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #612 from Shopify/reduce-required-rubocop-version
- Loading branch information
Showing
4 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
lib/rubocop/shopify/gem_version_string_comparable_backport.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
# This is true for Ruby 3.2+, so once support for 3.1 is dropped, we can remove this. | ||
# Until then, some installations may have a recent enough version of RubyGems, but it is not guaranteed. | ||
return if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.5.6") | ||
|
||
module RuboCop | ||
module Shopify | ||
# Backport rubygems/rubygems#5275, so we can compare `Gem::Version`s directly against `String`s. | ||
# | ||
# Gem::Version.new("1.2.3") > "1.2" | ||
# | ||
# Without this, to support Ruby < 3.2, we would have to create a new `Gem::Version` instance ourselves. | ||
# | ||
# Gem::Version.new("1.2.3") > Gem::Version.new("1.2") | ||
# | ||
# This would get very verbose in our RuboCop config files. | ||
module GemVersionStringComparableBackport | ||
def <=>(other) | ||
return self <=> self.class.new(other) if (String === other) && self.class.correct?(other) | ||
|
||
super | ||
end | ||
|
||
Gem::Version.prepend(self) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters