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

Error setting severity level to info #9444

Closed
dduugg opened this issue Jan 28, 2021 · 3 comments · Fixed by #9447
Closed

Error setting severity level to info #9444

dduugg opened this issue Jan 28, 2021 · 3 comments · Fixed by #9447
Assignees

Comments

@dduugg
Copy link
Contributor

dduugg commented Jan 28, 2021

I'm attempting to use the info severity level introduced in 1.9.0, but getting an error (apologies if I'm misunderstanding something).


Expected behavior

rubocop runs without error

Actual behavior

rubocop prints a stack trace

Steps to reproduce the problem

Create an empty file:

$ touch a.rb

Create the following .rubocop.yml file:

AllCops:
  NewCops: disable
Lint/EmptyFile:
  Severity: info

Then:

rubocop a.rb --only Lint/EmptyFile
Inspecting 1 file


Offenses:

undefined method `codes' for nil:NilClass
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rainbow-3.0.0/lib/rainbow/presenter.rb:20:in `color'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/colorizable.rb:22:in `colorize'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/simple_text_formatter.rb:80:in `colored_severity_code'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/clang_style_formatter.rb:23:in `report_offense'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/clang_style_formatter.rb:12:in `block in report_file'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/clang_style_formatter.rb:12:in `each'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/clang_style_formatter.rb:12:in `report_file'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/progress_formatter.rb:42:in `block in finished'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/progress_formatter.rb:41:in `each'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/progress_formatter.rb:41:in `finished'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/formatter_set.rb:34:in `public_send'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/formatter_set.rb:34:in `block (3 levels) in <class:FormatterSet>'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/formatter_set.rb:34:in `each'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/formatter_set.rb:34:in `block (2 levels) in <class:FormatterSet>'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:95:in `ensure in inspect_files'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:96:in `inspect_files'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:47:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command.rb:11:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/environment.rb:18:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:65:in `run_command'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:72:in `execute_runners'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:41:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/exe/rubocop:13:in `block in <top (required)>'
/path/to/.rbenv/versions/2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/exe/rubocop:12:in `<top (required)>'
/path/to/.rbenv/versions/2.7.2/bin/rubocop:23:in `load'
/path/to/.rbenv/versions/2.7.2/bin/rubocop:23:in `<main>'

RuboCop version

$ rubocop -V
1.9.0 (using Parser 3.0.0.0, rubocop-ast 1.4.0, running on ruby 2.7.2 x86_64-darwin20)
@dvandersluis
Copy link
Member

Which formatter are you using?

@dduugg
Copy link
Contributor Author

dduugg commented Jan 28, 2021

@dvandersluis how can one determine that?

Here's the output with the -d flag (apologies for omitting that in the bug report) and an explicit --format simple:

rubocop a.rb -d --only Lint/EmptyFile --format simple
Scanning /path/to/git/a.rb
For /path/to/git: configuration from /path/to/git/.rubocop.yml
Default configuration from /path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/config/default.yml
Loading cache from /path/to/.cache/rubocop_cache/391692be9e0b7c692be95653de289b60a53e40f2/243e5d8f13b2b8dcfe69df0f0382b49192998b5c/e40d45030dec026f54a2d8fd953453f03f9a1356
== a.rb ==

0 files inspected, 1 offense detected
undefined method `codes' for nil:NilClass
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rainbow-3.0.0/lib/rainbow/presenter.rb:20:in `color'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/colorizable.rb:22:in `colorize'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/simple_text_formatter.rb:80:in `colored_severity_code'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/simple_text_formatter.rb:49:in `block in report_file'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/simple_text_formatter.rb:46:in `each'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/simple_text_formatter.rb:46:in `report_file'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/simple_text_formatter.rb:33:in `file_finished'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/formatter_set.rb:50:in `block in file_finished'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/formatter_set.rb:50:in `each'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/formatter/formatter_set.rb:50:in `file_finished'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:218:in `file_finished'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:127:in `process_file'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `reduce'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:86:in `inspect_files'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/runner.rb:47:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/command.rb:11:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli/environment.rb:18:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:65:in `run_command'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:72:in `execute_runners'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/lib/rubocop/cli.rb:41:in `run'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/exe/rubocop:13:in `block in <top (required)>'
/path/to/.rbenv/versions/2.7.2/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/path/to/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rubocop-1.9.0/exe/rubocop:12:in `<top (required)>'
/path/to/.rbenv/versions/2.7.2/bin/rubocop:23:in `load'
/path/to/.rbenv/versions/2.7.2/bin/rubocop:23:in `<main>'
Finished in 0.12633200001437217 seconds

@dvandersluis dvandersluis self-assigned this Jan 28, 2021
@dvandersluis
Copy link
Member

Thanks @dduugg I just wanted to check if you were explicitly using a formatter or not for more context. I'll look into this.

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jan 28, 2021
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue Jan 28, 2021
dvandersluis added a commit that referenced this issue Jan 28, 2021
[Fix #9444] Fix error on colorization for offenses with `Severity: info`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants