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

Style/FileName with ExpectMatchingDefinition true errors on an empty file #2604

Closed
agrimm opened this issue Jan 8, 2016 · 2 comments
Closed

Comments

@agrimm
Copy link
Contributor

agrimm commented Jan 8, 2016

Given a configuration of

Style/FileName:
  ExpectMatchingDefinition: true

RuboCop gives an error for an empty file foo.rb:

Andrews-Air:[redacted] agrimm$ bundle exec rubocop --only Style/FileName -d foo.rb 
For /Users/agrimm/rails/[redacted]: configuration from /Users/agrimm/rails/[redacted]/.rubocop.yml
Default configuration from /Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/config/default.yml
Inheriting configuration from /Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/config/enabled.yml
Inheriting configuration from /Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/config/disabled.yml
Inspecting 1 file
Scanning /Users/agrimm/rails/[redacted]/foo.rb
An error occurred while Style/FileName cop was inspecting /Users/agrimm/rails/[redacted]/foo.rb.
undefined method `type' for nil:NilClass
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/util.rb:86:in `on_node'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/style/file_name.rb:69:in `find_class_or_module'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/style/file_name.rb:25:in `investigate'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/commissioner.rb:81:in `block (2 levels) in invoke_custom_processing'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/commissioner.rb:87:in `with_cop_error_handling'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/commissioner.rb:80:in `block in invoke_custom_processing'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/commissioner.rb:77:in `each'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/commissioner.rb:77:in `invoke_custom_processing'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/commissioner.rb:51:in `investigate'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cop/team.rb:36:in `inspect_file'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:193:in `inspect_file'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:163:in `block in do_inspection_loop'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:157:in `loop'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:157:in `do_inspection_loop'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:86:in `process_file'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:58:in `block in inspect_files'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:56:in `each'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:56:in `inspect_files'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/runner.rb:34:in `run'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/lib/rubocop/cli.rb:29:in `run'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/bin/rubocop:13:in `block in <top (required)>'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bundler/gems/rubocop-9f9b655d6d72/bin/rubocop:12:in `<top (required)>'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bin/rubocop:23:in `load'
/Users/agrimm/.rbenv/versions/1.9.3-p550/lib/ruby/gems/1.9.1/bin/rubocop:23:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Style/FileName cop was inspecting /Users/agrimm/rails/[redacted]/foo.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.35.1 (using Parser 2.3.0.pre.6, running on ruby 1.9.3 x86_64-darwin14.5.0)

Finished in 0.292642 seconds

RuboCop version info:

GIT
  remote: git://github.com/bbatsov/rubocop.git
  revision: 9f9b655d6d726bf46939b7c05c6095e0c23de961
@alexdowad
Copy link
Contributor

Whoops! Thanks for catching this!

@alexdowad
Copy link
Contributor

Just pushed a fix to my open PR.

@bbatsov bbatsov closed this as completed in d64d9f6 Jan 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants