mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 10:52:48 -07:00
Merge pull request #1135 from Shopify/fix-failing-rubocop
Resolve failing rubocop issues
This commit is contained in:
+9
-8
@@ -1,6 +1,6 @@
|
|||||||
# This configuration was generated by
|
# This configuration was generated by
|
||||||
# `rubocop --auto-gen-config`
|
# `rubocop --auto-gen-config`
|
||||||
# on 2019-08-27 22:42:50 +1000 using RuboCop version 0.74.0.
|
# on 2019-08-29 00:43:36 +1000 using RuboCop version 0.74.0.
|
||||||
# The point is for the user to remove these configuration records
|
# The point is for the user to remove these configuration records
|
||||||
# one by one as the offenses are removed from the code base.
|
# one by one as the offenses are removed from the code base.
|
||||||
# Note that changes in the inspected code, or installation of new
|
# Note that changes in the inspected code, or installation of new
|
||||||
@@ -46,7 +46,7 @@ Layout/ClosingHeredocIndentation:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- 'test/integration/tags/for_tag_test.rb'
|
- 'test/integration/tags/for_tag_test.rb'
|
||||||
|
|
||||||
# Offense count: 25
|
# Offense count: 27
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Layout/EmptyLineAfterGuardClause:
|
Layout/EmptyLineAfterGuardClause:
|
||||||
Exclude:
|
Exclude:
|
||||||
@@ -104,7 +104,7 @@ Lint/Void:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/liquid/parse_context.rb'
|
- 'lib/liquid/parse_context.rb'
|
||||||
|
|
||||||
# Offense count: 52
|
# Offense count: 53
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 56
|
Max: 56
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ Metrics/AbcSize:
|
|||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 13
|
Max: 13
|
||||||
|
|
||||||
# Offense count: 114
|
# Offense count: 118
|
||||||
# Configuration parameters: CountComments, ExcludedMethods.
|
# Configuration parameters: CountComments, ExcludedMethods.
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Max: 38
|
Max: 38
|
||||||
@@ -144,11 +144,12 @@ Naming/UncommunicativeMethodParamName:
|
|||||||
- 'test/integration/template_test.rb'
|
- 'test/integration/template_test.rb'
|
||||||
- 'test/unit/condition_unit_test.rb'
|
- 'test/unit/condition_unit_test.rb'
|
||||||
|
|
||||||
# Offense count: 3
|
# Offense count: 5
|
||||||
# Configuration parameters: EnforcedStyle.
|
# Configuration parameters: EnforcedStyle.
|
||||||
# SupportedStyles: inline, group
|
# SupportedStyles: inline, group
|
||||||
Style/AccessModifierDeclarations:
|
Style/AccessModifierDeclarations:
|
||||||
Exclude:
|
Exclude:
|
||||||
|
- 'lib/liquid/block_body.rb'
|
||||||
- 'lib/liquid/tag.rb'
|
- 'lib/liquid/tag.rb'
|
||||||
- 'lib/liquid/tags/include.rb'
|
- 'lib/liquid/tags/include.rb'
|
||||||
- 'test/unit/strainer_unit_test.rb'
|
- 'test/unit/strainer_unit_test.rb'
|
||||||
@@ -220,7 +221,7 @@ Style/FormatStringToken:
|
|||||||
- 'test/integration/filter_test.rb'
|
- 'test/integration/filter_test.rb'
|
||||||
- 'test/integration/hash_ordering_test.rb'
|
- 'test/integration/hash_ordering_test.rb'
|
||||||
|
|
||||||
# Offense count: 103
|
# Offense count: 106
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle.
|
# Configuration parameters: EnforcedStyle.
|
||||||
# SupportedStyles: always, never
|
# SupportedStyles: always, never
|
||||||
@@ -244,7 +245,7 @@ Style/GuardClause:
|
|||||||
- 'lib/liquid/variable.rb'
|
- 'lib/liquid/variable.rb'
|
||||||
- 'test/unit/tokenizer_unit_test.rb'
|
- 'test/unit/tokenizer_unit_test.rb'
|
||||||
|
|
||||||
# Offense count: 52
|
# Offense count: 53
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: EnforcedStyle.
|
# Configuration parameters: EnforcedStyle.
|
||||||
# SupportedStyles: literals, strict
|
# SupportedStyles: literals, strict
|
||||||
@@ -336,7 +337,7 @@ Style/WhileUntilModifier:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- 'lib/liquid/tags/case.rb'
|
- 'lib/liquid/tags/case.rb'
|
||||||
|
|
||||||
# Offense count: 650
|
# Offense count: 665
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
||||||
# URISchemes: http, https
|
# URISchemes: http, https
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class Profiler
|
|||||||
@retained << "#{report.scale_bytes(report.total_retained_memsize)} (#{report.total_retained} objects)"
|
@retained << "#{report.scale_bytes(report.total_retained_memsize)} (#{report.total_retained} objects)"
|
||||||
|
|
||||||
return if ENV['CI']
|
return if ENV['CI']
|
||||||
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
report_file = File.join(REPORTS_DIR, "#{sanitize(phase)}.txt")
|
report_file = File.join(REPORTS_DIR, "#{sanitize(phase)}.txt")
|
||||||
FileUtils.mkdir_p(REPORTS_DIR)
|
FileUtils.mkdir_p(REPORTS_DIR)
|
||||||
|
|||||||
@@ -5,72 +5,72 @@ class LiquidTagTest < Minitest::Test
|
|||||||
|
|
||||||
def test_liquid_tag
|
def test_liquid_tag
|
||||||
assert_template_result('1 2 3', <<~LIQUID, 'array' => [1, 2, 3])
|
assert_template_result('1 2 3', <<~LIQUID, 'array' => [1, 2, 3])
|
||||||
{%- liquid
|
{%- liquid
|
||||||
echo array | join: " "
|
echo array | join: " "
|
||||||
-%}
|
-%}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_template_result('1 2 3', <<~LIQUID, 'array' => [1, 2, 3])
|
assert_template_result('1 2 3', <<~LIQUID, 'array' => [1, 2, 3])
|
||||||
{%- liquid
|
{%- liquid
|
||||||
for value in array
|
for value in array
|
||||||
echo value
|
echo value
|
||||||
unless forloop.last
|
unless forloop.last
|
||||||
echo " "
|
echo " "
|
||||||
endunless
|
endunless
|
||||||
endfor
|
endfor
|
||||||
-%}
|
-%}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_template_result('4 8 12 6', <<~LIQUID, 'array' => [1, 2, 3])
|
assert_template_result('4 8 12 6', <<~LIQUID, 'array' => [1, 2, 3])
|
||||||
{%- liquid
|
{%- liquid
|
||||||
for value in array
|
for value in array
|
||||||
assign double_value = value | times: 2
|
assign double_value = value | times: 2
|
||||||
echo double_value | times: 2
|
echo double_value | times: 2
|
||||||
unless forloop.last
|
unless forloop.last
|
||||||
echo " "
|
echo " "
|
||||||
endunless
|
endunless
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
echo " "
|
echo " "
|
||||||
echo double_value
|
echo double_value
|
||||||
-%}
|
-%}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_template_result('abc', <<~LIQUID)
|
assert_template_result('abc', <<~LIQUID)
|
||||||
{%- liquid echo "a" -%}
|
{%- liquid echo "a" -%}
|
||||||
b
|
b
|
||||||
{%- liquid echo "c" -%}
|
{%- liquid echo "c" -%}
|
||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_liquid_tag_errors
|
def test_liquid_tag_errors
|
||||||
assert_match_syntax_error("syntax error (line 1): Unknown tag 'error'", <<~LIQUID)
|
assert_match_syntax_error("syntax error (line 1): Unknown tag 'error'", <<~LIQUID)
|
||||||
{%- liquid error no such tag -%}
|
{%- liquid error no such tag -%}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_match_syntax_error("syntax error (line 7): Unknown tag 'error'", <<~LIQUID)
|
assert_match_syntax_error("syntax error (line 7): Unknown tag 'error'", <<~LIQUID)
|
||||||
{{ test }}
|
{{ test }}
|
||||||
|
|
||||||
{%-
|
{%-
|
||||||
liquid
|
liquid
|
||||||
for value in array
|
for value in array
|
||||||
|
|
||||||
error no such tag
|
error no such tag
|
||||||
endfor
|
endfor
|
||||||
-%}
|
-%}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_match_syntax_error("syntax error (line 2): Unknown tag '!!! the guards are vigilant'", <<~LIQUID)
|
assert_match_syntax_error("syntax error (line 2): Unknown tag '!!! the guards are vigilant'", <<~LIQUID)
|
||||||
{%- liquid
|
{%- liquid
|
||||||
!!! the guards are vigilant
|
!!! the guards are vigilant
|
||||||
-%}
|
-%}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_match_syntax_error("syntax error (line 4): 'for' tag was never closed", <<~LIQUID)
|
assert_match_syntax_error("syntax error (line 4): 'for' tag was never closed", <<~LIQUID)
|
||||||
{%- liquid
|
{%- liquid
|
||||||
for value in array
|
for value in array
|
||||||
echo 'forgot to close the for tag'
|
echo 'forgot to close the for tag'
|
||||||
-%}
|
-%}
|
||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -81,24 +81,24 @@ class LiquidTagTest < Minitest::Test
|
|||||||
|
|
||||||
def test_cannot_open_blocks_living_past_a_liquid_tag
|
def test_cannot_open_blocks_living_past_a_liquid_tag
|
||||||
assert_match_syntax_error("syntax error (line 3): 'if' tag was never closed", <<~LIQUID)
|
assert_match_syntax_error("syntax error (line 3): 'if' tag was never closed", <<~LIQUID)
|
||||||
{%- liquid
|
{%- liquid
|
||||||
if true
|
if true
|
||||||
-%}
|
-%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_quirk_can_close_blocks_created_before_a_liquid_tag
|
def test_quirk_can_close_blocks_created_before_a_liquid_tag
|
||||||
assert_template_result("42", <<~LIQUID)
|
assert_template_result("42", <<~LIQUID)
|
||||||
{%- if true -%}
|
{%- if true -%}
|
||||||
42
|
42
|
||||||
{%- liquid endif -%}
|
{%- liquid endif -%}
|
||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_liquid_tag_in_raw
|
def test_liquid_tag_in_raw
|
||||||
assert_template_result("{% liquid echo 'test' %}\n", <<~LIQUID)
|
assert_template_result("{% liquid echo 'test' %}\n", <<~LIQUID)
|
||||||
{% raw %}{% liquid echo 'test' %}{% endraw %}
|
{% raw %}{% liquid echo 'test' %}{% endraw %}
|
||||||
LIQUID
|
LIQUID
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user