Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stray rubocop:enable directive causes Rubocop to fail #5708

Closed
koppen opened this issue Mar 21, 2018 · 0 comments
Closed

Stray rubocop:enable directive causes Rubocop to fail #5708

koppen opened this issue Mar 21, 2018 · 0 comments
Labels

Comments

@koppen
Copy link

koppen commented Mar 21, 2018

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

  1. Create a file containing:
puts
# rubocop:enable all
  1. 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

RuboCop version

$ rubocop -V
0.54.0 (using Parser 2.5.0.4, running on ruby 2.5.0 x86_64-darwin15)
@Drenmi Drenmi added the bug label Mar 21, 2018
balbesina added a commit to balbesina/rubocop that referenced this issue May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants