-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Ability to pass filename on CLI when checking STDIN #934
Comments
All those methods work exactly the same. I think you're being confused by the CakePHP standard itself. Check here: https://github.com/cakephp/cakephp-codesniffer/blob/master/CakePHP/ruleset.xml#L102 You can see that the CakePHP standard does include those ValidFunctionName sniffs from the Squiz and PEAR standards. So the CakePHP standard is absolutely being run in all your test cases. But also note that both those sniffs are excluded if the file exists in In a future PHPCS version (3.0, still unreleased) you'll be able to get filtering working correctly as long as your editor plugin is telling PHPCS where the file actually exists. There is more info on the feature request here: #733 Does it make sense why using STDIN is showing different results now? |
Thanks!! Thank you again for your work! |
@gsherwood Speaking on behalf of Flycheck, we'd prefer if we could keep standard input for phpcs, as it makes many things simpler. It'd be great if we had a way to give phpcs a filename it should assume for standard input. Many other popular linters (rubocop, eslint, etc.) provide a command line option for this purpose. |
@lunaryorn Support for STDIN isn't being removed. It's actually being strengthened in the next releases. PHPCS has (since version 2.0) a way to tell PHPCS what the path of a file is when you pass STDIN, which is the method @choma mentioned. The problem being reported in this issue is that the ruleset itself does not use this file path to exclude sniffs from being checked. This is something I have rectified in the 3.0 branch, but not something I can backport to 2.x. So I recommend continuing to use STDIN for checking file contents in editors and plugins as this allows for unsaved content to also be checked. But I do recommend adding the |
@gsherwood I was referring to standard input support for phpcs in Flycheck. I'm sorry, my comment was ambiguous. Anyway, I'm not too happy about the proposed solution. Of all the 80 or so tools that we support in Flycheck phpcs is the only one with this peculiar interface. All others take file names as options. Hence we've no infrastructure in Flycheck to send arbitrary dynamic text over standard input before the actual contents, and I hesitate to add it for a single syntax checker. I'd be awesome if phpcs could also provide a command line option to set the file name. |
I can certainly do that. Was just pointing out that the feature has been available for a couple of years and I'm not planing on removing support for such a feature. Adding to it is certainly something I would do. I'll reopen this as a feature request to pass a filename as an argument, which is only used when checking STDIN. |
That'd really be awesome 😍 Thank you very much! |
…use on the command line (request #934)
This is done now and will be available from 2.6.0. Example usage: |
I'm not sure if this is a duplicate of #873, so sorry if I make noise.
I'm using emacs flycheck plugin to sniff code with Cakephp codesniffer.
The reports with this plugin were different from what I had in the shell. I noted that the plugin uses
<
in the command. Then I checked in the CLI, and using file path like this:is different from using STDIN like this:
As an example take this file:
If use file path, it will report (using
-s
option):If I use STDIN, it will report:
Is it the intended behaviour?
Is there a way to use only Cakephp rules when using STDIN?
My system info:
Thanks in advanced!
The text was updated successfully, but these errors were encountered: