-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
Running rubocop on Windows 11 against a file named (rubocop_fails.rb) with the content below:
class Foo
bar do
one_line
one_line
one_line
one_line
one_line
end
endThe .rubocop.yml file (in the same folder) contains this:
AllCops:
TargetRubyVersion: 2.7.2
NewCops: enable
Metrics/BlockLength:
CountAsOne: [config]
Max: 5
Expected behavior
Rubocop should just say that the block is too long
Actual behavior
It displays the results of some cops an when inspecting Metrics/BlockLength fails with error:
1 error occurred:
An error occurred while Metrics/BlockLength cop was inspecting C:/test/rubocop_fails.rb:2:2.
Full result:
For C:/test: configuration from C:/test/.rubocop.yml
Default configuration from C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/config/default.yml
Inspecting 1 file
Scanning C:/test/rubocop_fails.rb
An error occurred while Metrics/BlockLength cop was inspecting C:/test/rubocop_fails.rb:2:2.
Unknown foldable type: :config. Valid foldable types are: array, hash, heredoc, send, csend.
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/metrics/utils/code_length_calculator.rb:54:in `block in build_foldable_checks'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/metrics/utils/code_length_calculator.rb:43:in `map'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/metrics/utils/code_length_calculator.rb:43:in `build_foldable_checks'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/metrics/utils/code_length_calculator.rb:20:in `initialize'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/mixin/code_length.rb:50:in `new'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/mixin/code_length.rb:50:in `build_code_length_calculator'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/mixin/code_length.rb:35:in `check_code_length'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/metrics/block_length.rb:56:in `on_block'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:107:in `public_send'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:105:in `each'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:69:in `on_block'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.31.2/lib/rubocop/ast/traversal.rb:154:in `on_class'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:71:in `on_class'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-ast-1.31.2/lib/rubocop/ast/traversal.rb:20:in `walk'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/commissioner.rb:87:in `investigate'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/team.rb:156:in `investigate_partial'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cop/team.rb:98:in `investigate'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:349:in `block in inspect_file'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:348:in `each'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:348:in `flat_map'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:348:in `inspect_file'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:291:in `block in do_inspection_loop'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:325:in `block in iterate_until_no_changes'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:318:in `loop'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:318:in `iterate_until_no_changes'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:287:in `do_inspection_loop'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:168:in `block in file_offenses'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:193:in `file_offense_cache'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:167:in `file_offenses'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:158:in `process_file'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:139:in `block in each_inspected_file'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:138:in `each'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:138:in `reduce'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:138:in `each_inspected_file'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:124:in `inspect_files'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/runner.rb:77:in `run'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli/command.rb:11:in `run'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli/environment.rb:18:in `run'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli.rb:118:in `run_command'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli.rb:125:in `execute_runners'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli.rb:51:in `block in run'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli.rb:77:in `profile_if_needed'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/lib/rubocop/cli.rb:43:in `run'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/exe/rubocop:19:in `block in <top (required)>'
C:/ruby/Ruby27-x64/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
C:/ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rubocop-1.63.4/exe/rubocop:19:in `<top (required)>'
C:/ruby/Ruby27-x64/bin/rubocop:32:in `load'
C:/ruby/Ruby27-x64/bin/rubocop:32:in `<main>'
C
Offenses:
rubocop_fails.rb:1:1: C: Style/Documentation: Missing top-level documentation comment for class Foo.
class Foo
^^^^^^^^^
rubocop_fails.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
class Foo
^
rubocop_fails.rb:3:1: C: [Correctable] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
1 file inspected, 3 offenses detected, 2 offenses autocorrectable
1 error occurred:
An error occurred while Metrics/BlockLength cop was inspecting C:/test/rubocop_fails.rb:2:2.
configuration from C:/test/.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.63.4 (using Parser 3.3.1.0, rubocop-ast 1.31.2, running on ruby 2.7.2) [x64-mingw32]
Finished in 0.5653301000129431 seconds
Steps to reproduce the problem
Prepare the sample ruby file and the .rubocop.yml as outlined at the beginning of this report.
Next run:
> rubocop -d .\rubocop_fails.rb
You should see the same result as outlined in the Actual behaviour section above
RuboCop version
> rubocop -V
1.63.4 (using Parser 3.3.1.0, rubocop-ast 1.31.2, running on ruby 2.7.2) [x64-mingw32]
- Note that this also fails on
ruby 3.2.2(tested)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels