mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Fix simple RuboCop offenses and update TODO file (#1062)
* Fix Layout/EmptyLineAfterMagicComment offense * Fix Layout/ExtraSpacing offense * Fix Layout/ClosingParenthesisIndentation offenses * Fix Style/MutableConstant offense * Fix Style/UnneededInterpolation offenses * Fix Style/RedundantParentheses offenses * Update TODO config for RuboCop * Add executable bit to test/test_helper.rb ref: https://travis-ci.org/Shopify/liquid/jobs/488169512#L578
This commit is contained in:
@@ -1,30 +1,11 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2017-11-22 11:35:55 -0500 using RuboCop version 0.49.1.
|
||||
# on 2019-02-03 21:12:39 +0530 using RuboCop version 0.49.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
Layout/ClosingParenthesisIndentation:
|
||||
Exclude:
|
||||
- 'test/integration/error_handling_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Layout/EmptyLineAfterMagicComment:
|
||||
Exclude:
|
||||
- 'lib/liquid/version.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
||||
Layout/ExtraSpacing:
|
||||
Exclude:
|
||||
- 'test/integration/parsing_quirks_test.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
@@ -51,31 +32,26 @@ Lint/InheritException:
|
||||
Exclude:
|
||||
- 'lib/liquid/interrupts.rb'
|
||||
|
||||
# Offense count: 1
|
||||
Lint/ScriptPermission:
|
||||
Exclude:
|
||||
- 'test/test_helper.rb'
|
||||
|
||||
# Offense count: 52
|
||||
# Offense count: 51
|
||||
Metrics/AbcSize:
|
||||
Max: 56
|
||||
|
||||
# Offense count: 13
|
||||
# Offense count: 11
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 12
|
||||
|
||||
# Offense count: 620
|
||||
# Offense count: 639
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
Metrics/LineLength:
|
||||
Max: 294
|
||||
|
||||
# Offense count: 102
|
||||
# Offense count: 108
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/MethodLength:
|
||||
Max: 37
|
||||
|
||||
# Offense count: 9
|
||||
# Offense count: 7
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 11
|
||||
|
||||
@@ -143,23 +119,6 @@ Style/GuardClause:
|
||||
- 'lib/liquid/variable.rb'
|
||||
- 'test/unit/tokenizer_unit_test.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: SupportedStyles.
|
||||
# SupportedStyles: snake_case, camelCase
|
||||
Style/MethodName:
|
||||
EnforcedStyle: snake_case
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
Style/MutableConstant:
|
||||
Exclude:
|
||||
- 'lib/liquid/expression.rb'
|
||||
- 'lib/liquid/lexer.rb'
|
||||
- 'lib/liquid/standardfilters.rb'
|
||||
- 'lib/liquid/tags/if.rb'
|
||||
- 'lib/liquid/variable_lookup.rb'
|
||||
- 'lib/liquid/version.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
||||
@@ -190,12 +149,6 @@ Style/PercentLiteralDelimiters:
|
||||
- 'test/integration/assign_test.rb'
|
||||
- 'test/integration/standard_filter_test.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantParentheses:
|
||||
Exclude:
|
||||
- 'test/unit/condition_unit_test.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantSelf:
|
||||
@@ -227,13 +180,6 @@ Style/TernaryParentheses:
|
||||
- 'lib/liquid/context.rb'
|
||||
- 'lib/liquid/utils.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
Style/UnneededInterpolation:
|
||||
Exclude:
|
||||
- 'lib/liquid/i18n.rb'
|
||||
- 'test/integration/standard_filter_test.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/UnneededPercentQ:
|
||||
|
||||
@@ -19,7 +19,7 @@ module Liquid
|
||||
'false'.freeze => false,
|
||||
'blank'.freeze => MethodLiteral.new(:blank?, '').freeze,
|
||||
'empty'.freeze => MethodLiteral.new(:empty?, '').freeze
|
||||
}
|
||||
}.freeze
|
||||
|
||||
SINGLE_QUOTED_STRING = /\A'(.*)'\z/m
|
||||
DOUBLE_QUOTED_STRING = /\A"(.*)"\z/m
|
||||
|
||||
@@ -26,7 +26,7 @@ module Liquid
|
||||
def interpolate(name, vars)
|
||||
name.gsub(/%\{(\w+)\}/) do
|
||||
# raise TranslationError, "Undefined key #{$1} for interpolation in translation #{name}" unless vars[$1.to_sym]
|
||||
"#{vars[$1.to_sym]}"
|
||||
(vars[$1.to_sym]).to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ module Liquid
|
||||
')'.freeze => :close_round,
|
||||
'?'.freeze => :question,
|
||||
'-'.freeze => :dash
|
||||
}
|
||||
}.freeze
|
||||
IDENTIFIER = /[a-zA-Z_][\w-]*\??/
|
||||
SINGLE_STRING_LITERAL = /'[^\']*'/
|
||||
DOUBLE_STRING_LITERAL = /"[^\"]*"/
|
||||
|
||||
@@ -9,7 +9,7 @@ module Liquid
|
||||
'<'.freeze => '<'.freeze,
|
||||
'"'.freeze => '"'.freeze,
|
||||
"'".freeze => '''.freeze
|
||||
}
|
||||
}.freeze
|
||||
HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+));)/
|
||||
|
||||
# Return the size of an array or of an string
|
||||
|
||||
@@ -12,7 +12,7 @@ module Liquid
|
||||
class If < Block
|
||||
Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/o
|
||||
ExpressionsAndOperators = /(?:\b(?:\s?and\s?|\s?or\s?)\b|(?:\s*(?!\b(?:\s?and\s?|\s?or\s?)\b)(?:#{QuotedFragment}|\S+)\s*)+)/o
|
||||
BOOLEAN_OPERATORS = %w(and or)
|
||||
BOOLEAN_OPERATORS = %w(and or).freeze
|
||||
|
||||
attr_reader :blocks
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Liquid
|
||||
class VariableLookup
|
||||
SQUARE_BRACKETED = /\A\[(.*)\]\z/m
|
||||
COMMAND_METHODS = ['size'.freeze, 'first'.freeze, 'last'.freeze]
|
||||
COMMAND_METHODS = ['size'.freeze, 'first'.freeze, 'last'.freeze].freeze
|
||||
|
||||
attr_reader :name, :lookups
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# encoding: utf-8
|
||||
|
||||
module Liquid
|
||||
VERSION = "4.0.1"
|
||||
VERSION = "4.0.1".freeze
|
||||
end
|
||||
|
||||
@@ -123,7 +123,7 @@ class ErrorHandlingTest < Minitest::Test
|
||||
',
|
||||
error_mode: :warn,
|
||||
line_numbers: true
|
||||
)
|
||||
)
|
||||
|
||||
assert_equal ['Liquid syntax error (line 4): Unexpected character = in "1 =! 2"'],
|
||||
template.warnings.map(&:message)
|
||||
@@ -140,7 +140,7 @@ class ErrorHandlingTest < Minitest::Test
|
||||
',
|
||||
error_mode: :strict,
|
||||
line_numbers: true
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
assert_equal 'Liquid syntax error (line 4): Unexpected character = in "1 =! 2"', err.message
|
||||
@@ -158,7 +158,7 @@ class ErrorHandlingTest < Minitest::Test
|
||||
bla
|
||||
',
|
||||
line_numbers: true
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
assert_equal "Liquid syntax error (line 5): Unknown tag 'foo'", err.message
|
||||
|
||||
@@ -99,7 +99,7 @@ class ParsingQuirksTest < Minitest::Test
|
||||
# After the messed up quotes a filter without parameters (reverse) should work
|
||||
# but one with parameters (remove) shouldn't be detected.
|
||||
assert_template_result('here', "{{ 'hi there' | split:\"t\"\" | reverse | first}}")
|
||||
assert_template_result('hi ', "{{ 'hi there' | split:\"t\"\" | remove:\"i\" | first}}")
|
||||
assert_template_result('hi ', "{{ 'hi there' | split:\"t\"\" | remove:\"i\" | first}}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -465,9 +465,9 @@ class StandardFiltersTest < Minitest::Test
|
||||
assert_equal '07/05/2006', @filters.date("2006-07-05 10:00:00", "%m/%d/%Y")
|
||||
|
||||
assert_equal "07/16/2004", @filters.date("Fri Jul 16 01:00:00 2004", "%m/%d/%Y")
|
||||
assert_equal "#{Date.today.year}", @filters.date('now', '%Y')
|
||||
assert_equal "#{Date.today.year}", @filters.date('today', '%Y')
|
||||
assert_equal "#{Date.today.year}", @filters.date('Today', '%Y')
|
||||
assert_equal Date.today.year.to_s, @filters.date('now', '%Y')
|
||||
assert_equal Date.today.year.to_s, @filters.date('today', '%Y')
|
||||
assert_equal Date.today.year.to_s, @filters.date('Today', '%Y')
|
||||
|
||||
assert_nil @filters.date(nil, "%B")
|
||||
|
||||
|
||||
0
test/test_helper.rb
Normal file → Executable file
0
test/test_helper.rb
Normal file → Executable file
@@ -24,9 +24,9 @@ class ConditionUnitTest < Minitest::Test
|
||||
assert_evaluates_true 1, '<=', 1
|
||||
# negative numbers
|
||||
assert_evaluates_true 1, '>', -1
|
||||
assert_evaluates_true (-1), '<', 1
|
||||
assert_evaluates_true -1, '<', 1
|
||||
assert_evaluates_true 1.0, '>', -1.0
|
||||
assert_evaluates_true (-1.0), '<', 1.0
|
||||
assert_evaluates_true -1.0, '<', 1.0
|
||||
end
|
||||
|
||||
def test_default_operators_evalute_false
|
||||
|
||||
Reference in New Issue
Block a user