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

Registering 0 sniffs must through an error #1129

Closed
dereuromark opened this issue Aug 23, 2016 · 5 comments
Closed

Registering 0 sniffs must through an error #1129

dereuromark opened this issue Aug 23, 2016 · 5 comments

Comments

@dereuromark
Copy link
Contributor

dereuromark commented Aug 23, 2016

Right now, by accident you can have a typo in the sniff name for --sniffs and it would just silently do nothing.

--standard=.../ruleset.xml --sniffs=Xyz.ControlStructures.TypoInName -v

gets you

Registering sniffs in the Xyz standard... DONE (0 sniffs registered)
...

And this is also only visible with -v, otherwise it is even cloaked and gives the false positive expression of running the selected sniffer.

There is absolutely 0 use case for having 0 sniffs and running it on sth.
Therefore it should definitely error out with "No sniffs registered/found" or sth.

@aik099
Copy link
Contributor

aik099 commented Aug 23, 2016

Maybe The X sniff not found or similar message would be better. This way user is informed that sniff he has specified doesn't exist.

@dereuromark
Copy link
Contributor Author

That would also be good.

@gsherwood
Copy link
Member

I've thought about doing this for a while but never got around to it. I agree it would be a good change.

Ideally, I'd like to add both the "no sniffs registered" error and the "invalid sniffs supplied" error.

@gsherwood
Copy link
Member

I've added an error for this to the 3.x branch. The output looks like this:

ERROR: No sniffs were registered

Run "phpcs --help" for usage information

Note that when caching is enabled, sniff restrictions are not processed, and so sniffs might be registered even though none of them are valid. There is nowhere in PHPCS to perform this sort of check without a significant performance penalty. Currently, when the error messages are replayed from the cache, they are filtered out if they don't match one of the sniff restrictions.

@ElGabbu
Copy link

ElGabbu commented Jun 14, 2017

Hi guys

I have installed codesniffer using composer on a windows machine with the intention of using it in PHP Storm.

Although I had to change the directories in phpcs.bat to point to my php.exe and phpcs I managed to get PHPStorm to validate phpcs.bat

However every time I open a php file I am getting the error mentioned by @gsherwood in his last comment.

ERROR: No sniffs were registered

Anything I could have missed or mis configured?

Thanks

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

No branches or pull requests

4 participants