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

Can't run Rubocop with only Lint/Syntax cop. #2324

Closed
savef opened this issue Oct 16, 2015 · 2 comments
Closed

Can't run Rubocop with only Lint/Syntax cop. #2324

savef opened this issue Oct 16, 2015 · 2 comments
Assignees
Labels

Comments

@savef
Copy link
Contributor

savef commented Oct 16, 2015

Trying to just check syntax with Rubocop using the command rubocop --only Lint/Syntax fails with "Unrecognised cop or namespace".

I was able to only run the syntax cop with rubocop --only "", but this looks very hacky so I don't think it's a solution. (Note that rubocop --only fails trying to call Array#split on nil, this might want to be fixed, to behave the same as passing "").

After some very quick digging it seems the issue with the missing cop is due to RuboCop::Cop::Cop.all not exposing Lint/Syntax as a real cop, I imagine there are various reasons for this so I doubt changing that is the solution, and popping Lint/Syntax onto the cops array only in RuboCop::Options might get messy. Therefore I think the simplest solution might be to add a new switch such as rubocop --syntax, that only runs the syntax checker and exits (being functionally the same as what rubocop --only "" does now).

Version: 0.34.2 (using Parser 2.2.3.0, running on ruby 2.2.3 x86_64-linux)

Thanks!

@jonas054 jonas054 self-assigned this Oct 17, 2015
@jonas054 jonas054 added the bug label Oct 17, 2015
bbatsov added a commit that referenced this issue Oct 17, 2015
[Fix #2324] Handle --only Lint/Syntax and --except Lint/Syntax
@savef
Copy link
Contributor Author

savef commented Oct 19, 2015

Thanks!

@DeflateAwning
Copy link

For anyone stumbling upon this in the future, here's how to do it:

rubocop --only Lint/Syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants