Skip to content

Commit 05847cb

Browse files
committed
Enable RuboCop style cops
- enable [Style/AmbiguousEndlessMethodDefinition](https://docs.rubocop.org/rubocop/cops_style.html#styleambiguousendlessmethoddefinition) - enable [Style/AndOr](https://docs.rubocop.org/rubocop/cops_style.html#styleandor) - enable [Style/ArrayCoercion](https://docs.rubocop.org/rubocop/cops_style.html#stylearraycoercion) - enable [Style/Attr](https://docs.rubocop.org/rubocop/cops_style.html#styleattr) - enable [Style/BisectedAttrAccessor](https://docs.rubocop.org/rubocop/cops_style.html#stylebisectedattraccessor) - enable [Style/BlockComments](https://docs.rubocop.org/rubocop/cops_style.html#styleblockcomments) - enable [Style/BlockDelimiters](https://docs.rubocop.org/rubocop/cops_style.html#styleblockdelimiters) - enable [Style/CharacterLiteral](https://docs.rubocop.org/rubocop/cops_style.html#stylecharacterliteral) - enable [Style/ClassAndModuleChildren](https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren) - enable [Style/ClassMethods](https://docs.rubocop.org/rubocop/cops_style.html#styleclassmethods) - enable [Style/ClassVars](https://docs.rubocop.org/rubocop/cops_style.html#styleclassvars) - enable [Style/ColonMethodCall](https://docs.rubocop.org/rubocop/cops_style.html#stylecolonmethodcall) - enable [Style/ColonMethodDefinition](https://docs.rubocop.org/rubocop/cops_style.html#stylecolonmethoddefinition) - enable [Style/CombinableDefined](https://docs.rubocop.org/rubocop/cops_style.html#stylecombinabledefined) - enable [Style/DateTime](https://docs.rubocop.org/rubocop/cops_style.html#styledatetime) - enable [Style/DefWithParentheses](https://docs.rubocop.org/rubocop/cops_style.html#styledefwithparentheses) - enable [Style/DigChain](https://docs.rubocop.org/rubocop/cops_style.html#styledigchain) - enable [Style/EndlessMethod](https://docs.rubocop.org/rubocop/cops_style.html#styleendlessmethod) - enable [Style/GlobalVars](https://docs.rubocop.org/rubocop/cops_style.html#styleglobalvars) - enable [Style/HashSyntax](https://docs.rubocop.org/rubocop/cops_style.html#stylehashsyntax) - enable [Style/MagicCommentFormat](https://docs.rubocop.org/rubocop/cops_style.html#stylemagiccommentformat) - enable [Style/MethodDefParentheses](https://docs.rubocop.org/rubocop/cops_style.html#stylemethoddefparentheses) - enable [Style/RedundantBegin](https://docs.rubocop.org/rubocop/cops_style.html#styleredundantbegin) - enable [Style/RedundantReturn](https://docs.rubocop.org/rubocop/cops_style.html#styleredundantreturn) - enable [Style/RedundantSelf](https://docs.rubocop.org/rubocop/cops_style.html#styleredundantself) - enable [Style/Semicolon](https://docs.rubocop.org/rubocop/cops_style.html#stylesemicolon) - enable [Style/StringLiterals](https://docs.rubocop.org/rubocop/cops_style.html#stylestringliterals) - enable [Style/StringLiteralsInInterpolation](https://docs.rubocop.org/rubocop/cops_style.html#stylestringliteralsininterpolation) - enable [Style/SymbolLiteral](https://docs.rubocop.org/rubocop/cops_style.html#stylesymbolliteral) - enable [Style/TrailingBodyOnClass](https://docs.rubocop.org/rubocop/cops_style.html#styletrailingbodyonclass) - enable [Style/TrailingBodyOnMethodDefinition](https://docs.rubocop.org/rubocop/cops_style.html#styletrailingbodyonmethoddefinition) - enable [Style/TrailingBodyOnModule](https://docs.rubocop.org/rubocop/cops_style.html#styletrailingbodyonmodule) - enable [Style/TrailingMethodEndStatement](https://docs.rubocop.org/rubocop/cops_style.html#styletrailingmethodendstatement) - enable [Style/UnlessElse](https://docs.rubocop.org/rubocop/cops_style.html#styleunlesselse) - enable [Style/VariableInterpolation](https://docs.rubocop.org/rubocop/cops_style.html#stylevariableinterpolation)
1 parent f801c39 commit 05847cb

File tree

6 files changed

+52
-126
lines changed

6 files changed

+52
-126
lines changed

bin/sort-cops

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

4-
require 'yaml'
4+
require "yaml"
55

66
def extract_cop_entries(content)
77
# Extract all cop configurations (entries that start with a department name)
@@ -19,7 +19,7 @@ def extract_cop_entries(content)
1919
end
2020

2121
# Start new cop
22-
current_cop = line.split(':').first
22+
current_cop = line.split(":").first
2323
current_config = [line]
2424
elsif current_cop
2525
current_config << line

gemfiles/minimum_rubocop.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ eval_gemfile "../Gemfile"
55
# This extracts the minimum rubocop version from our gemspec,
66
# allowing us to ensure that it remains compatible.
77

8-
supported_requirement_types = ['>=', '~>']
8+
supported_requirement_types = [">=", "~>"]
99
supported_requirements, unsupported_requirements = Gem::Specification
1010
.load("rubocop-shopify.gemspec")
1111
.dependencies.find { |d| d.name == "rubocop" }

lib/rubocop/cop/lint/no_return_in_memoization.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module Lint
7474
# end
7575
# end
7676
class NoReturnInMemoization < ::RuboCop::Cop::Base
77-
MSG = 'Do not `return` in `begin..end` blocks in instance variable assignment contexts.'
77+
MSG = "Do not `return` in `begin..end` blocks in instance variable assignment contexts."
7878

7979
def on_or_asgn(node)
8080
node.each_node(:kwbegin) do |kwbegin_node|

rubocop.yml

Lines changed: 10 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,14 @@ Style/Alias:
615615
EnforcedStyle: prefer_alias_method
616616

617617
Style/AmbiguousEndlessMethodDefinition:
618-
Enabled: false
619-
620-
Style/AndOr:
621-
Enabled: false
618+
Enabled: true
622619

623620
Style/ArgumentsForwarding:
624621
Enabled: false
625622

623+
Style/ArrayCoercion:
624+
Enabled: true
625+
626626
Style/ArrayIntersect:
627627
Enabled: false
628628

@@ -634,27 +634,15 @@ Style/ArrayIntersectWithSingleElement:
634634
Style/ArrayJoin:
635635
Enabled: false
636636

637-
Style/Attr:
638-
Enabled: false
639-
640637
Style/BarePercentLiterals:
641638
Enabled: false
642639

643640
Style/BeginBlock:
644641
Enabled: false
645642

646-
Style/BisectedAttrAccessor:
647-
Enabled: false
648-
649643
Style/BitwisePredicate:
650644
Enabled: false
651645

652-
Style/BlockComments:
653-
Enabled: false
654-
655-
Style/BlockDelimiters:
656-
Enabled: false
657-
658646
Style/CaseEquality:
659647
Enabled: false
660648
AllowOnConstant: true
@@ -663,27 +651,15 @@ Style/CaseEquality:
663651
Style/CaseLikeIf:
664652
Enabled: false
665653

666-
Style/CharacterLiteral:
667-
Enabled: false
668-
669-
Style/ClassAndModuleChildren:
670-
Enabled: false
671-
672654
Style/ClassCheck:
673655
Enabled: false
674656

675657
Style/ClassEqualityComparison:
676658
Enabled: false
677659

678-
Style/ClassMethods:
679-
Enabled: false
680-
681660
Style/ClassMethodsDefinitions:
682661
EnforcedStyle: self_class
683662

684-
Style/ClassVars:
685-
Enabled: false
686-
687663
Style/CollectionCompact:
688664
Enabled: false
689665

@@ -692,14 +668,8 @@ Style/CollectionQuerying:
692668
Enabled: true
693669
<% end %>
694670

695-
Style/ColonMethodCall:
696-
Enabled: false
697-
698-
Style/ColonMethodDefinition:
699-
Enabled: false
700-
701671
Style/CombinableDefined:
702-
Enabled: false
672+
Enabled: true
703673

704674
Style/CombinableLoops:
705675
Enabled: false
@@ -731,11 +701,11 @@ Style/ConditionalAssignment:
731701
Style/DataInheritance:
732702
Enabled: false
733703

734-
Style/DefWithParentheses:
735-
Enabled: false
704+
Style/DateTime:
705+
Enabled: true
736706

737707
Style/DigChain:
738-
Enabled: false
708+
Enabled: true
739709

740710
Style/Dir:
741711
Enabled: false
@@ -795,7 +765,7 @@ Style/EndBlock:
795765
Enabled: false
796766

797767
Style/EndlessMethod:
798-
Enabled: false
768+
Enabled: true
799769

800770
Style/EnvHome:
801771
Enabled: false
@@ -858,9 +828,6 @@ Style/FrozenStringLiteralComment:
858828
Style/GlobalStdStream:
859829
Enabled: false
860830

861-
Style/GlobalVars:
862-
Enabled: false
863-
864831
Style/GuardClause:
865832
Enabled: false
866833

@@ -887,9 +854,6 @@ Style/HashLikeCase:
887854
Style/HashSlice:
888855
Enabled: false
889856

890-
Style/HashSyntax:
891-
Enabled: false
892-
893857
Style/HashTransformKeys:
894858
Enabled: false
895859

@@ -947,7 +911,7 @@ Style/LineEndConcatenation:
947911
Enabled: false
948912

949913
Style/MagicCommentFormat:
950-
Enabled: false
914+
Enabled: true
951915
ValueCapitalization: lowercase
952916

953917
Style/MapCompactWithConditionalBlock:
@@ -976,9 +940,6 @@ Style/MethodCallWithArgsParentheses:
976940
Style/MethodCallWithoutArgsParentheses:
977941
Enabled: false
978942

979-
Style/MethodDefParentheses:
980-
Enabled: false
981-
982943
Style/MinMax:
983944
Enabled: false
984945

@@ -1140,9 +1101,6 @@ Style/RedundantArrayFlatten:
11401101
Style/RedundantAssignment:
11411102
Enabled: false
11421103

1143-
Style/RedundantBegin:
1144-
Enabled: false
1145-
11461104
Style/RedundantCapitalW:
11471105
Enabled: false
11481106

@@ -1215,12 +1173,6 @@ Style/RedundantRegexpConstructor:
12151173
Style/RedundantRegexpEscape:
12161174
Enabled: false
12171175

1218-
Style/RedundantReturn:
1219-
Enabled: false
1220-
1221-
Style/RedundantSelf:
1222-
Enabled: false
1223-
12241176
Style/RedundantSelfAssignment:
12251177
Enabled: false
12261178

@@ -1264,9 +1216,6 @@ Style/SelectByRegexp:
12641216
Style/SelfAssignment:
12651217
Enabled: false
12661218

1267-
Style/Semicolon:
1268-
Enabled: false
1269-
12701219
Style/SendWithLiteralMethodName:
12711220
Enabled: false
12721221

@@ -1304,11 +1253,9 @@ Style/StringConcatenation:
13041253
Enabled: false
13051254

13061255
Style/StringLiterals:
1307-
Enabled: false
13081256
EnforcedStyle: double_quotes
13091257

13101258
Style/StringLiteralsInInterpolation:
1311-
Enabled: false
13121259
EnforcedStyle: double_quotes
13131260

13141261
Style/Strip:
@@ -1330,24 +1277,12 @@ Style/SymbolArray:
13301277
Enabled: false
13311278
EnforcedStyle: brackets
13321279

1333-
Style/SymbolLiteral:
1334-
Enabled: false
1335-
13361280
Style/SymbolProc:
13371281
Enabled: false
13381282

13391283
Style/TernaryParentheses:
13401284
Enabled: false
13411285

1342-
Style/TrailingBodyOnClass:
1343-
Enabled: false
1344-
1345-
Style/TrailingBodyOnMethodDefinition:
1346-
Enabled: false
1347-
1348-
Style/TrailingBodyOnModule:
1349-
Enabled: false
1350-
13511286
Style/TrailingCommaInArguments:
13521287
Enabled: false
13531288
EnforcedStyleForMultiline: comma
@@ -1360,24 +1295,15 @@ Style/TrailingCommaInHashLiteral:
13601295
Enabled: false
13611296
EnforcedStyleForMultiline: consistent_comma
13621297

1363-
Style/TrailingMethodEndStatement:
1364-
Enabled: false
1365-
13661298
Style/TrailingUnderscoreVariable:
13671299
Enabled: false
13681300

13691301
Style/TrivialAccessors:
13701302
Enabled: false
13711303

1372-
Style/UnlessElse:
1373-
Enabled: false
1374-
13751304
Style/UnpackFirst:
13761305
Enabled: false
13771306

1378-
Style/VariableInterpolation:
1379-
Enabled: false
1380-
13811307
Style/WhenThen:
13821308
Enabled: false
13831309

test/config_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ def test_no_cops_are_configured_as_pending
9292

9393
def test_config_does_not_check_for_rubocop_versions_below_minimum_version
9494
rubocop_version_requirement = Gem
95-
.loaded_specs.fetch('rubocop-shopify')
96-
.dependencies.find { _1.name == 'rubocop' }
95+
.loaded_specs.fetch("rubocop-shopify")
96+
.dependencies.find { _1.name == "rubocop" }
9797
.requirement
9898

9999
# 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|
100+
redundant_rubocop_version_checks = File.read("rubocop.yml").each_line.with_index.filter_map do |line, index|
101101
match = line.match(/<% if rubocop_version >= "(?<version>.*)" %>/)
102102
next unless match
103103

0 commit comments

Comments
 (0)