You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running rubocop on a file that contains a leftover rubocop:enable all directive, rubocop triggers an error instead of a cop warning.
Steps to reproduce the problem
Create a file containing:
puts
# rubocop:enable all
Run Rubocop on that file
$ rubocop file.rb
Expected behavior
Inspecting 1 file
.
1 file inspected, no offenses detected
... or alternatively
1 file inspected, 1 offense detected
Unnecessary `rubocop:enable` directive found
... or something to that effect.
Actual behavior
Inspecting 1 file
An error occurred while Lint/UnneededCopEnableDirective cop was inspecting /Users/jakob/file.rb.
To see the complete backtrace run rubocop -d.
.
1 file inspected, no offenses detected
1 error occurred:
An error occurred while Lint/UnneededCopEnableDirective cop was inspecting /Users/jakob/file.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/bbatsov/rubocop/issues
Mention the following information in the issue report:
0.54.0 (using Parser 2.5.0.4, running on ruby 2.5.0 x86_64-darwin15)
With debugging flag
$ rubocop -d file.rb
For /Users/jakob: configuration from ~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/config/default.yml
Inheriting configuration from ~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/config/enabled.yml
Inheriting configuration from ~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/config/disabled.yml
Inspecting 1 file
Scanning ~/file.rb
An error occurred while Lint/UnneededCopEnableDirective cop was inspecting ~/file.rb.
nil can't be coerced into Integer
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb:47:in `+'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb:47:in `range_of_offense'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb:32:in `block in investigate'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb:29:in `each'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb:29:in `investigate'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in invoke_custom_processing'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/commissioner.rb:109:in `with_cop_error_handling'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/commissioner.rb:99:in `block in invoke_custom_processing'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/commissioner.rb:96:in `each'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/commissioner.rb:96:in `invoke_custom_processing'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/commissioner.rb:58:in `investigate'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/team.rb:114:in `investigate'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/team.rb:102:in `offenses'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cop/team.rb:44:in `inspect_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:259:in `inspect_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:206:in `block in do_inspection_loop'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:238:in `block in iterate_until_no_changes'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:231:in `loop'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:231:in `iterate_until_no_changes'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:202:in `do_inspection_loop'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:111:in `block in file_offenses'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:121:in `file_offense_cache'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:109:in `file_offenses'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:100:in `process_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:78:in `block in each_inspected_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:75:in `each'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:75:in `reduce'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:75:in `each_inspected_file'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:67:in `inspect_files'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/runner.rb:39:in `run'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cli.rb:156:in `execute_runner'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cli.rb:84:in `execute_runners'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/lib/rubocop/cli.rb:41:in `run'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/bin/rubocop:13:in `block in <top (required)>'
~/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
~/.rvm/gems/ruby-2.5.0/gems/rubocop-0.54.0/bin/rubocop:12:in `<top (required)>'
~/.rvm/gems/ruby-2.5.0/bin/rubocop:23:in `load'
~/.rvm/gems/ruby-2.5.0/bin/rubocop:23:in `<main>'
~/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `eval'
~/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:15:in `<main>'
.
1 file inspected, no offenses detected
1 error occurred:
An error occurred while Lint/UnneededCopEnableDirective cop was inspecting ~/file.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/bbatsov/rubocop/issues
Mention the following information in the issue report:
0.54.0 (using Parser 2.5.0.4, running on ruby 2.5.0 x86_64-darwin15)
Finished in 0.2657470899866894 seconds
When running rubocop on a file that contains a leftover
rubocop:enable all
directive, rubocop triggers an error instead of a cop warning.Steps to reproduce the problem
Expected behavior
... or alternatively
... or something to that effect.
Actual behavior
With debugging flag
RuboCop version
The text was updated successfully, but these errors were encountered: