Skip to content

Commit 7845d49

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/CharacterLiteral](https://docs.rubocop.org/rubocop/cops_style.html#stylecharacterliteral) - enable [Style/ClassAndModuleChildren](https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren) - enable [Style/ClassMethodsDefinitions](https://docs.rubocop.org/rubocop/cops_style.html#styleclassmethodsdefinitions) - 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/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 7845d49

File tree

6 files changed

+53
-123
lines changed

6 files changed

+53
-123
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: 11 additions & 81 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,24 +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-
655646
Style/BlockDelimiters:
656647
Enabled: false
657648

@@ -663,27 +654,16 @@ Style/CaseEquality:
663654
Style/CaseLikeIf:
664655
Enabled: false
665656

666-
Style/CharacterLiteral:
667-
Enabled: false
668-
669-
Style/ClassAndModuleChildren:
670-
Enabled: false
671-
672657
Style/ClassCheck:
673658
Enabled: false
674659

675660
Style/ClassEqualityComparison:
676661
Enabled: false
677662

678-
Style/ClassMethods:
679-
Enabled: false
680-
681663
Style/ClassMethodsDefinitions:
664+
Enabled: true
682665
EnforcedStyle: self_class
683666

684-
Style/ClassVars:
685-
Enabled: false
686-
687667
Style/CollectionCompact:
688668
Enabled: false
689669

@@ -692,14 +672,8 @@ Style/CollectionQuerying:
692672
Enabled: true
693673
<% end %>
694674

695-
Style/ColonMethodCall:
696-
Enabled: false
697-
698-
Style/ColonMethodDefinition:
699-
Enabled: false
700-
701675
Style/CombinableDefined:
702-
Enabled: false
676+
Enabled: true
703677

704678
Style/CombinableLoops:
705679
Enabled: false
@@ -731,11 +705,11 @@ Style/ConditionalAssignment:
731705
Style/DataInheritance:
732706
Enabled: false
733707

734-
Style/DefWithParentheses:
735-
Enabled: false
708+
Style/DateTime:
709+
Enabled: true
736710

737711
Style/DigChain:
738-
Enabled: false
712+
Enabled: true
739713

740714
Style/Dir:
741715
Enabled: false
@@ -795,7 +769,7 @@ Style/EndBlock:
795769
Enabled: false
796770

797771
Style/EndlessMethod:
798-
Enabled: false
772+
Enabled: true
799773

800774
Style/EnvHome:
801775
Enabled: false
@@ -858,9 +832,6 @@ Style/FrozenStringLiteralComment:
858832
Style/GlobalStdStream:
859833
Enabled: false
860834

861-
Style/GlobalVars:
862-
Enabled: false
863-
864835
Style/GuardClause:
865836
Enabled: false
866837

@@ -887,9 +858,6 @@ Style/HashLikeCase:
887858
Style/HashSlice:
888859
Enabled: false
889860

890-
Style/HashSyntax:
891-
Enabled: false
892-
893861
Style/HashTransformKeys:
894862
Enabled: false
895863

@@ -947,7 +915,7 @@ Style/LineEndConcatenation:
947915
Enabled: false
948916

949917
Style/MagicCommentFormat:
950-
Enabled: false
918+
Enabled: true
951919
ValueCapitalization: lowercase
952920

953921
Style/MapCompactWithConditionalBlock:
@@ -976,9 +944,6 @@ Style/MethodCallWithArgsParentheses:
976944
Style/MethodCallWithoutArgsParentheses:
977945
Enabled: false
978946

979-
Style/MethodDefParentheses:
980-
Enabled: false
981-
982947
Style/MinMax:
983948
Enabled: false
984949

@@ -1140,9 +1105,6 @@ Style/RedundantArrayFlatten:
11401105
Style/RedundantAssignment:
11411106
Enabled: false
11421107

1143-
Style/RedundantBegin:
1144-
Enabled: false
1145-
11461108
Style/RedundantCapitalW:
11471109
Enabled: false
11481110

@@ -1215,12 +1177,6 @@ Style/RedundantRegexpConstructor:
12151177
Style/RedundantRegexpEscape:
12161178
Enabled: false
12171179

1218-
Style/RedundantReturn:
1219-
Enabled: false
1220-
1221-
Style/RedundantSelf:
1222-
Enabled: false
1223-
12241180
Style/RedundantSelfAssignment:
12251181
Enabled: false
12261182

@@ -1264,9 +1220,6 @@ Style/SelectByRegexp:
12641220
Style/SelfAssignment:
12651221
Enabled: false
12661222

1267-
Style/Semicolon:
1268-
Enabled: false
1269-
12701223
Style/SendWithLiteralMethodName:
12711224
Enabled: false
12721225

@@ -1305,11 +1258,9 @@ Style/StringConcatenation:
13051258

13061259
Style/StringLiterals:
13071260
Enabled: false
1308-
EnforcedStyle: double_quotes
13091261

13101262
Style/StringLiteralsInInterpolation:
13111263
Enabled: false
1312-
EnforcedStyle: double_quotes
13131264

13141265
Style/Strip:
13151266
Enabled: false
@@ -1330,24 +1281,12 @@ Style/SymbolArray:
13301281
Enabled: false
13311282
EnforcedStyle: brackets
13321283

1333-
Style/SymbolLiteral:
1334-
Enabled: false
1335-
13361284
Style/SymbolProc:
13371285
Enabled: false
13381286

13391287
Style/TernaryParentheses:
13401288
Enabled: false
13411289

1342-
Style/TrailingBodyOnClass:
1343-
Enabled: false
1344-
1345-
Style/TrailingBodyOnMethodDefinition:
1346-
Enabled: false
1347-
1348-
Style/TrailingBodyOnModule:
1349-
Enabled: false
1350-
13511290
Style/TrailingCommaInArguments:
13521291
Enabled: false
13531292
EnforcedStyleForMultiline: comma
@@ -1360,24 +1299,15 @@ Style/TrailingCommaInHashLiteral:
13601299
Enabled: false
13611300
EnforcedStyleForMultiline: consistent_comma
13621301

1363-
Style/TrailingMethodEndStatement:
1364-
Enabled: false
1365-
13661302
Style/TrailingUnderscoreVariable:
13671303
Enabled: false
13681304

13691305
Style/TrivialAccessors:
13701306
Enabled: false
13711307

1372-
Style/UnlessElse:
1373-
Enabled: false
1374-
13751308
Style/UnpackFirst:
13761309
Enabled: false
13771310

1378-
Style/VariableInterpolation:
1379-
Enabled: false
1380-
13811311
Style/WhenThen:
13821312
Enabled: false
13831313

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)