diff --git a/bin/sort-cops b/bin/sort-cops index c4eaf5f9..2d04b6b2 100755 --- a/bin/sort-cops +++ b/bin/sort-cops @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require 'yaml' +require "yaml" def extract_cop_entries(content) # Extract all cop configurations (entries that start with a department name) @@ -19,7 +19,7 @@ def extract_cop_entries(content) end # Start new cop - current_cop = line.split(':').first + current_cop = line.split(":").first current_config = [line] elsif current_cop current_config << line diff --git a/gemfiles/minimum_rubocop.gemfile b/gemfiles/minimum_rubocop.gemfile index 25f38632..b461952b 100644 --- a/gemfiles/minimum_rubocop.gemfile +++ b/gemfiles/minimum_rubocop.gemfile @@ -5,7 +5,7 @@ eval_gemfile "../Gemfile" # This extracts the minimum rubocop version from our gemspec, # allowing us to ensure that it remains compatible. -supported_requirement_types = ['>=', '~>'] +supported_requirement_types = [">=", "~>"] supported_requirements, unsupported_requirements = Gem::Specification .load("rubocop-shopify.gemspec") .dependencies.find { |d| d.name == "rubocop" } diff --git a/lib/rubocop/cop/lint/no_return_in_memoization.rb b/lib/rubocop/cop/lint/no_return_in_memoization.rb index 61eff5c1..8f8eebd8 100644 --- a/lib/rubocop/cop/lint/no_return_in_memoization.rb +++ b/lib/rubocop/cop/lint/no_return_in_memoization.rb @@ -74,7 +74,7 @@ module Lint # end # end class NoReturnInMemoization < ::RuboCop::Cop::Base - MSG = 'Do not `return` in `begin..end` blocks in instance variable assignment contexts.' + MSG = "Do not `return` in `begin..end` blocks in instance variable assignment contexts." def on_or_asgn(node) node.each_node(:kwbegin) do |kwbegin_node| diff --git a/rubocop.yml b/rubocop.yml index e9191270..8b299068 100644 --- a/rubocop.yml +++ b/rubocop.yml @@ -615,14 +615,14 @@ Style/Alias: EnforcedStyle: prefer_alias_method Style/AmbiguousEndlessMethodDefinition: - Enabled: false - -Style/AndOr: - Enabled: false + Enabled: true Style/ArgumentsForwarding: Enabled: false +Style/ArrayCoercion: + Enabled: true + Style/ArrayIntersect: Enabled: false @@ -634,24 +634,15 @@ Style/ArrayIntersectWithSingleElement: Style/ArrayJoin: Enabled: false -Style/Attr: - Enabled: false - Style/BarePercentLiterals: Enabled: false Style/BeginBlock: Enabled: false -Style/BisectedAttrAccessor: - Enabled: false - Style/BitwisePredicate: Enabled: false -Style/BlockComments: - Enabled: false - Style/BlockDelimiters: Enabled: false @@ -663,27 +654,16 @@ Style/CaseEquality: Style/CaseLikeIf: Enabled: false -Style/CharacterLiteral: - Enabled: false - -Style/ClassAndModuleChildren: - Enabled: false - Style/ClassCheck: Enabled: false Style/ClassEqualityComparison: Enabled: false -Style/ClassMethods: - Enabled: false - Style/ClassMethodsDefinitions: + Enabled: true EnforcedStyle: self_class -Style/ClassVars: - Enabled: false - Style/CollectionCompact: Enabled: false @@ -692,14 +672,8 @@ Style/CollectionQuerying: Enabled: true <% end %> -Style/ColonMethodCall: - Enabled: false - -Style/ColonMethodDefinition: - Enabled: false - Style/CombinableDefined: - Enabled: false + Enabled: true Style/CombinableLoops: Enabled: false @@ -731,11 +705,11 @@ Style/ConditionalAssignment: Style/DataInheritance: Enabled: false -Style/DefWithParentheses: - Enabled: false +Style/DateTime: + Enabled: true Style/DigChain: - Enabled: false + Enabled: true Style/Dir: Enabled: false @@ -795,7 +769,7 @@ Style/EndBlock: Enabled: false Style/EndlessMethod: - Enabled: false + Enabled: true Style/EnvHome: Enabled: false @@ -858,9 +832,6 @@ Style/FrozenStringLiteralComment: Style/GlobalStdStream: Enabled: false -Style/GlobalVars: - Enabled: false - Style/GuardClause: Enabled: false @@ -887,9 +858,6 @@ Style/HashLikeCase: Style/HashSlice: Enabled: false -Style/HashSyntax: - Enabled: false - Style/HashTransformKeys: Enabled: false @@ -947,7 +915,7 @@ Style/LineEndConcatenation: Enabled: false Style/MagicCommentFormat: - Enabled: false + Enabled: true ValueCapitalization: lowercase Style/MapCompactWithConditionalBlock: @@ -976,9 +944,6 @@ Style/MethodCallWithArgsParentheses: Style/MethodCallWithoutArgsParentheses: Enabled: false -Style/MethodDefParentheses: - Enabled: false - Style/MinMax: Enabled: false @@ -1140,9 +1105,6 @@ Style/RedundantArrayFlatten: Style/RedundantAssignment: Enabled: false -Style/RedundantBegin: - Enabled: false - Style/RedundantCapitalW: Enabled: false @@ -1215,12 +1177,6 @@ Style/RedundantRegexpConstructor: Style/RedundantRegexpEscape: Enabled: false -Style/RedundantReturn: - Enabled: false - -Style/RedundantSelf: - Enabled: false - Style/RedundantSelfAssignment: Enabled: false @@ -1264,9 +1220,6 @@ Style/SelectByRegexp: Style/SelfAssignment: Enabled: false -Style/Semicolon: - Enabled: false - Style/SendWithLiteralMethodName: Enabled: false @@ -1305,11 +1258,9 @@ Style/StringConcatenation: Style/StringLiterals: Enabled: false - EnforcedStyle: double_quotes Style/StringLiteralsInInterpolation: Enabled: false - EnforcedStyle: double_quotes Style/Strip: Enabled: false @@ -1330,24 +1281,12 @@ Style/SymbolArray: Enabled: false EnforcedStyle: brackets -Style/SymbolLiteral: - Enabled: false - Style/SymbolProc: Enabled: false Style/TernaryParentheses: Enabled: false -Style/TrailingBodyOnClass: - Enabled: false - -Style/TrailingBodyOnMethodDefinition: - Enabled: false - -Style/TrailingBodyOnModule: - Enabled: false - Style/TrailingCommaInArguments: Enabled: false EnforcedStyleForMultiline: comma @@ -1360,24 +1299,15 @@ Style/TrailingCommaInHashLiteral: Enabled: false EnforcedStyleForMultiline: consistent_comma -Style/TrailingMethodEndStatement: - Enabled: false - Style/TrailingUnderscoreVariable: Enabled: false Style/TrivialAccessors: Enabled: false -Style/UnlessElse: - Enabled: false - Style/UnpackFirst: Enabled: false -Style/VariableInterpolation: - Enabled: false - Style/WhenThen: Enabled: false diff --git a/test/config_test.rb b/test/config_test.rb index db9355dd..4513a8df 100644 --- a/test/config_test.rb +++ b/test/config_test.rb @@ -92,12 +92,12 @@ def test_no_cops_are_configured_as_pending def test_config_does_not_check_for_rubocop_versions_below_minimum_version rubocop_version_requirement = Gem - .loaded_specs.fetch('rubocop-shopify') - .dependencies.find { _1.name == 'rubocop' } + .loaded_specs.fetch("rubocop-shopify") + .dependencies.find { _1.name == "rubocop" } .requirement # RuboCop version checks are done in ERB, so we need to read the raw file - redundant_rubocop_version_checks = File.read('rubocop.yml').each_line.with_index.filter_map do |line, index| + redundant_rubocop_version_checks = File.read("rubocop.yml").each_line.with_index.filter_map do |line, index| match = line.match(/<% if rubocop_version >= "(?.*)" %>/) next unless match diff --git a/test/fixtures/full_config.yml b/test/fixtures/full_config.yml index ccc85235..351bcc83 100644 --- a/test/fixtures/full_config.yml +++ b/test/fixtures/full_config.yml @@ -2498,12 +2498,12 @@ Style/Alias: Style/AmbiguousEndlessMethodDefinition: Description: Checks for endless methods inside operators of lower precedence. StyleGuide: "#ambiguous-endless-method-defintions" - Enabled: false + Enabled: true VersionAdded: '1.68' Style/AndOr: Description: Use &&/|| instead of and/or. StyleGuide: "#no-and-or-or" - Enabled: false + Enabled: true SafeAutoCorrect: false VersionAdded: '0.9' VersionChanged: '1.21' @@ -2536,7 +2536,7 @@ Style/ArrayCoercion: array. StyleGuide: "#array-coercion" Safe: false - Enabled: false + Enabled: true VersionAdded: '0.88' Style/ArrayFirstLast: Description: Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`. @@ -2572,7 +2572,7 @@ Style/AsciiComments: Style/Attr: Description: Checks for uses of Module#attr. StyleGuide: "#attr" - Enabled: false + Enabled: true VersionAdded: '0.9' VersionChanged: '0.12' Style/AutoResourceCleanup: @@ -2597,7 +2597,7 @@ Style/BeginBlock: Style/BisectedAttrAccessor: Description: Checks for places where `attr_reader` and `attr_writer` for the same method can be combined into single `attr_accessor`. - Enabled: false + Enabled: true VersionAdded: '0.87' Style/BitwisePredicate: Description: Prefer bitwise predicate methods over direct comparison operations. @@ -2608,7 +2608,7 @@ Style/BitwisePredicate: Style/BlockComments: Description: Do not use block comments. StyleGuide: "#no-block-comments" - Enabled: false + Enabled: true VersionAdded: '0.9' VersionChanged: '0.23' Style/BlockDelimiters: @@ -2667,13 +2667,13 @@ Style/CaseLikeIf: Style/CharacterLiteral: Description: Checks for uses of character literals. StyleGuide: "#no-character-literals" - Enabled: false + Enabled: true VersionAdded: '0.9' Style/ClassAndModuleChildren: Description: Checks style of children classes and modules. StyleGuide: "#namespace-definition" SafeAutoCorrect: false - Enabled: false + Enabled: true VersionAdded: '0.19' VersionChanged: '1.74' EnforcedStyle: nested @@ -2715,14 +2715,14 @@ Style/ClassEqualityComparison: Style/ClassMethods: Description: Use self when defining module/class methods. StyleGuide: "#def-self-class-methods" - Enabled: false + Enabled: true VersionAdded: '0.9' VersionChanged: '0.20' Style/ClassMethodsDefinitions: Description: Enforces using `def self.method_name` or `class << self` to define class methods. StyleGuide: "#def-self-class-methods" - Enabled: false + Enabled: true VersionAdded: '0.89' EnforcedStyle: self_class SupportedStyles: @@ -2731,7 +2731,7 @@ Style/ClassMethodsDefinitions: Style/ClassVars: Description: Avoid the use of class variables. StyleGuide: "#no-class-vars" - Enabled: false + Enabled: true VersionAdded: '0.13' Style/CollectionCompact: Description: Use `{Array,Hash}#{compact,compact!}` instead of custom logic to reject @@ -2768,17 +2768,17 @@ Style/CollectionQuerying: Style/ColonMethodCall: Description: 'Do not use :: for method call.' StyleGuide: "#double-colons" - Enabled: false + Enabled: true VersionAdded: '0.9' Style/ColonMethodDefinition: Description: 'Do not use :: for defining class methods.' StyleGuide: "#colon-method-definition" - Enabled: false + Enabled: true VersionAdded: '0.52' Style/CombinableDefined: Description: Checks successive `defined?` calls that can be combined into a single call. - Enabled: false + Enabled: true VersionAdded: '1.68' Style/CombinableLoops: Description: Checks for places where multiple consecutive loops over the same data @@ -2871,7 +2871,7 @@ Style/DataInheritance: Style/DateTime: Description: Use Time over DateTime. StyleGuide: "#date-time" - Enabled: false + Enabled: true VersionAdded: '0.51' VersionChanged: '0.92' SafeAutoCorrect: false @@ -2879,12 +2879,12 @@ Style/DateTime: Style/DefWithParentheses: Description: Use def with parentheses when there are arguments. StyleGuide: "#method-parens" - Enabled: false + Enabled: true VersionAdded: '0.9' VersionChanged: '0.12' Style/DigChain: Description: Use `dig` with multiple parameters instead of chaining multiple calls. - Enabled: false + Enabled: true Safe: false VersionAdded: '1.69' Style/Dir: @@ -3023,7 +3023,7 @@ Style/EndBlock: Style/EndlessMethod: Description: Avoid the use of multi-lined endless method definitions. StyleGuide: "#endless-methods" - Enabled: false + Enabled: true VersionAdded: '1.8' EnforcedStyle: allow_single_line SupportedStyles: @@ -3187,7 +3187,7 @@ Style/GlobalVars: StyleGuide: "#instance-vars" References: - https://www.zenspider.com/ruby/quickref.html - Enabled: false + Enabled: true VersionAdded: '0.13' AllowedVariables: [] Style/GuardClause: @@ -3253,7 +3253,7 @@ Style/HashSyntax: Description: 'Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, :b => 2 }.' StyleGuide: "#hash-literals" - Enabled: false + Enabled: true VersionAdded: '0.9' VersionChanged: '1.67' EnforcedStyle: ruby19 @@ -3449,7 +3449,7 @@ Style/LineEndConcatenation: VersionChanged: '0.64' Style/MagicCommentFormat: Description: Use a consistent style for magic comments. - Enabled: false + Enabled: true VersionAdded: '1.35' EnforcedStyle: snake_case SupportedStyles: @@ -3524,7 +3524,7 @@ Style/MethodCalledOnDoEndBlock: Style/MethodDefParentheses: Description: Checks if the method definitions have or don't have parentheses. StyleGuide: "#method-parens" - Enabled: false + Enabled: true VersionAdded: '0.16' VersionChanged: '1.7' EnforcedStyle: require_parentheses @@ -3989,7 +3989,7 @@ Style/RedundantAssignment: Style/RedundantBegin: Description: Don't use begin blocks when they are not needed. StyleGuide: "#begin-implicit" - Enabled: false + Enabled: true VersionAdded: '0.10' VersionChanged: '0.21' Style/RedundantCapitalW: @@ -4122,14 +4122,14 @@ Style/RedundantRegexpEscape: Style/RedundantReturn: Description: Don't use return where it's not required. StyleGuide: "#no-explicit-return" - Enabled: false + Enabled: true VersionAdded: '0.10' VersionChanged: '0.14' AllowMultipleReturnValues: false Style/RedundantSelf: Description: Don't use self where it's not needed. StyleGuide: "#no-self-unless-required" - Enabled: false + Enabled: true VersionAdded: '0.10' VersionChanged: '0.13' Style/RedundantSelfAssignment: @@ -4249,7 +4249,7 @@ Style/SelfAssignment: Style/Semicolon: Description: Don't use semicolons to terminate expressions. StyleGuide: "#no-semicolon" - Enabled: false + Enabled: true VersionAdded: '0.9' VersionChanged: '0.19' AllowAsExpressionSeparator: false @@ -4382,7 +4382,7 @@ Style/StringLiterals: Enabled: false VersionAdded: '0.9' VersionChanged: '0.36' - EnforcedStyle: double_quotes + EnforcedStyle: single_quotes SupportedStyles: - single_quotes - double_quotes @@ -4392,7 +4392,7 @@ Style/StringLiteralsInInterpolation: match the configured preference. Enabled: false VersionAdded: '0.27' - EnforcedStyle: double_quotes + EnforcedStyle: single_quotes SupportedStyles: - single_quotes - double_quotes @@ -4443,7 +4443,7 @@ Style/SymbolArray: - brackets Style/SymbolLiteral: Description: Use plain symbols instead of string symbols when possible. - Enabled: false + Enabled: true VersionAdded: '0.30' Style/SymbolProc: Description: Use symbols as procs instead of blocks when possible. @@ -4474,15 +4474,15 @@ Style/TopLevelMethodDefinition: VersionAdded: '1.15' Style/TrailingBodyOnClass: Description: Class body goes below class statement. - Enabled: false + Enabled: true VersionAdded: '0.53' Style/TrailingBodyOnMethodDefinition: Description: Method body goes below definition. - Enabled: false + Enabled: true VersionAdded: '0.52' Style/TrailingBodyOnModule: Description: Module body goes below module statement. - Enabled: false + Enabled: true VersionAdded: '0.53' Style/TrailingCommaInArguments: Description: Checks for trailing comma in argument lists. @@ -4523,7 +4523,7 @@ Style/TrailingCommaInHashLiteral: VersionAdded: '0.53' Style/TrailingMethodEndStatement: Description: Checks for trailing end statement on line of method body. - Enabled: false + Enabled: true VersionAdded: '0.52' Style/TrailingUnderscoreVariable: Description: Checks for the usage of unneeded trailing underscores at the end of @@ -4563,7 +4563,7 @@ Style/TrivialAccessors: Style/UnlessElse: Description: Do not use unless with else. Rewrite these with the positive case first. StyleGuide: "#no-else-with-unless" - Enabled: false + Enabled: true VersionAdded: '0.9' Style/UnlessLogicalOperators: Description: Checks for use of logical operators in an unless condition. @@ -4582,7 +4582,7 @@ Style/VariableInterpolation: Description: Don't interpolate global, instance and class variables directly in strings. StyleGuide: "#curlies-interpolate" - Enabled: false + Enabled: true VersionAdded: '0.9' VersionChanged: '0.20' Style/WhenThen: