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/RaiseArgs doesn't handle exception classes with just keyword arguments properly #3944

Closed
wvanbergen opened this issue Jan 20, 2017 · 1 comment · Fixed by #3946
Closed

Comments

@wvanbergen
Copy link

wvanbergen commented Jan 20, 2017

Expected behavior

When using an exception class with just keyword arguments, it should not find an offense.

raise MyError.new(keyword: argument, key: word)

Actual behavior

It finds an offense, telling me I should be using raise MyError, message instead. This is because the code simply checks if there's only 1 argument, and keyword argument always count as one.

Steps to reproduce the problem

Run rubocop on the following snippet, with Style/RaiseArgs enabled

raise MyError.new(keyword: argument, key: word)

RuboCop version

Include the output of rubocop -V. Here's an example:

rubocop -V
0.46.0 (using Parser 2.3.3.1, running on ruby 2.3.3 x86_64-darwin16)
@mikegee
Copy link
Contributor

mikegee commented Jan 21, 2017

I confirmed the reported behavior on master with the default configuration. Additionally, raise MyError.new(argument, word) produces no offense.

This seems like an inconsistency that should be allowed.

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

Successfully merging a pull request may close this issue.

2 participants