rubocop-shopify 2.14.0 → 2.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This is true for Ruby 3.2+, so once support for 3.1 is dropped, we can remove this.
4
+ # Until then, some installations may have a recent enough version of RubyGems, but it is not guaranteed.
5
+ return if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("3.5.6")
6
+
7
+ module RuboCop
8
+ module Shopify
9
+ # Backport rubygems/rubygems#5275, so we can compare `Gem::Version`s directly against `String`s.
10
+ #
11
+ # Gem::Version.new("1.2.3") > "1.2"
12
+ #
13
+ # Without this, to support Ruby < 3.2, we would have to create a new `Gem::Version` instance ourselves.
14
+ #
15
+ # Gem::Version.new("1.2.3") > Gem::Version.new("1.2")
16
+ #
17
+ # This would get very verbose in our RuboCop config files.
18
+ module GemVersionStringComparableBackport
19
+ def <=>(other)
20
+ return self <=> self.class.new(other) if (String === other) && self.class.correct?(other)
21
+
22
+ super
23
+ end
24
+
25
+ Gem::Version.prepend(self)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubocop"
4
+
5
+ namespace :config do
6
+ desc "Dump the full RuboCop config as a YAML file for testing"
7
+ task :dump, [:target] do |_task, args|
8
+ file = "rubocop.yml"
9
+ target = args.fetch(:target, "test/fixtures/full_config.yml")
10
+
11
+ file_config = RuboCop::ConfigLoader.load_file(file)
12
+ config = RuboCop::ConfigLoader.merge_with_default(file_config, file)
13
+ output = config.to_h.to_yaml.gsub(config.base_dir_for_path_parameters, "")
14
+
15
+ # Removing trailing whitespaces from each line due to older libyaml versions
16
+ # converting nil hash values into whitespaces. GitHub actions is still stuck
17
+ # with libyaml < 0.2.5. This line can be removed once it is upgraded. Psych
18
+ # can be used to check for the running libyaml version:
19
+ #
20
+ # ```ruby
21
+ # require "psych"
22
+ # puts Psych::LIBYAML_VERSION
23
+ # ```
24
+ #
25
+ # For more info, see: https://github.com/yaml/libyaml/pull/186
26
+ output.gsub!(/\s\n/, "\n")
27
+
28
+ File.write(target, output)
29
+ end
30
+ end
data/rubocop.yml CHANGED
@@ -1,3 +1,9 @@
1
+ <%
2
+ require "rubocop/shopify/gem_version_string_comparable_backport"
3
+
4
+ rubocop_version = Gem.loaded_specs.fetch("rubocop").version
5
+ %>
6
+
1
7
  inherit_mode:
2
8
  merge:
3
9
  - Exclude
@@ -5,6 +11,7 @@ inherit_mode:
5
11
 
6
12
  AllCops:
7
13
  StyleGuideBaseURL: https://shopify.github.io/ruby-style-guide/
14
+ NewCops: disable # New cops will be triaged by style guide maintainers instead.
8
15
 
9
16
  Bundler/OrderedGems:
10
17
  Enabled: false
@@ -54,10 +61,10 @@ Layout/HashAlignment:
54
61
  EnforcedLastArgumentHashStyle: ignore_implicit
55
62
 
56
63
  Layout/LineContinuationLeadingSpace:
57
- Enabled: false
64
+ Enabled: true
58
65
 
59
66
  Layout/LineContinuationSpacing:
60
- Enabled: false
67
+ Enabled: true
61
68
 
62
69
  Layout/LineEndStringConcatenationIndentation:
63
70
  Enabled: true
@@ -182,9 +189,24 @@ Lint/IncompatibleIoSelectWithFiberScheduler:
182
189
  Lint/InterpolationCheck:
183
190
  Enabled: false
184
191
 
192
+ <% if rubocop_version >= "1.59" %>
193
+ Lint/ItWithoutArgumentsInBlock:
194
+ Enabled: true
195
+ <% end %>
196
+
185
197
  Lint/LambdaWithoutLiteralBlock:
186
198
  Enabled: false
187
199
 
200
+ <% if rubocop_version >= "1.58" %>
201
+ Lint/LiteralAssignmentInCondition:
202
+ Enabled: true
203
+ <% end %>
204
+
205
+ <% if rubocop_version >= "1.53" %>
206
+ Lint/MixedCaseRange:
207
+ Enabled: true
208
+ <% end %>
209
+
188
210
  Lint/MixedRegexpCaptureTypes:
189
211
  Enabled: false
190
212
 
@@ -218,6 +240,11 @@ Lint/RaiseException:
218
240
  Lint/RedundantDirGlobSort:
219
241
  Enabled: false
220
242
 
243
+ <% if rubocop_version >= "1.53" %>
244
+ Lint/RedundantRegexpQuantifiers:
245
+ Enabled: true
246
+ <% end %>
247
+
221
248
  Lint/RedundantRequireStatement:
222
249
  Enabled: false
223
250
 
@@ -375,8 +402,7 @@ Naming/InclusiveLanguage:
375
402
  - !ruby/regexp /\w*:\/\/\S+/ # URLs (e.g. https://github.com/org/repo/blob/master/README.md)
376
403
  - !ruby/regexp '/(?:blob|tree)/master/' # e.g. github.com/org/repo/blob/master/README.md, without https://
377
404
  - !ruby/regexp '/origin[ \/]master/' # Legacy default git branch name
378
- - 'mastercard'
379
- - 'webmaster'
405
+ - !ruby/regexp '/(?<=[a-z])master|master(?=[a-z])/' # "master" substring within a longer word
380
406
 
381
407
  Naming/MemoizedInstanceVariableName:
382
408
  Enabled: false
@@ -505,7 +531,7 @@ Style/Encoding:
505
531
  Enabled: false
506
532
 
507
533
  Style/EndlessMethod:
508
- Enabled: false
534
+ Enabled: true
509
535
 
510
536
  Style/EnvHome:
511
537
  Enabled: false
@@ -542,6 +568,7 @@ Style/FormatStringToken:
542
568
 
543
569
  Style/FrozenStringLiteralComment:
544
570
  SafeAutoCorrect: true
571
+ EnforcedStyle: always_true
545
572
  Details: 'Add `# frozen_string_literal: true` to the top of the file. Frozen string
546
573
  literals will become the default in a future Ruby version, and we want to make
547
574
  sure we''re ready.'
@@ -577,7 +604,7 @@ Style/IfUnlessModifier:
577
604
  Enabled: false
578
605
 
579
606
  Style/IfWithBooleanLiteralBranches:
580
- Enabled: false
607
+ Enabled: true
581
608
 
582
609
  Style/InPatternThen:
583
610
  Enabled: true
@@ -703,6 +730,11 @@ Style/RandomWithOffset:
703
730
  Style/RedundantArgument:
704
731
  Enabled: false
705
732
 
733
+ <% if rubocop_version >= "1.52" %>
734
+ Style/RedundantArrayConstructor:
735
+ Enabled: true
736
+ <% end %>
737
+
706
738
  Style/RedundantAssignment:
707
739
  Enabled: false
708
740
 
@@ -715,6 +747,11 @@ Style/RedundantConditional:
715
747
  Style/RedundantConstantBase:
716
748
  Enabled: true
717
749
 
750
+ <% if rubocop_version >= "1.53" %>
751
+ Style/RedundantCurrentDirectoryInPath:
752
+ Enabled: true
753
+ <% end %>
754
+
718
755
  Style/RedundantDoubleSplatHashBraces:
719
756
  Enabled: true
720
757
 
@@ -727,6 +764,11 @@ Style/RedundantFetchBlock:
727
764
  Style/RedundantFileExtensionInRequire:
728
765
  Enabled: false
729
766
 
767
+ <% if rubocop_version >= "1.52" %>
768
+ Style/RedundantFilterChain:
769
+ Enabled: true
770
+ <% end %>
771
+
730
772
  Style/RedundantHeredocDelimiterQuotes:
731
773
  Enabled: true
732
774
 
@@ -736,9 +778,19 @@ Style/RedundantInitialize:
736
778
  Style/RedundantLineContinuation:
737
779
  Enabled: true
738
780
 
781
+ <% if rubocop_version >= "1.53" %>
782
+ Style/RedundantRegexpArgument:
783
+ Enabled: true
784
+ <% end %>
785
+
739
786
  Style/RedundantRegexpCharacterClass:
740
787
  Enabled: false
741
788
 
789
+ <% if rubocop_version >= "1.52" %>
790
+ Style/RedundantRegexpConstructor:
791
+ Enabled: true
792
+ <% end %>
793
+
742
794
  Style/RedundantRegexpEscape:
743
795
  Enabled: false
744
796
 
@@ -763,12 +815,22 @@ Style/RescueStandardError:
763
815
  Style/ReturnNil:
764
816
  Enabled: true
765
817
 
818
+ <% if rubocop_version >= "1.53" %>
819
+ Style/ReturnNilInPredicateMethodDefinition:
820
+ Enabled: true
821
+ <% end %>
822
+
766
823
  Style/SelectByRegexp:
767
824
  Enabled: false
768
825
 
769
826
  Style/SingleArgumentDig:
770
827
  Enabled: false
771
828
 
829
+ <% if rubocop_version >= "1.57" %>
830
+ Style/SingleLineDoEndBlock:
831
+ Enabled: true
832
+ <% end %>
833
+
772
834
  Style/SlicingWithRange:
773
835
  Enabled: false
774
836
 
@@ -793,6 +855,11 @@ Style/StringLiteralsInInterpolation:
793
855
  Style/StructInheritance:
794
856
  Enabled: false
795
857
 
858
+ <% if rubocop_version >= "1.58" %>
859
+ Style/SuperWithArgsParentheses:
860
+ Enabled: true
861
+ <% end %>
862
+
796
863
  Style/SwapValues:
797
864
  Enabled: false
798
865
 
@@ -823,5 +890,10 @@ Style/UnpackFirst:
823
890
  Style/WordArray:
824
891
  EnforcedStyle: brackets
825
892
 
893
+ <% if rubocop_version >= "1.53" %>
894
+ Style/YAMLFileRead:
895
+ Enabled: true
896
+ <% end %>
897
+
826
898
  Style/YodaCondition:
827
899
  Enabled: false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-shopify
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-09 00:00:00.000000000 Z
11
+ date: 2024-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -32,13 +32,16 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - LICENSE.md
35
+ - README.md
36
+ - lib/rubocop/shopify/gem_version_string_comparable_backport.rb
37
+ - lib/tasks/config.rake
35
38
  - rubocop-cli.yml
36
39
  - rubocop.yml
37
40
  homepage: https://shopify.github.io/ruby-style-guide/
38
41
  licenses:
39
42
  - MIT
40
43
  metadata:
41
- source_code_uri: https://github.com/Shopify/ruby-style-guide/tree/v2.14.0
44
+ source_code_uri: https://github.com/Shopify/ruby-style-guide/tree/v2.15.1
42
45
  allowed_push_host: https://rubygems.org
43
46
  post_install_message:
44
47
  rdoc_options: []
@@ -55,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
58
  - !ruby/object:Gem::Version
56
59
  version: '0'
57
60
  requirements: []
58
- rubygems_version: 3.4.13
61
+ rubygems_version: 3.5.6
59
62
  signing_key:
60
63
  specification_version: 4
61
64
  summary: Shopify's style guide for Ruby.