Skip to content

Commit

Permalink
Fix offenses from the new version of rubocop.
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith committed Sep 25, 2015
1 parent 27c6b80 commit 704937b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ Style/ClassVars:
Style/PerlBackrefs:
Enabled: false

Style/TrivialAccessors:
AllowPredicates: true

Style/WordArray:
Enabled: false

14 changes: 7 additions & 7 deletions lib/liquid/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,44 @@ def to_liquid
end
end

class Array # :nodoc:
class Array # :nodoc:
def to_liquid
self
end
end

class Hash # :nodoc:
class Hash # :nodoc:
def to_liquid
self
end
end

class Numeric # :nodoc:
class Numeric # :nodoc:
def to_liquid
self
end
end

class Time # :nodoc:
class Time # :nodoc:
def to_liquid
self
end
end

class DateTime < Date # :nodoc:
class DateTime < Date # :nodoc:
def to_liquid
self
end
end

class Date # :nodoc:
class Date # :nodoc:
def to_liquid
self
end
end

class TrueClass
def to_liquid # :nodoc:
def to_liquid # :nodoc:
self
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/standardfilters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def escape_once(input)
end

def url_encode(input)
CGI.escape(input) rescue input
CGI.escape(input) unless input.nil?
end

def slice(input, offset, length = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/tags/cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def render(context)
iteration = context.registers[:cycle][key]
result = context.evaluate(@variables[iteration])
iteration += 1
iteration = 0 if iteration >= @variables.size
iteration = 0 if iteration >= @variables.size
context.registers[:cycle][key] = iteration
result
end
Expand Down
2 changes: 1 addition & 1 deletion lib/liquid/tags/for.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def lax_parse(markup)
def strict_parse(markup)
p = Parser.new(markup)
@variable_name = p.consume(:id)
raise SyntaxError.new(options[:locale].t("errors.syntax.for_invalid_in".freeze)) unless p.id?('in'.freeze)
raise SyntaxError.new(options[:locale].t("errors.syntax.for_invalid_in".freeze)) unless p.id?('in'.freeze)
collection_name = p.expression
@name = "#{@variable_name}-#{collection_name}"
@collection_name = Expression.parse(collection_name)
Expand Down
2 changes: 1 addition & 1 deletion liquid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.test_files = Dir.glob("{test}/**/*")
s.files = Dir.glob("{lib}/**/*") + %w(MIT-LICENSE README.md)

s.extra_rdoc_files = ["History.md", "README.md"]
s.extra_rdoc_files = ["History.md", "README.md"]

s.require_path = "lib"

Expand Down
4 changes: 2 additions & 2 deletions test/integration/tags/if_else_tag_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def test_if_or
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => true)
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => false)
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => true)
assert_template_result('', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => false)
assert_template_result('', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => false)

assert_template_result(' YES ', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => true)
assert_template_result('', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => false)
assert_template_result('', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => false)
end

def test_if_or_with_operators
Expand Down
4 changes: 2 additions & 2 deletions test/unit/context_unit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_try_first

def test_access_hashes_with_hash_notation
@context['products'] = { 'count' => 5, 'tags' => ['deepsnow', 'freestyle'] }
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }

assert_equal 5, @context['products["count"]']
assert_equal 'deepsnow', @context['products["tags"][0]']
Expand Down Expand Up @@ -305,7 +305,7 @@ def test_hash_notation_only_for_hash_access
end

def test_first_can_appear_in_middle_of_callchain
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }

assert_equal 'draft151cm', @context['product.variants[0].title']
assert_equal 'element151cm', @context['product.variants[1].title']
Expand Down

0 comments on commit 704937b

Please sign in to comment.