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

Reduce minimum RuboCop version back to ~> 1.51 #612

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: .
specs:
rubocop-shopify (2.14.0)
rubocop (~> 1.53)
rubocop (~> 1.51)

GEM
remote: https://rubygems.org/
Expand Down
28 changes: 28 additions & 0 deletions lib/rubocop/shopify/gem_version_string_comparable_backport.rb
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
2 changes: 1 addition & 1 deletion rubocop-shopify.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Gem::Specification.new do |s|

s.required_ruby_version = ">= 2.7.0"

s.add_dependency("rubocop", "~> 1.53")
s.add_dependency("rubocop", "~> 1.51")
end
31 changes: 24 additions & 7 deletions rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<%
require "rubocop/shopify/gem_version_string_comparable_backport"

rubocop_version = Gem.loaded_specs.fetch("rubocop").version
v1_57 = Gem::Version.new("1.57")
v1_58 = Gem::Version.new("1.58")
v1_59 = Gem::Version.new("1.59")
%>

inherit_mode:
Expand Down Expand Up @@ -190,21 +189,23 @@ Lint/IncompatibleIoSelectWithFiberScheduler:
Lint/InterpolationCheck:
Enabled: false

<% if rubocop_version >= v1_59 %>
<% if rubocop_version >= "1.59" %>
Lint/ItWithoutArgumentsInBlock:
Enabled: true
<% end %>

Lint/LambdaWithoutLiteralBlock:
Enabled: false

<% if rubocop_version >= v1_58 %>
<% if rubocop_version >= "1.58" %>
Lint/LiteralAssignmentInCondition:
Enabled: true
<% end %>

<% if rubocop_version >= "1.53" %>
Lint/MixedCaseRange:
Enabled: true
<% end %>

Lint/MixedRegexpCaptureTypes:
Enabled: false
Expand Down Expand Up @@ -239,8 +240,10 @@ Lint/RaiseException:
Lint/RedundantDirGlobSort:
Enabled: false

<% if rubocop_version >= "1.53" %>
Lint/RedundantRegexpQuantifiers:
Enabled: true
<% end %>

Lint/RedundantRequireStatement:
Enabled: false
Expand Down Expand Up @@ -727,8 +730,10 @@ Style/RandomWithOffset:
Style/RedundantArgument:
Enabled: false

<% if rubocop_version >= "1.52" %>
Style/RedundantArrayConstructor:
Enabled: true
<% end %>

Style/RedundantAssignment:
Enabled: false
Expand All @@ -742,8 +747,10 @@ Style/RedundantConditional:
Style/RedundantConstantBase:
Enabled: true

<% if rubocop_version >= "1.53" %>
Style/RedundantCurrentDirectoryInPath:
Enabled: true
<% end %>

Style/RedundantDoubleSplatHashBraces:
Enabled: true
Expand All @@ -757,8 +764,10 @@ Style/RedundantFetchBlock:
Style/RedundantFileExtensionInRequire:
Enabled: false

<% if rubocop_version >= "1.52" %>
Style/RedundantFilterChain:
Enabled: true
<% end %>

Style/RedundantHeredocDelimiterQuotes:
Enabled: true
Expand All @@ -769,14 +778,18 @@ Style/RedundantInitialize:
Style/RedundantLineContinuation:
Enabled: true

<% if rubocop_version >= "1.53" %>
Style/RedundantRegexpArgument:
Enabled: true
<% end %>

Style/RedundantRegexpCharacterClass:
Enabled: false

<% if rubocop_version >= "1.52" %>
Style/RedundantRegexpConstructor:
Enabled: true
<% end %>

Style/RedundantRegexpEscape:
Enabled: false
Expand All @@ -802,16 +815,18 @@ Style/RescueStandardError:
Style/ReturnNil:
Enabled: true

<% if rubocop_version >= "1.53" %>
Style/ReturnNilInPredicateMethodDefinition:
Enabled: true
<% end %>

Style/SelectByRegexp:
Enabled: false

Style/SingleArgumentDig:
Enabled: false

<% if rubocop_version >= v1_57 %>
<% if rubocop_version >= "1.57" %>
Style/SingleLineDoEndBlock:
Enabled: true
<% end %>
Expand Down Expand Up @@ -840,7 +855,7 @@ Style/StringLiteralsInInterpolation:
Style/StructInheritance:
Enabled: false

<% if rubocop_version >= v1_58 %>
<% if rubocop_version >= "1.58" %>
Style/SuperWithArgsParentheses:
Enabled: true
<% end %>
Expand Down Expand Up @@ -875,8 +890,10 @@ Style/UnpackFirst:
Style/WordArray:
EnforcedStyle: brackets

<% if rubocop_version >= "1.53" %>
Style/YAMLFileRead:
Enabled: true
<% end %>

Style/YodaCondition:
Enabled: false