kddnewton / parser-prism

A prism backend for the whitequark/parser gem
MIT License
24 stars 4 forks source link

key not found: :PERCENT_EQUAL #1

Closed eregon closed 1 year ago

eregon commented 1 year ago

I was trying this on ruby/spec and I got this error:

$ cd rubyspec
$ git remote add eregon git@github.com:eregon/rubyspec.git
$ git checkout parser-yarp
$ bundle exec ruby -rparser/yarp/rubocop -r./check $(bundle show rubocop)/exe/rubocop --cache false language
Inspecting 157 files
[24001715.33, 24001715.33, true]
.[24001715.33, 24001715.33, true]
...
13 files inspected, no offenses detected
key not found: :PERCENT_EQUAL
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp/lexer.rb:175:in `fetch'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp/lexer.rb:175:in `to_a'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp.rb:83:in `build_tokens'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp.rb:57:in `tokenize'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:215:in `tokenize'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:210:in `parse'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:38:in `initialize'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:23:in `new'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:23:in `from_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:478:in `get_processed_source'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:273:in `do_inspection_loop'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:164:in `block in file_offenses'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:189:in `file_offense_cache'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:163:in `file_offenses'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:154:in `process_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:134:in `each'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:134:in `reduce'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:134:in `each_inspected_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:120:in `inspect_files'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:73:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command.rb:11:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/environment.rb:18:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:118:in `run_command'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:125:in `execute_runners'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:51:in `block in run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:77:in `profile_if_needed'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:43:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/exe/rubocop:19:in `block in <main>'
/home/eregon/.rubies/ruby-3.2.2/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/exe/rubocop:19:in `<main>'

And FWIW running without this gem (and changing to TargetRubyVersion: 3.3):

$ bundle exec rubocop --cache false language
Inspecting 157 files
.............................................................................................................................................................

157 files inspected, no offenses detected
bundle exec rubocop --cache false language  3.83s user 0.09s system 99% cpu 3.935 total
kddnewton commented 1 year ago

This is fixed on main now. Looks like there are 3 files left that are failing:

    - language/predefined_spec.rb
    - language/regexp/character_classes_spec.rb
    - language/rescue_spec.rb

I'll take a look later.

eregon commented 1 year ago

That was fast! As a note there are a few more errors when using command_line core language library optional security instead of language

eregon commented 1 year ago

FYI some quick perf numbers, and this is with some errors on YARP, but:

$ /usr/bin/time -v bundle exec ruby $(bundle show rubocop)/exe/rubocop --cache false command_line core language library optional security
Inspecting 4402 files
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:35.15

$ /usr/bin/time -v bundle exec ruby -rparser/yarp/rubocop $(bundle show rubocop)/exe/rubocop --cache false command_line core language library optional security
Inspecting 4402 files
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:11.40

That's like a 3x speedup on RuboCop wall clock time!

The full output on YARP with errors:

...........................................................................................................................................................................................................................................................................................................................................................................An error occurred while Lint/RequireParentheses cop was inspecting /home/eregon/code/rubyspec/core/dir/children_spec.rb:132:55.
To see the complete backtrace run rubocop -d.
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................An error occurred while Lint/ParenthesesAsGroupedExpression cop was inspecting /home/eregon/code/rubyspec/core/io/read_spec.rb:694:36.
To see the complete backtrace run rubocop -d.
An error occurred while Layout/SpaceInLambdaLiteral cop was inspecting /home/eregon/code/rubyspec/core/io/read_spec.rb:697:2.
To see the complete backtrace run rubocop -d.
An error occurred while Style/StabbyLambdaParentheses cop was inspecting /home/eregon/code/rubyspec/core/io/read_spec.rb:697:2.
To see the complete backtrace run rubocop -d.
....................................................................An error occurred while Lint/ParenthesesAsGroupedExpression cop was inspecting /home/eregon/code/rubyspec/core/kernel/eval_spec.rb:450:3.
To see the complete backtrace run rubocop -d.
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................W.......................................................................................................................................................................................................................................................................................

Offenses:

core/objectspace/define_finalizer_spec.rb:166:1: W: Lint/ImplicitStringConcatenation: Combine  and  into a single string literal, rather than using implicit string concatenation.
    RUBY

1966 files inspected, 1 offense detected