Skip to content

Commit 712cb31

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/ArgumentsForwarding](https://docs.rubocop.org/rubocop/cops_style.html#styleargumentsforwarding) - 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 712cb31

File tree

6 files changed

+57
-129
lines changed

6 files changed

+57
-129
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: 13 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,15 @@ 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:
624-
Enabled: false
621+
Enabled: true
622+
UseAnonymousForwarding: false
623+
624+
625+
Style/ArrayCoercion:
626+
Enabled: true
625627

626628
Style/ArrayIntersect:
627629
Enabled: false
@@ -634,27 +636,15 @@ Style/ArrayIntersectWithSingleElement:
634636
Style/ArrayJoin:
635637
Enabled: false
636638

637-
Style/Attr:
638-
Enabled: false
639-
640639
Style/BarePercentLiterals:
641640
Enabled: false
642641

643642
Style/BeginBlock:
644643
Enabled: false
645644

646-
Style/BisectedAttrAccessor:
647-
Enabled: false
648-
649645
Style/BitwisePredicate:
650646
Enabled: false
651647

652-
Style/BlockComments:
653-
Enabled: false
654-
655-
Style/BlockDelimiters:
656-
Enabled: false
657-
658648
Style/CaseEquality:
659649
Enabled: false
660650
AllowOnConstant: true
@@ -663,27 +653,15 @@ Style/CaseEquality:
663653
Style/CaseLikeIf:
664654
Enabled: false
665655

666-
Style/CharacterLiteral:
667-
Enabled: false
668-
669-
Style/ClassAndModuleChildren:
670-
Enabled: false
671-
672656
Style/ClassCheck:
673657
Enabled: false
674658

675659
Style/ClassEqualityComparison:
676660
Enabled: false
677661

678-
Style/ClassMethods:
679-
Enabled: false
680-
681662
Style/ClassMethodsDefinitions:
682663
EnforcedStyle: self_class
683664

684-
Style/ClassVars:
685-
Enabled: false
686-
687665
Style/CollectionCompact:
688666
Enabled: false
689667

@@ -692,14 +670,8 @@ Style/CollectionQuerying:
692670
Enabled: true
693671
<% end %>
694672

695-
Style/ColonMethodCall:
696-
Enabled: false
697-
698-
Style/ColonMethodDefinition:
699-
Enabled: false
700-
701673
Style/CombinableDefined:
702-
Enabled: false
674+
Enabled: true
703675

704676
Style/CombinableLoops:
705677
Enabled: false
@@ -731,11 +703,11 @@ Style/ConditionalAssignment:
731703
Style/DataInheritance:
732704
Enabled: false
733705

734-
Style/DefWithParentheses:
735-
Enabled: false
706+
Style/DateTime:
707+
Enabled: true
736708

737709
Style/DigChain:
738-
Enabled: false
710+
Enabled: true
739711

740712
Style/Dir:
741713
Enabled: false
@@ -795,7 +767,7 @@ Style/EndBlock:
795767
Enabled: false
796768

797769
Style/EndlessMethod:
798-
Enabled: false
770+
Enabled: true
799771

800772
Style/EnvHome:
801773
Enabled: false
@@ -858,9 +830,6 @@ Style/FrozenStringLiteralComment:
858830
Style/GlobalStdStream:
859831
Enabled: false
860832

861-
Style/GlobalVars:
862-
Enabled: false
863-
864833
Style/GuardClause:
865834
Enabled: false
866835

@@ -887,9 +856,6 @@ Style/HashLikeCase:
887856
Style/HashSlice:
888857
Enabled: false
889858

890-
Style/HashSyntax:
891-
Enabled: false
892-
893859
Style/HashTransformKeys:
894860
Enabled: false
895861

@@ -947,7 +913,7 @@ Style/LineEndConcatenation:
947913
Enabled: false
948914

949915
Style/MagicCommentFormat:
950-
Enabled: false
916+
Enabled: true
951917
ValueCapitalization: lowercase
952918

953919
Style/MapCompactWithConditionalBlock:
@@ -976,9 +942,6 @@ Style/MethodCallWithArgsParentheses:
976942
Style/MethodCallWithoutArgsParentheses:
977943
Enabled: false
978944

979-
Style/MethodDefParentheses:
980-
Enabled: false
981-
982945
Style/MinMax:
983946
Enabled: false
984947

@@ -1140,9 +1103,6 @@ Style/RedundantArrayFlatten:
11401103
Style/RedundantAssignment:
11411104
Enabled: false
11421105

1143-
Style/RedundantBegin:
1144-
Enabled: false
1145-
11461106
Style/RedundantCapitalW:
11471107
Enabled: false
11481108

@@ -1215,12 +1175,6 @@ Style/RedundantRegexpConstructor:
12151175
Style/RedundantRegexpEscape:
12161176
Enabled: false
12171177

1218-
Style/RedundantReturn:
1219-
Enabled: false
1220-
1221-
Style/RedundantSelf:
1222-
Enabled: false
1223-
12241178
Style/RedundantSelfAssignment:
12251179
Enabled: false
12261180

@@ -1264,9 +1218,6 @@ Style/SelectByRegexp:
12641218
Style/SelfAssignment:
12651219
Enabled: false
12661220

1267-
Style/Semicolon:
1268-
Enabled: false
1269-
12701221
Style/SendWithLiteralMethodName:
12711222
Enabled: false
12721223

@@ -1304,11 +1255,9 @@ Style/StringConcatenation:
13041255
Enabled: false
13051256

13061257
Style/StringLiterals:
1307-
Enabled: false
13081258
EnforcedStyle: double_quotes
13091259

13101260
Style/StringLiteralsInInterpolation:
1311-
Enabled: false
13121261
EnforcedStyle: double_quotes
13131262

13141263
Style/Strip:
@@ -1330,24 +1279,12 @@ Style/SymbolArray:
13301279
Enabled: false
13311280
EnforcedStyle: brackets
13321281

1333-
Style/SymbolLiteral:
1334-
Enabled: false
1335-
13361282
Style/SymbolProc:
13371283
Enabled: false
13381284

13391285
Style/TernaryParentheses:
13401286
Enabled: false
13411287

1342-
Style/TrailingBodyOnClass:
1343-
Enabled: false
1344-
1345-
Style/TrailingBodyOnMethodDefinition:
1346-
Enabled: false
1347-
1348-
Style/TrailingBodyOnModule:
1349-
Enabled: false
1350-
13511288
Style/TrailingCommaInArguments:
13521289
Enabled: false
13531290
EnforcedStyleForMultiline: comma
@@ -1360,24 +1297,15 @@ Style/TrailingCommaInHashLiteral:
13601297
Enabled: false
13611298
EnforcedStyleForMultiline: consistent_comma
13621299

1363-
Style/TrailingMethodEndStatement:
1364-
Enabled: false
1365-
13661300
Style/TrailingUnderscoreVariable:
13671301
Enabled: false
13681302

13691303
Style/TrivialAccessors:
13701304
Enabled: false
13711305

1372-
Style/UnlessElse:
1373-
Enabled: false
1374-
13751306
Style/UnpackFirst:
13761307
Enabled: false
13771308

1378-
Style/VariableInterpolation:
1379-
Enabled: false
1380-
13811309
Style/WhenThen:
13821310
Enabled: false
13831311

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)