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 in Style/RedundantParentheses #3154

Closed
lordofthelake opened this issue May 22, 2016 · 1 comment
Closed

Error in Style/RedundantParentheses #3154

lordofthelake opened this issue May 22, 2016 · 1 comment

Comments

@lordofthelake
Copy link

Expected behavior

Rubocop should just lint the file and not throw an error.

Actual behavior

An error occurs in the Style/RedudantParenthesis cop while linting the file, with the following error message:

Inspecting 1 file
An error occurred while Style/RedundantParentheses cop was inspecting /path/to/test.rb.
To see the complete backtrace run rubocop -d.
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Style/RedundantParentheses cop was inspecting /path/to/test.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.40.0 (using Parser 2.3.1.0, running on ruby 2.3.1 x86_64-darwin15)

Steps to reproduce the problem

  1. Create a test file with the following content:

    def foo(bar)
      (bar || ()).nil?
    end
  2. Run rubocop test.rb

RuboCop version

$ rubocop -V
0.40.0 (using Parser 2.3.1.0, running on ruby 2.3.1 x86_64-darwin15)
@amencarini
Copy link

amencarini commented May 26, 2016

Just encountered the same issue.
The -d run adds the following:

Scanning /Users/amencarini/Projects/ruby/test_file.rb
An error occurred while Style/RedundantParentheses cop was inspecting /Users/amencarini/Projects/ruby/test_file.rb.
undefined method `hash_type?' for nil:NilClass
/Users/amencarini/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.40.0/lib/rubocop/cop/style/redundant_parentheses.rb:41:in `parens_allowed?'
/Users/amencarini/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.40.0/lib/rubocop/cop/style/redundant_parentheses.rb:30:in `on_begin'
/Users/amencarini/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rubocop-0.40.0/lib/rubocop/cop/commissioner.rb:42:in `block (2 levels) in on_begin'

bbatsov added a commit that referenced this issue May 26, 2016
[Fix #3154] Fix handling of () in RedundantParentheses
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
`Style/RedundantParentheses` doesn't crash when handling `()`.
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