Sha256: a00f13b3c5aade71404221dcdbe9087221446a4460fb7b1e01447491ff9912b8

Contents?: true

Size: 680 Bytes

Versions: 68

Compression:

Stored size: 680 Bytes

Contents

# frozen_string_literal: true

class Rewriter < Parser::Rewriter
  def on_if(node)
    # Crude, totally-not-usable-in-the-real-world code to remove optional
    # parens from control keywords.
    #
    # In a perfect test scenario we'd simply make this a no-op, to demonstrate
    # that the bug happens when any rewriter is loaded regardless of whether it
    # actually changes anything but that makes assertions much harder to get
    # right.  It's much easier to just show that the file did, or did not
    # get changed.
    if node.children[0].type == :begin
      replace node.children[0].loc.begin, ' '
      remove node.children[0].loc.end
    end

    super
  end
end

Version data entries

68 entries across 54 versions & 10 rubygems

Version Path
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
passbase-1.1.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
passbase-1.0.3 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
parser-2.7.1.5 test/bug_163/rewriter.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.0.2/test/bug_163/rewriter.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/parser-2.7.1.4/test/bug_163/rewriter.rb
parser-2.7.1.4 test/bug_163/rewriter.rb
parser-2.7.1.3 test/bug_163/rewriter.rb
parser-2.7.1.2 test/bug_163/rewriter.rb
parser-2.7.1.1 test/bug_163/rewriter.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/parser-2.7.1.0/test/bug_163/rewriter.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/parser-2.7.1.0/test/bug_163/rewriter.rb
parser-2.7.1.0 test/bug_163/rewriter.rb
parser-2.7.0.5 test/bug_163/rewriter.rb
parser-2.7.0.4 test/bug_163/rewriter.rb