Skip to content

Error running rubocop with JRuby 9.4.0.0 #7520

@UweKubosch

Description

@UweKubosch

Environment Information

jruby 9.4.0.0 (3.1.0) 2022-11-23 95c0ec1 OpenJDK 64-Bit Server VM 17.0.5+8 on 17.0.5+8 +jit [x86_64-darwin]
Darwin messerschmitt 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:12:57 PDT 2022; root:xnu-8020.240.7~1/RELEASE_X86_64 x86_64
rubocop 1.40.0 (using Parser 3.1.3.0, rubocop-ast 1.24.0, running on jruby 3.1.0) [java]

Expected Behavior

Given a ruby file example.rb

class Example
  def foo
  rescue
    bar {}
  end
end

running

rubocop example.rb

should complete with some rubocop offenses. This works fine with JRuby 9.3.9.0 and Ruby 3.1.3:

Inspecting 1 file
C

Offenses:

example.rb:1:1: C: Style/Documentation: Missing top-level documentation comment for class Example.
class Example
^^^^^^^^^^^^^
example.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
class Example
^
example.rb:3:3: C: [Correctable] Style/RescueStandardError: Avoid rescuing without specifying an error class.
  rescue
  ^^^^^^

1 file inspected, 3 offenses detected, 2 offenses autocorrectable

Actual Behavior

With JRuby 9.4.0.0 there is an error:

For example_directory: Default configuration from ~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/config/default.yml
Inspecting 1 file
Scanning example.rb
An error occurred while VariableForce cop was inspecting example.rb.
no receiver given
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:106:in `block in visit_descendants'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
org/jruby/RubyArray.java:1988:in `each'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:105:in `visit_descendants'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:107:in `block in visit_descendants'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
org/jruby/RubyArray.java:1988:in `each'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:105:in `visit_descendants'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:60:in `each_descendant'
org/jruby/RubyEnumerator.java:397:in `each'
org/jruby/RubyEnumerable.java:1785:in `any?'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:252:in `block in process_rescue'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
org/jruby/RubyArray.java:1988:in `each'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
org/jruby/RubyEnumerator.java:397:in `each'
org/jruby/RubyEnumerable.java:1785:in `any?'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:251:in `process_rescue'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:86:in `process_node'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:103:in `block in process_children'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
org/jruby/RubyArray.java:1988:in `each'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:100:in `process_children'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:95:in `inspect_variables_in_scope'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:276:in `process_scope'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:86:in `process_node'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:103:in `block in process_children'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
org/jruby/RubyArray.java:1988:in `each'
~/.gem/jruby/3.1.0/gems/rubocop-ast-1.24.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:100:in `process_children'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:95:in `inspect_variables_in_scope'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:276:in `process_scope'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:86:in `process_node'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/variable_force.rb:80:in `investigate'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/commissioner.rb:153:in `block in invoke'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/commissioner.rb:153:in `block in invoke'
org/jruby/RubyArray.java:1988:in `each'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/commissioner.rb:153:in `invoke'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/commissioner.rb:85:in `investigate'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/team.rb:154:in `investigate_partial'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cop/team.rb:82:in `investigate'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:315:in `inspect_file'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
org/jruby/RubyKernel.java:1586:in `loop'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:255:in `do_inspection_loop'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:138:in `block in file_offenses'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:163:in `file_offense_cache'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:137:in `file_offenses'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:128:in `process_file'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:109:in `block in each_inspected_file'
org/jruby/RubyArray.java:1988:in `each'
org/jruby/RubyEnumerable.java:1099:in `inject'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:108:in `each_inspected_file'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:94:in `inspect_files'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/runner.rb:47:in `run'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli/command.rb:11:in `run'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli/environment.rb:18:in `run'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli.rb:72:in `run_command'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli.rb:79:in `execute_runners'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/lib/rubocop/cli.rb:48:in `run'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/exe/rubocop:19:in `block in <main>'
~/.rubies/jruby-9.4.0.0/lib/ruby/stdlib/benchmark.rb:311:in `realtime'
~/.gem/jruby/3.1.0/gems/rubocop-1.40.0/exe/rubocop:19:in `<main>'
org/jruby/RubyKernel.java:1091:in `load'
~/.gem/jruby/3.1.0/bin/rubocop:25:in `<main>'
C

Offenses:

example.rb:1:1: C: Style/Documentation: Missing top-level documentation comment for class Example.
class Example
^^^^^^^^^^^^^
example.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
class Example
^
example.rb:3:3: C: [Correctable] Style/RescueStandardError: Avoid rescuing without specifying an error class.
  rescue
  ^^^^^^

1 file inspected, 3 offenses detected, 2 offenses autocorrectable

1 error occurred:
An error occurred while VariableForce cop was inspecting example.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.40.0 (using Parser 3.1.3.0, rubocop-ast 1.24.0, running on jruby 3.1.0) [java]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions