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

Minitest/TestFileName errors on empty files #228

Closed
movermeyer opened this issue Jan 16, 2023 · 2 comments
Closed

Minitest/TestFileName errors on empty files #228

movermeyer opened this issue Jan 16, 2023 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@movermeyer
Copy link

Expected behavior

No failures when analyzing empty files (or files with only comments)

Actual behavior

Minitest/TestFileName errors:

An error occurred while Minitest/TestFileName cop was inspecting /Users/michael.overmeyer/src/github.com/Shopify/shopify-i18n/test/empty.rb.

Running with -d flag to get additional output:

Full stack trace
rubocop -d --only=Minitest/TestFileName test/empty.rb
For /Users/michael.overmeyer/src/github.com/<redacted>: configuration from /Users/michael.overmeyer/src/github.com/<redacted>/.rubocop.yml
configuration from /Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-minitest-0.26.0/config/default.yml
configuration from /Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-minitest-0.26.0/config/default.yml
Default configuration from /Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/config/default.yml
configuration from /Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-performance-1.15.2/config/default.yml
configuration from /Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-performance-1.15.2/config/default.yml
configuration from /Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-rake-0.6.0/config/default.yml
configuration from /Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-rake-0.6.0/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /Users/michael.overmeyer/src/github.com/<redacted>/test/empty.rb
An error occurred while Minitest/TestFileName cop was inspecting /Users/michael.overmeyer/src/github.com/<redacted>/test/empty.rb.
undefined method `class_type?' for nil:NilClass

          return true if node.class_type? && test_class?(node)
                             ^^^^^^^^^^^^
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-minitest-0.26.0/lib/rubocop/cop/minitest/test_file_name.rb:32:in `test_file?'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-minitest-0.26.0/lib/rubocop/cop/minitest/test_file_name.rb:24:in `on_new_investigation'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/commissioner.rb:154:in `block (2 levels) in invoke'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/commissioner.rb:165:in `with_cop_error_handling'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/commissioner.rb:154:in `block in invoke'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/commissioner.rb:154:in `each'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/commissioner.rb:154:in `invoke'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/commissioner.rb:84:in `investigate'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/team.rb:154:in `investigate_partial'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cop/team.rb:97:in `investigate'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:322:in `inspect_file'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:266:in `block in do_inspection_loop'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:300:in `block in iterate_until_no_changes'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:293:in `loop'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:293:in `iterate_until_no_changes'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:262:in `do_inspection_loop'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:143:in `block in file_offenses'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:168:in `file_offense_cache'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:142:in `file_offenses'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:133:in `process_file'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:114:in `block in each_inspected_file'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:113:in `each'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:113:in `reduce'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:113:in `each_inspected_file'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:99:in `inspect_files'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/runner.rb:52:in `run'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli/command.rb:11:in `run'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli/environment.rb:18:in `run'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli.rb:72:in `run_command'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli.rb:79:in `execute_runners'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/lib/rubocop/cli.rb:48:in `run'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/exe/rubocop:19:in `block in <top (required)>'
/opt/rubies/3.1.2/lib/ruby/3.1.0/benchmark.rb:311:in `realtime'
/Users/michael.overmeyer/.gem/ruby/3.1.2/gems/rubocop-1.43.0/exe/rubocop:19:in `<top (required)>'
/Users/michael.overmeyer/.gem/ruby/3.1.2/bin/rubocop:25:in `load'
/Users/michael.overmeyer/.gem/ruby/3.1.2/bin/rubocop:25:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Minitest/TestFileName cop was inspecting /Users/michael.overmeyer/src/github.com/<redacted>/test/empty.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.43.0 (using Parser 3.2.0.0, rubocop-ast 1.24.1, running on ruby 3.1.2) [arm64-darwin21]
Finished in 0.21253699995577335 seconds

Describe here what actually happened.

Steps to reproduce the problem

mkdir test
touch test/empty.rb
rubocop --only=Minitest/TestFileName test/empty.rb
# Fails

echo "# Just a comment" > test/comment.rb
rubocop --only=Minitest/TestFileName test/comment.rb
# Also fails

RuboCop version

1.43.0 (using Parser 3.2.0.0, rubocop-ast 1.24.1, running on ruby 3.1.2) [arm64-darwin21]
  - rubocop-minitest 0.26.0
  - rubocop-performance 1.15.2
  - rubocop-rake 0.6.0
@movermeyer movermeyer changed the title Minitest/TestFileName fails empty files Minitest/TestFileName errors on empty files Jan 16, 2023
@koic
Copy link
Member

koic commented Jan 16, 2023

This issue is a dup with #225 and fixed by #227. I will release later.

@koic koic closed this as completed Jan 16, 2023
@koic koic added the duplicate This issue or pull request already exists label Jan 16, 2023
@koic
Copy link
Member

koic commented Jan 17, 2023

FYI, RuboCop Minitest 0.26.1 has been released:
https://github.com/rubocop/rubocop-minitest/releases/tag/v0.26.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants