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

PHPCS fixes for 1.9.1-dev #486

Merged
merged 60 commits into from
Oct 16, 2018
Merged

Conversation

paulschreiber
Copy link
Contributor

No description provided.

@paulschreiber
Copy link
Contributor Author

Two lines generate escaping warnings:

  • class-wpcom-liveblog-lazyloader.php:142
  • class-wpcom-liveblog-amp-template.php:97

Please inspect them and choose an appropriate escaping function, or add a phpcs:ignore comment.

phpcs.xml Outdated
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be named .phpcs.xml.dist or phpcs.xml.dist.

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 based this on the work done at https://github.com/Automattic/amp-wp/ cc @westonruter

Copy link
Contributor

Choose a reason for hiding this comment

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

@westonruter should know better :-)

I've created ampproject/amp-wp#1324 for them to update it at AMP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed with 5767fb0.

phpcs.xml Outdated
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Liveblog">
Copy link
Contributor

Choose a reason for hiding this comment

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

Name should be "Custom ruleset for Liveblog". It's a ruleset, not a standard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also copied from amp-wp.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is just about being accurate and educating developers.

For your reference (since I see you on many different repos doing PRs improving PHPCS setups like this - and thank you for that!), here's my plugin boilerplate .phpcs.xml.dist file, which applies many good practices.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed with 14a4a9e.

phpcs.xml Outdated
<ruleset name="WordPress Coding Standards for Liveblog">

<rule ref="WordPress-VIP" />
<rule ref="WordPress-Extra" />
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be no spaces before closing />. This is XML, not XHTML.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also copied from amp-wp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed with 0ca4449.

phpcs.xml Outdated
<rule ref="WordPress-VIP" />
<rule ref="WordPress-Extra" />

<arg value="s"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Include the progress (p), colors, extensions, basepath and parallel args - this plugin is PHP 5.6 and above, so PHPCS 3.x will be installed (3.3.1 currently).

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 was previously told not to use --colors:
WordPress/gutenberg#1685 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

extensions is already present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you want for basepath and parallel? @westonruter any thoughts here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed based on your boilerplate. 15df6b2.

Copy link
Contributor

Choose a reason for hiding this comment

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

basepath="." is enough to remove everything before the current directory.
parallel="8" is a good default, though I put it to 50 on my plugins - I've not yet encountered a drawback, though that doesn't mean there isn't one.

phpcs.xml.dist Outdated
@@ -1,8 +1,9 @@
<?xml version="1.0"?>
<ruleset name="Custom ruleset for Liveblog">

<rule ref="WordPress-VIP"/>
<rule ref="WordPress-Core"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to include WordPress-Core if including WordPress-Extra, as Extra already includes Core.

@@ -1625,11 +1630,11 @@ private static function status_header_with_message( $status, $message ) {

$status = absint( $status );
$official_message = isset( $wp_header_to_desc[ $status ] ) ? $wp_header_to_desc[ $status ] : '';
$wp_header_to_desc[ $status ] = self::sanitize_http_header( $message );
$wp_header_to_desc[ $status ] = self::sanitize_http_header( $message ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited

This comment was marked as resolved.

<?xml version="1.0"?>
<ruleset name="Custom ruleset for Liveblog">

<rule ref="WordPress-Extra"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Also add WordPress-Docs? It's not fully complete, but it's a good start for what it does cover. Could leave for a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, let's do a separate issue outside of this PR 👍

<arg name="parallel" value="50"/>
<arg name="extensions" value="php"/>
<file>.</file>

Copy link
Contributor

Choose a reason for hiding this comment

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

Would like to see text domain checks enabled, and prefixes, and some link references.

See https://github.com/GaryJones/plugin-boilerplate/blob/master/.phpcs.xml.dist, and consider copying this, and amending it with the liveblog bits (no need to include Neutron).

PHPCompatibilityWP standard would also then need to be added to composer.json and Travis config.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave this for a separate change

Copy link
Contributor

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

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

A few small bits to address, then I think this would be good to get merged, re-adjust the phpcs.xml.dist as necessary, and then re-scan and re-fix.

Great job @paulschreiber!

@GaryJones GaryJones changed the title PHPCS fixes for 1.9 PHPCS fixes for 2.0-dev Oct 13, 2018
@GaryJones GaryJones changed the title PHPCS fixes for 2.0-dev PHPCS fixes for 1.9.1-dev Oct 13, 2018
@paulschreiber
Copy link
Contributor Author

@philipjohn I've addressed the issues @GaryJones flagged.

@philipjohn philipjohn dismissed GaryJones’s stale review October 16, 2018 16:38

Addressed in recent commits.

Copy link
Contributor

@philipjohn philipjohn left a comment

Choose a reason for hiding this comment

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

Thanks @paulschreiber !

@philipjohn philipjohn changed the base branch from master to release/1.9.1 October 16, 2018 16:39
@philipjohn philipjohn merged commit f2a965a into Automattic:release/1.9.1 Oct 16, 2018
@paulschreiber paulschreiber deleted the fix/phpcs branch October 16, 2018 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants