-
Notifications
You must be signed in to change notification settings - Fork 11
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
Improve Wpcs #20
Improve Wpcs #20
Conversation
Strictly comparison Extra unneded new line separators on statements/loops closing Group assignments for readability
Try to get the option only if the $option_prefix has a valid value.
Thanks for pointing out the comparisons. I'll fix those and look at the $option_prefix. I'm not so sure about removing lines though. Are you checking against an additional standard? I'm using the WordPress standard which includes core, VIP, etc. It doesn't warn me about removing lines like in your PR and I don't see it in the standards on make.wordpress.org. I find this to be a lot more readable: function wie_security_notices() {
$notices = array();
// Outdated PHP notice.
$notices[] = 'wie_php_notice';
// HTTP notice.
$notices[] = 'wie_http_notice';
// Filter notices.
$notices = apply_filters( 'wie_security_notices', $notices );
// Loop notices to activate.
foreach ( $notices as $notice ) {
add_action( 'admin_notices', $notice );
}
} ...than this: function wie_security_notices() {
$notices = array();
// Outdated PHP notice.
$notices[] = 'wie_php_notice';
// HTTP notice.
$notices[] = 'wie_http_notice';
// Filter notices.
$notices = apply_filters( 'wie_security_notices', $notices );
// Loop notices to activate.
foreach ( $notices as $notice ) {
add_action( 'admin_notices', $notice );
}
} I do see the standard for new lines on Other than that, there are warnings about $_GET, $_POST, etc. There must be some better way to deal with handling that data. Maybe in the next release. Any ideas? |
Hi, Thank you for your response.
Any additional standard. Generally multiple assignments are grouped but in this case the additional comment per assigment may decrease readability as you pointed out. I think, depending on dev habit. Anyway nothing to strictly related to Wpcs.
I don't think using
I think it's more readable than
Depending on what is the use of the data we can ignore the warning or filtering/validate the data. For example, checking for the existence of a data like using There are other at-comments. More info: Other cases can be covered by using For example:
I use Then we can use any other function like: esc_url, esc_url_raw, sanitize_text_field, kses_post etc... depending on the context. What are your thoughts about that? |
Thanks for the thoughts. I'll make I opened an issue so $_POST, $_GET, etc. can be better handled in next release per your advice. #21 |
Strictly comparisons
Remove extra unneeded new line separators for readability
Grouped assignments for readability