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

WordPress VIP coding standards compliance #1111

Merged
merged 3 commits into from
Jul 7, 2020

Conversation

kidunot89
Copy link
Contributor

Summary

Adds the VIP coding standards and clears up all the warnings from the PHPCS test.

Copy link
Contributor

@kasparsd kasparsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @kidunot89!

Having reviewed the live-updates feature and the way it uses request variables I'm thinking if we should pull the feature from the current release or somehow reduce the amount of request variables we're passing to the JS side via JSON in DOM.

.vscode/settings.json Outdated Show resolved Hide resolved
// input var okay, CSRF okay
'current_query_count' => count( $_GET ), // WPCS: CSRF ok.
// input var okay, CSRF okay
'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be sanitized to an integer value?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

absint( wp_unslash( $_GET['paged] ) ) would probably be my preference here, but there are many ways to sanitize/escape this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gotcha, I wasn't worried about the code and was just trying to silence the PHPCS warning.

'current_query_count' => count( $_GET ), // WPCS: CSRF ok.
// input var okay, CSRF okay
'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
'current_order' => isset( $_GET['order'] ) ? esc_js( $_GET['order'] ) : 'desc', // phpcs:ignore WordPress.Security.NonceVerification.Recommended
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we check that it's one of the allowed values of order before setting it? Do we support anything apart from desc and asc?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, if there are only asc and desc we can do a check for one and manually set this instead of excepting any value.

classes/class-admin.php Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@kidunot89 kidunot89 force-pushed the devops/vip-compliance branch from 39d8bcb to ee379e1 Compare June 23, 2020 21:07
@kidunot89 kidunot89 self-assigned this Jun 25, 2020
@kidunot89 kidunot89 changed the title VIP compliance WordPress VIP compliance Jun 26, 2020
@kidunot89 kidunot89 changed the title WordPress VIP compliance WordPress VIP coding standards compliance Jun 26, 2020
@kasparsd kasparsd added this to the Version 3.5.0 milestone Jul 1, 2020
@@ -154,7 +154,7 @@ function ( $var ) {
$result = $this->plugin->db->insert( $recordarr );

// This is helpful in development environments:
// error_log( $this->debug_backtrace( $recordarr ) );
// error_log( $this->debug_backtrace( $recordarr ) );.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove this completely?

Copy link
Contributor

@kasparsd kasparsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@kasparsd
Copy link
Contributor

kasparsd commented Jul 6, 2020

Looks like need to resolve the merge conflict. @kidunot89 could you do that, please?

@kidunot89 kidunot89 force-pushed the devops/vip-compliance branch from 96dbebb to 6458a3b Compare July 6, 2020 15:00
@@ -23,6 +23,6 @@
<exclude-pattern>*/ui/lib/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/build/*</exclude-pattern>
<exclude-pattern>*/local/public/*</exclude-pattern>
<exclude-pattern>*/local/*</exclude-pattern>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it only used is in development, I've added the whole local directory to be ignored by PHPCS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have all PHP files with consistent formatting even if they're used for development purposes.

@kidunot89 kidunot89 requested a review from kasparsd July 6, 2020 15:10
Copy link
Contributor

@kasparsd kasparsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @kidunot89!

Could we please create issues for all instances of phpcs:ignore to add the nonce checks?

@kasparsd kasparsd merged commit d465e35 into xwp:develop Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants