rubocop
rubocop copied to clipboard
[Layout/SpaceInsideParens] Parser::Source::Range: end_pos must not be less than begin_pos with Prism 1.0.0/1.1.0
Expected behavior
rubocop --only Layout/SpaceInsideParens with Prism Ruby parser should exit without error.
Actual behavior
Target ruby file:
# 12345678901234567890123
class A
b = -> {
c(:d)
.eeeeee(
Fffffff(
"g
"
)
)
}
end
Results:
# rubocop --only Layout/SpaceInsideParens 2.rb
Inspecting 1 file
An error occurred while Layout/SpaceInsideParens cop was inspecting /2.rb.
To see the complete backtrace run rubocop -d.
.
1 file inspected, no offenses detected
1 error occurred:
An error occurred while Layout/SpaceInsideParens cop was inspecting /2.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.66.1 (using Prism 1.0.0, rubocop-ast 1.32.3, running on ruby 3.3.4) [aarch64-linux]
Results with --debug option
# rubocop -d --only Layout/SpaceInsideParens 2.rb
For /: configuration from /.rubocop.yml
Default configuration from /usr/local/bundle/gems/rubocop-1.66.1/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /2.rb
An error occurred while Layout/SpaceInsideParens cop was inspecting /2.rb.
Parser::Source::Range: end_pos must not be less than begin_pos
/usr/local/bundle/gems/parser-3.3.5.0/lib/parser/source/range.rb:39:in `initialize'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/mixin/range_help.rb:37:in `new'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/mixin/range_help.rb:37:in `range_between'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/layout/space_inside_parens.rb:108:in `block in correct_extraneous_space'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/layout/space_inside_parens.rb:100:in `each'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/layout/space_inside_parens.rb:100:in `each_cons'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/layout/space_inside_parens.rb:100:in `correct_extraneous_space'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/layout/space_inside_parens.rb:75:in `on_new_investigation'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:160:in `block (2 levels) in invoke'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:160:in `block in invoke'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:160:in `each'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:160:in `invoke'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:84:in `investigate'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/team.rb:168:in `investigate_partial'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cop/team.rb:102:in `investigate'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:349:in `block in inspect_file'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:348:in `each'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:348:in `flat_map'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:348:in `inspect_file'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:291:in `block in do_inspection_loop'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:325:in `block in iterate_until_no_changes'
<internal:kernel>:187:in `loop'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:318:in `iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:287:in `do_inspection_loop'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:168:in `block in file_offenses'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:193:in `file_offense_cache'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:167:in `file_offenses'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:158:in `process_file'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:139:in `block in each_inspected_file'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:138:in `each'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:138:in `reduce'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:138:in `each_inspected_file'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:124:in `inspect_files'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/runner.rb:77:in `run'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli/command.rb:11:in `run'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli/environment.rb:18:in `run'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli.rb:122:in `run_command'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli.rb:129:in `execute_runners'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli.rb:51:in `block in run'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli.rb:81:in `profile_if_needed'
/usr/local/bundle/gems/rubocop-1.66.1/lib/rubocop/cli.rb:43:in `run'
/usr/local/bundle/gems/rubocop-1.66.1/exe/rubocop:19:in `<top (required)>'
/usr/local/bundle/bin/rubocop:25:in `load'
/usr/local/bundle/bin/rubocop:25:in `<main>'
.
1 file inspected, no offenses detected
1 error occurred:
An error occurred while Layout/SpaceInsideParens cop was inspecting /2.rb.
configuration from /.rubocop.yml
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.66.1 (using Prism 1.0.0, rubocop-ast 1.32.3, running on ruby 3.3.4) [aarch64-linux]
Finished in 0.15332154099996842 seconds
Layout/SpaceInsideParens is not included in the incompatible list of cops in #12724.
Th file can be parsed successfully with Prism (1.0.0) as follows:
# ruby -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse(open("2.rb").read)'
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [aarch64-linux]
s(:class,
s(:const, nil, :A), nil,
s(:lvasgn, :b,
s(:block,
s(:send, nil, :lambda),
s(:args),
s(:send,
s(:send, nil, :c,
s(:sym, :d)), :eeeeee,
s(:send, nil, :Fffffff,
s(:dstr,
s(:str, "g\n"),
s(:str, " ")))))))
Steps to reproduce the problem
gem install prism:1.0.0 rubocop-ast:1.32.3 rubocop:1.66.1
echo -en "AllCops:\n ParserEngine: parser_prism\n TargetRubyVersion: 3.3\n NewCops: enable" > .rubocop.yml
echo "IyDvvJHvvJLvvJPvvJTvvJXvvJbvvJfvvJjvvJnvvJDvvJHvvJLvvJPvvJTvvJXvvJbvvJfvvJjvvJnvvJDvvJHvvJLvvJMKY2xhc3MgQQogIGIgPSAtPiB7CiAgICBjKDpkKQogICAgICAuZWVlZWVlKAogICAgICAgIEZmZmZmZmYoCiAgICAgICAgICAiZwogICAgICAgICAgIgogICAgICAgICkKICAgICAgKQogIH0KZW5kCgo=" | base64 -d > 2.rb
rubocop --only Layout/SpaceInsideParens 2.rb
[2024-10-04]: rubocop 1.66.1 (using Prism 1.1.0, rubocop-ast 1.32.3, running on ruby 3.3.4) [aarch64-linux] reproduced the problem, too.
RuboCop version
$ rubocop -V
1.66.1 (using Prism 1.0.0, rubocop-ast 1.32.3, running on ruby 3.3.4) [aarch64-linux]
ruby 3.4.0preview1 (2024-05-16 master 9d69619623) [aarch64-linux] can be used to reproduced this case.