-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Please consider if isset
as reliable usage of an input var
#849
Comments
Let me add this to the puzzle:
|
OK, you're using the Also, <?php
$type = null;
if ( isset( $_GET['type'] ) ) { // WPCS: input var ok; CSRF ok.
$type = sanitize_key( wp_unslash( $_GET['type'] ) ); // WPCS: input var ok; CSRF ok.
} You can avoid the whitelisting comments if you use a less-strict standard like |
Thanks @westonruter .
The first and last comment still nags me because it is an Please consider |
if isset
as reliable usage of an input var
The sniff that you are referring to is intended mainly as a helper to code reviewers for the VIP platform. I think that it probably needs to remain as it is, but I always disable it in my PHPCS ruleset file: <rule ref="WordPress-VIP">
<exclude name="WordPress.VIP.SuperGlobalInputUsage" />
</rule> |
So I, as a developer, shouldn't be aware of this sniff. Is that correct? If that is correct, then I would change the topic one more time to: "Please create rulesets for developers". |
Well there is WordPress-Theme sniff, but it's still in the works. I personally use modified |
It depends on what your goal of using WPCS is. You can see the available rulesets and what they are meant to check. https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#rulesets |
Yes, that's about right. If you are a developer performing a review of your code or running WPCS over it for the first time, you might want to use that sniff. For regular use of WPCS I just turn it off. There has been some discussion, and maybe a ticket, to remove the whole VIP standard to be separate from WPCS, because it is aimed specifically at code being developed/reviewed for the VIP platform. However, that hasn't happened yet. Basically though, when you run the |
Thanks for the reply. Please read this carefully as it sums up my last request: Bring up another ruleset a bit weaker than WordPress-VIP. This solves what you just said @JDGrimes . I know about the other rulesets. Maybe there could be a new ruleset a bit weaker than VIP but stronger than the "WordPress" rulset. I like to suggest a ruleset based on WordPress-VIP without:
I like that the VIP standards are endosed in this repo. And another one for "WordPress-VIP-dev" would be great if loose enough for developers. Anyway it would be great to have it as most developers need to do it on their own every time. So: If you like, then I put up a merge request to bring in some more details about what I mean. |
I think the ruleset that you are looking for is
Now it is not to say the |
I'm going to close this, as the original issue has been dealt with, and the remaining request is basically covered by #240. |
Edit:
See comment #849 (comment)
about the common if and isset.
Original issue:
See this:
Now it nags for
So I comment with
Then it nags with
Help! What is it that you want from me?
The text was updated successfully, but these errors were encountered: