From 67eca3f58d8d75afe8e4574e3908eb772ad69a0e Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 9 Jan 2020 13:14:32 -0500 Subject: [PATCH 1/2] Upgrade rubocop and style guide for ruby 2.7 compatibility --- ...ify-github-io-ruby-style-guide-rubocop-yml | 46 ++++++++++--------- .rubocop_todo.yml | 4 +- Gemfile | 2 +- lib/liquid/parser_switching.rb | 4 +- performance/shopify/shop_filter.rb | 2 +- test/integration/render_profiling_test.rb | 4 +- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml b/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml index f5bbf72..6cb8e45 100644 --- a/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +++ b/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml @@ -1,3 +1,5 @@ +# Recommended rubocop version: ~> 0.78.0 + AllCops: Exclude: - 'db/schema.rb' @@ -20,7 +22,7 @@ Style/Alias: - prefer_alias - prefer_alias_method -Layout/AlignHash: +Layout/HashAlignment: EnforcedHashRocketStyle: key EnforcedColonStyle: key EnforcedLastArgumentHashStyle: ignore_implicit @@ -30,7 +32,7 @@ Layout/AlignHash: - ignore_implicit - ignore_explicit -Layout/AlignParameters: +Layout/ParameterAlignment: EnforcedStyle: with_fixed_indentation SupportedStyles: - with_first_parameter @@ -172,7 +174,7 @@ Naming/FileName: Regex: IgnoreExecutableScripts: true -Layout/IndentFirstArgument: +Layout/FirstArgumentIndentation: EnforcedStyle: consistent SupportedStyles: - consistent @@ -225,7 +227,7 @@ Layout/IndentationConsistency: Layout/IndentationWidth: Width: 2 -Layout/IndentFirstArrayElement: +Layout/FirstArrayElementIndentation: EnforcedStyle: consistent SupportedStyles: - special_inside_parentheses @@ -233,10 +235,10 @@ Layout/IndentFirstArrayElement: - align_brackets IndentationWidth: -Layout/IndentAssignment: +Layout/AssignmentIndentation: IndentationWidth: -Layout/IndentFirstHashElement: +Layout/FirstHashElementIndentation: EnforcedStyle: consistent SupportedStyles: - special_inside_parentheses @@ -340,9 +342,9 @@ Style/PercentQLiterals: Naming/PredicateName: NamePrefix: - is_ - NamePrefixBlacklist: + ForbiddenPrefixes: - is_ - NameWhitelist: + AllowedMethods: - is_a? Exclude: - 'spec/**/*' @@ -467,7 +469,7 @@ Style/TernaryParentheses: - require_no_parentheses AllowSafeAssignment: true -Layout/TrailingBlankLines: +Layout/TrailingEmptyLines: EnforcedStyle: final_newline SupportedStyles: - final_newline @@ -478,7 +480,7 @@ Style/TrivialAccessors: AllowPredicates: true AllowDSLWriters: false IgnoreClassMethods: false - Whitelist: + AllowedMethods: - to_ary - to_a - to_c @@ -509,7 +511,7 @@ Style/WhileUntilModifier: Metrics/BlockNesting: Max: 3 -Metrics/LineLength: +Layout/LineLength: Max: 120 AllowHeredoc: true AllowURI: true @@ -561,7 +563,7 @@ Lint/UnusedMethodArgument: Naming/AccessorMethodName: Enabled: true -Layout/AlignArray: +Layout/ArrayAlignment: Enabled: true Style/ArrayJoin: @@ -819,13 +821,13 @@ Layout/TrailingWhitespace: Style/UnlessElse: Enabled: true -Style/UnneededCapitalW: +Style/RedundantCapitalW: Enabled: true -Style/UnneededInterpolation: +Style/RedundantInterpolation: Enabled: true -Style/UnneededPercentQ: +Style/RedundantPercentQ: Enabled: true Style/VariableInterpolation: @@ -840,7 +842,7 @@ Style/WhileUntilDo: Style/ZeroLengthPredicate: Enabled: true -Layout/IndentHeredoc: +Layout/HeredocIndentation: EnforcedStyle: squiggly Lint/AmbiguousOperator: @@ -864,7 +866,7 @@ Lint/DeprecatedClassMethods: Lint/DuplicateMethods: Enabled: true -Lint/DuplicatedKey: +Lint/DuplicateHashKey: Enabled: true Lint/EachWithObjectArgument: @@ -891,7 +893,7 @@ Lint/FloatOutOfRange: Lint/FormatParameterMismatch: Enabled: true -Lint/HandleExceptions: +Lint/SuppressedException: AllowComments: true Lint/ImplicitStringConcatenation: @@ -947,7 +949,7 @@ Lint/ShadowedException: Lint/ShadowingOuterLocalVariable: Enabled: true -Lint/StringConversionInInterpolation: +Lint/RedundantStringCoercion: Enabled: true Lint/UnderscorePrefixedVariableName: @@ -956,13 +958,13 @@ Lint/UnderscorePrefixedVariableName: Lint/UnifiedInteger: Enabled: true -Lint/UnneededCopDisableDirective: +Lint/RedundantCopDisableDirective: Enabled: true -Lint/UnneededCopEnableDirective: +Lint/RedundantCopEnableDirective: Enabled: true -Lint/UnneededSplatExpansion: +Lint/RedundantSplatExpansion: Enabled: true Lint/UnreachableCode: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 34a2e24..fc0daf1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -18,7 +18,7 @@ Lint/InheritException: # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https -Metrics/LineLength: +Layout/LineLength: Max: 294 # Offense count: 44 @@ -45,4 +45,4 @@ Style/ClassVars: Exclude: - 'lib/liquid/condition.rb' - 'lib/liquid/strainer.rb' - - 'lib/liquid/template.rb' \ No newline at end of file + - 'lib/liquid/template.rb' diff --git a/Gemfile b/Gemfile index f520934..14537c6 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ group :benchmark, :test do end group :test do - gem 'rubocop', '~> 0.74.0', require: false + gem 'rubocop', '~> 0.78.0', require: false gem 'rubocop-performance', require: false platform :mri, :truffleruby do diff --git a/lib/liquid/parser_switching.rb b/lib/liquid/parser_switching.rb index e2f8546..1a8d4ff 100644 --- a/lib/liquid/parser_switching.rb +++ b/lib/liquid/parser_switching.rb @@ -8,10 +8,10 @@ module Liquid when :lax then lax_parse(markup) when :warn begin - return strict_parse_with_error_context(markup) + strict_parse_with_error_context(markup) rescue SyntaxError => e parse_context.warnings << e - return lax_parse(markup) + lax_parse(markup) end end end diff --git a/performance/shopify/shop_filter.rb b/performance/shopify/shop_filter.rb index f555862..3558c6f 100644 --- a/performance/shopify/shop_filter.rb +++ b/performance/shopify/shop_filter.rb @@ -60,7 +60,7 @@ module ShopFilter case style when 'original' - return '/files/shops/random_number/' + url + '/files/shops/random_number/' + url when 'grande', 'large', 'medium', 'compact', 'small', 'thumb', 'icon' "/files/shops/random_number/products/#{Regexp.last_match(1)}_#{style}.#{Regexp.last_match(2)}" else diff --git a/test/integration/render_profiling_test.rb b/test/integration/render_profiling_test.rb index 2d46061..d5ee6c6 100644 --- a/test/integration/render_profiling_test.rb +++ b/test/integration/render_profiling_test.rb @@ -159,13 +159,13 @@ class RenderProfilingTest < Minitest::Test t.render!("collection" => ["one", "two"]) leaf = t.profiler[0].children[0] - assert_operator leaf.self_time, :>, 0 + assert_operator(leaf.self_time, :>, 0) end def test_profiling_supports_total_time t = Template.parse("{% if true %} {% increment test %} {{ test }} {% endif %}", profile: true) t.render! - assert_operator t.profiler[0].total_time, :>, 0 + assert_operator(t.profiler[0].total_time, :>, 0) end end From b3ad54c0c2116c1061d106487033d7ffc0216b50 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 9 Jan 2020 12:46:12 -0500 Subject: [PATCH 2/2] Test against the latest ruby in CI --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1ab03f5..6d7d0a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,9 @@ cache: bundler rvm: - 2.4 - 2.5 - - &latest_ruby 2.6 + - 2.6 + - &latest_ruby 2.7 + - ruby-head matrix: include: