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

Code Quality: Update codes to pass php lint #201

Merged
merged 3 commits into from
Mar 30, 2022
Merged

Conversation

t-hamano
Copy link
Contributor

I have noticed many errors in the php lint.
This PR updates codes to pass correctly based on what phpcs pointed out.

Mainly, I have addressed the following:

  • Remove unnecessary spaces and line breaks
  • Move add_action to after function to eliminate missing doc error.
  • Space indent to tab indent
  • Add missing @package tag
  • Explicitly specify the fifth argument( $in_footer ) of wp_register_script
  • Explicitly specify the 4th argument( $ver ) of wp_register_style
  • add exclude pattern to phpcs.xml ( node_modules, block.asset.php )
  • Use require_once instead of include

As this is my first PR, please do not hesitate to point out any problems.

composer.json Outdated
"squizlabs/php_codesniffer": "^3.6",
"wp-coding-standards/wpcs": "^2.3"
},
"scripts": {
"lint": "./vendor/bin/phpcs --standard=phpcs.xml"
"lint": "phpcs --standard=phpcs.xml"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably a Windows-specific problem, the following error occurred:

'.' is not recognized as an internal or external command,
operable program or batch file.
Script ./vendor/bin/phpcs --standard=phpcs.xml handling the lint event returned with error code 1

I changed the way to specify the path according to gutenberg repository.

Copy link
Contributor

Choose a reason for hiding this comment

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

This command doesn't work for me anymore:

[InvalidArgumentException]                     
Script "phpcs" is not defined in this package

Let's revert this for now and come back to it in a secondary PR where we can come up with a good cross-platform approach.

Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to put this together!
Just a couple of notes/comments but overall looks great :)

plugins_url( 'style.css', __FILE__ )
plugins_url( 'style.css', __FILE__ ),
null,
get_bloginfo( 'version' ),
Copy link
Contributor

@ryanwelcher ryanwelcher Mar 24, 2022

Choose a reason for hiding this comment

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

Can we reuse the $asset_file['version'] here? My concern is that this will be cached until the version of WP changes.

composer.json Outdated
"squizlabs/php_codesniffer": "^3.6",
"wp-coding-standards/wpcs": "^2.3"
},
"scripts": {
"lint": "./vendor/bin/phpcs --standard=phpcs.xml"
"lint": "phpcs --standard=phpcs.xml"
Copy link
Contributor

Choose a reason for hiding this comment

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

This command doesn't work for me anymore:

[InvalidArgumentException]                     
Script "phpcs" is not defined in this package

Let's revert this for now and come back to it in a secondary PR where we can come up with a good cross-platform approach.

plugins_url( 'plugin-sidebar.css', __FILE__ )
plugins_url( 'plugin-sidebar.css', __FILE__ ),
null,
get_bloginfo( 'version' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Same concern about the asset version being tied to the WP version.

@t-hamano
Copy link
Contributor Author

Thank you for reviewing the code !
I have pushed the update.

Copy link
Contributor

@ryanwelcher ryanwelcher left a comment

Choose a reason for hiding this comment

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

LGTM 👍 - thanks again for putting this together!

@ryanwelcher ryanwelcher merged commit c85950e into trunk Mar 30, 2022
@ryanwelcher ryanwelcher deleted the quality/pass-php-lint branch March 30, 2022 17:35
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.

2 participants