mirror of
https://github.com/Shopify/liquid.git
synced 2025-09-23 00:01:14 -04:00
fix a few more rubocop offenses
This commit is contained in:
parent
b347fac3c0
commit
82269e2509
@ -5,6 +5,11 @@ AllCops:
|
||||
- 'performance/shopify/*'
|
||||
- 'pkg/**'
|
||||
|
||||
Metrics/BlockNesting:
|
||||
Max: 3
|
||||
Exclude:
|
||||
- 'lib/liquid/block_body.rb'
|
||||
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
|
||||
@ -26,6 +31,9 @@ Lint/EndAlignment:
|
||||
Style/SingleLineBlockParams:
|
||||
Enabled: false
|
||||
|
||||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
|
||||
Style/StringLiteralsInInterpolation:
|
||||
Enabled: false
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# This configuration was generated by `rubocop --auto-gen-config`
|
||||
# on 2015-06-04 12:55:39 -0400 using RuboCop version 0.31.0.
|
||||
# on 2015-06-04 13:07:29 -0400 using RuboCop version 0.31.0.
|
||||
# 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
|
||||
@ -10,22 +10,10 @@
|
||||
Lint/UnusedMethodArgument:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
Lint/UselessAccessModifier:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 6
|
||||
Lint/UselessAssignment:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 51
|
||||
Metrics/AbcSize:
|
||||
Max: 58
|
||||
|
||||
# Offense count: 2
|
||||
Metrics/BlockNesting:
|
||||
Max: 6
|
||||
|
||||
# Offense count: 16
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ClassLength:
|
||||
@ -48,7 +36,7 @@ Metrics/MethodLength:
|
||||
# Offense count: 1
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ModuleLength:
|
||||
Max: 235
|
||||
Max: 234
|
||||
|
||||
# Offense count: 6
|
||||
Metrics/PerceivedComplexity:
|
||||
@ -58,8 +46,9 @@ Metrics/PerceivedComplexity:
|
||||
Style/AccessorMethodName:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
Style/DoubleNegation:
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/ClosingParenthesisIndentation:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
@ -76,7 +65,7 @@ Style/MethodName:
|
||||
Style/MultilineBlockChain:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 2
|
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
||||
Style/Next:
|
||||
Enabled: false
|
||||
@ -86,12 +75,14 @@ Style/Next:
|
||||
Style/PredicateName:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
Style/RescueModifier:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 7
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowAsExpressionSeparator.
|
||||
Style/Semicolon:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: MaxLineLength.
|
||||
Style/WhileUntilModifier:
|
||||
Enabled: false
|
||||
|
@ -7,7 +7,7 @@ module Liquid
|
||||
|
||||
def parse(tokens)
|
||||
@body = BlockBody.new
|
||||
while more = parse_body(@body, tokens)
|
||||
while parse_body(@body, tokens)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,8 +57,6 @@ module Liquid
|
||||
|
||||
alias_method :[], :invoke_drop
|
||||
|
||||
private
|
||||
|
||||
# Check for method existence without invoking respond_to?, which creates symbols
|
||||
def self.invokable?(method_name)
|
||||
invokable_methods.include?(method_name.to_s)
|
||||
|
@ -138,7 +138,6 @@ module Liquid
|
||||
# Remove duplicate elements from an array
|
||||
# provide optional property with which to determine uniqueness
|
||||
def uniq(input, property = nil)
|
||||
ary = InputIterator.new(input)
|
||||
if property.nil?
|
||||
input.uniq
|
||||
elsif input.first.respond_to?(:[])
|
||||
|
@ -16,7 +16,7 @@ module Liquid
|
||||
|
||||
def parse(tokens)
|
||||
body = BlockBody.new
|
||||
while more = parse_body(body, tokens)
|
||||
while parse_body(body, tokens)
|
||||
body = @blocks.last.attachment
|
||||
end
|
||||
end
|
||||
|
@ -41,11 +41,10 @@ module Liquid
|
||||
if filter_markup =~ /#{FilterSeparator}\s*(.*)/om
|
||||
filters = $1.scan(FilterParser)
|
||||
filters.each do |f|
|
||||
if f =~ /\w+/
|
||||
filtername = Regexp.last_match(0)
|
||||
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o).flatten
|
||||
@filters << parse_filter_expressions(filtername, filterargs)
|
||||
end
|
||||
next unless f =~ /\w+/
|
||||
filtername = Regexp.last_match(0)
|
||||
filterargs = f.scan(/(?:#{FilterArgumentSeparator}|#{ArgumentSeparator})\s*((?:\w+\s*\:\s*)?#{QuotedFragment})/o).flatten
|
||||
@filters << parse_filter_expressions(filtername, filterargs)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -74,7 +73,7 @@ module Liquid
|
||||
def render(context)
|
||||
@filters.inject(context.evaluate(@name)) do |output, (filter_name, filter_args, filter_kwargs)|
|
||||
filter_args = evaluate_filter_expressions(context, filter_args, filter_kwargs)
|
||||
output = context.invoke(filter_name, output, *filter_args)
|
||||
context.invoke(filter_name, output, *filter_args)
|
||||
end.tap{ |obj| taint_check(obj) }
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
require 'stackprof' rescue fail("install stackprof extension/gem")
|
||||
require 'stackprof'
|
||||
require_relative 'theme_runner'
|
||||
|
||||
Liquid::Template.error_mode = ARGV.first.to_sym if ARGV.first
|
||||
|
@ -83,15 +83,15 @@ class ErrorHandlingTest < Minitest::Test
|
||||
|
||||
def test_with_line_numbers_adds_numbers_to_parser_errors
|
||||
err = assert_raises(SyntaxError) do
|
||||
template = Liquid::Template.parse(%q(
|
||||
Liquid::Template.parse(%q(
|
||||
foobar
|
||||
|
||||
{% "cat" | foobar %}
|
||||
|
||||
bla
|
||||
),
|
||||
),
|
||||
line_numbers: true
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
assert_match /Liquid syntax error \(line 4\)/, err.message
|
||||
|
@ -453,7 +453,6 @@ class ContextUnitTest < Minitest::Test
|
||||
def test_use_empty_instead_of_any_in_interrupt_handling_to_avoid_lots_of_unnecessary_object_allocations
|
||||
mock_any = Spy.on_instance_method(Array, :any?)
|
||||
mock_empty = Spy.on_instance_method(Array, :empty?)
|
||||
mock_has_interrupt = Spy.on(@context, :has_interrupt?).and_call_through
|
||||
|
||||
@context.has_interrupt?
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user