File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,32 @@ def test_no_cops_are_configured_as_pending
90
90
ERROR_MESSAGE
91
91
end
92
92
93
+ def test_config_does_not_check_for_rubocop_versions_below_minimum_version
94
+ rubocop_version_requirement = Gem
95
+ . loaded_specs . fetch ( 'rubocop-shopify' )
96
+ . dependencies . find { _1 . name == 'rubocop' }
97
+ . requirement
98
+
99
+ # RuboCop version checks are done in ERB, so we need to read the raw file
100
+ redundant_rubocop_version_checks = File . read ( 'rubocop.yml' ) . each_line . with_index . filter_map do |line , index |
101
+ match = line . match ( /<% if rubocop_version >= "(?<version>.*)" %>/ )
102
+ next unless match
103
+
104
+ minimum_version_for_config = Gem ::Version . new ( match [ 1 ] )
105
+ next if rubocop_version_requirement . satisfied_by? ( minimum_version_for_config )
106
+
107
+ [ index , line . chomp ]
108
+ end
109
+
110
+ assert ( redundant_rubocop_version_checks . empty? , <<~ERROR_MESSAGE . chomp )
111
+ The following RuboCop version check(s) are redundant given the gemspec's version requirement (#{ rubocop_version_requirement } ):
112
+
113
+ #{ redundant_rubocop_version_checks . map { " #{ _1 . to_s . rjust ( 4 ) } : #{ _2 } " } . join ( "\n " ) }
114
+
115
+ Please remove these check(s), or (if you intend to maintain compatibility) loosen the `rubocop` requirement in the gemspec.
116
+ ERROR_MESSAGE
117
+ end
118
+
93
119
private
94
120
95
121
def checking_rubocop_version_compatibility?
You can’t perform that action at this time.
0 commit comments