Skip to content

Conversation

@anomiex
Copy link
Contributor

@anomiex anomiex commented Jan 5, 2023

Changes proposed in this Pull Request:

Following up on #28099, this updates to a newer snapshot of the WordPress-Coding-Standards package to resolve the issues without having to maintain extraneous deps.

Changes to our jetpack-codesniffer package:

  • Drop MediaWiki.Usage.DirUsage, WPCS brings in Modernize.FunctionCalls.Dirname which checks the same and more.
  • Configure WordPress.WP.Capabilities
  • Ignore new Generic.CodeAnalysis.UnusedFunctionParameter, we already use VariableAnalysis.CodeAnalysis.VariableAnalysis that checks more stuff.
  • Ignore new Universal.NamingConventions.NoReservedKeywordParameterNames, not really useful until we can use PHP 8.

New sniffs fixed:

  • Universal.Arrays.DuplicateArrayKey
  • WordPress.WP.AlternativeFunctions.unlink_unlink
  • WordPress.WP.Capabilities.RoleFound
  • WordPress.WP.ClassNameCase.Incorrect

New sniffs ignored:

  • Universal.CodeAnalysis.ConstructorDestructorReturn - 1 false positive
  • WordPress.DB.DirectDatabaseQuery - "db call ok" comment is no longer recognized.
  • WordPress.WP.AlternativeFunctions.file_system_operations_is_writeable -
  • WordPress.WP.AlternativeFunctions.file_system_operations_mkdir -
  • WordPress.WP.AlternativeFunctions.file_system_operations_touch - Matching nearby ignores for fopen etc.
  • WordPress.WP.Capabilities.Unknown - Capabilities from other plugins.
  • Universal.Files.SeparateFunctionsFromOO.Mixed - Too big a refactoring job needed, we'll do this in separate PRs. Left TODO entries.

Also some existing sniffs were renamed:

  • WordPress.PHP.IniSet code display_errors_Blacklisted → display_errors_Disallowed
  • WordPress.WP.AlternativeFunctions codes file_system_read_* → file_system_operations_*
  • Also WordPress.WP.EnqueuedResourceParameters.MissingVersion apparently now reports a more accurate line number.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

pdWQjU-bv-p2

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  • Is CI happy?
  • Do the changes look good?

In packages/autoloader we can just ignore the sniff entirely. None of
the code there runs inside WordPress, so we don't need to use
WordPress's alternative functions.

The same goes for the tests in packages/my-jetpack.

The `Helper_Script_Manager` classes in packages/backup and
packages/transport-helper, on the other hand, can make more consistent
use of WordPress's `WP_Filesystem` class, instead of mixing it with
direct filesystem access.
* Drop MediaWiki.Usage.DirUsage, WPCS brings in
  Modernize.FunctionCalls.Dirname which checks the same and more.
* Configure `WordPress.WP.Capabilities`
* Ignore new Generic.CodeAnalysis.UnusedFunctionParameter, we already
  use VariableAnalysis.CodeAnalysis.VariableAnalysis that checks more
  stuff.
* Ignore new Universal.NamingConventions.NoReservedKeywordParameterNames,
  not really useful until we can use PHP 8.
Fixed:

* Universal.Arrays.DuplicateArrayKey
* WordPress.WP.AlternativeFunctions.unlink_unlink
* WordPress.WP.Capabilities.RoleFound
* WordPress.WP.ClassNameCase.Incorrect

Ignored:

* Universal.CodeAnalysis.ConstructorDestructorReturn - 1 false positive
* WordPress.DB.DirectDatabaseQuery - "db call ok" comment is no longer
  recognized.
* WordPress.WP.AlternativeFunctions.file_system_operations_is_writeable -
* WordPress.WP.AlternativeFunctions.file_system_operations_mkdir -
* WordPress.WP.AlternativeFunctions.file_system_operations_touch -
  Matching nearby ignores for fopen etc.
* WordPress.WP.Capabilities.Unknown - Capabilities from other plugins.

Renamed existing ignores:

* WordPress.PHP.IniSet.display_errors_Disallowed
* WordPress.WP.AlternativeFunctions.file_system_operations_fopen
* WordPress.WP.AlternativeFunctions.file_system_operations_fread
* WordPress.WP.AlternativeFunctions.file_system_operations_fwrite
* WordPress.WP.AlternativeFunctions.file_system_operations_fclose
* WordPress.WP.EnqueuedResourceParameters.MissingVersion
@anomiex anomiex self-assigned this Jan 5, 2023
@anomiex anomiex requested a review from a team as a code owner January 5, 2023 20:37
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2023

Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run bin/jetpack-downloader test jetpack update/wpcs to get started. More details: p9dueE-5Nn-p2

@github-actions github-actions bot added [Package] Autoloader [Package] Codesniffer [Package] Connection [Package] Publicize [Package] Roles [Package] Status [Package] Sync [Package] VideoPress [Package] WAF [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Debug Helper Debug Tools plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Status] Needs Test Review Compatibility [Feature] Contact Form [Feature] Custom Content Types Custom post or content types (usually for testimonials and portfolios) and their settings. [Feature] Custom CSS labels Jan 5, 2023
@github-actions github-actions bot added Pay With Paypal [Feature] Publicize Now Jetpack Social, auto-sharing [Feature] Sharing Post sharing, sharing buttons [Feature] Shortcodes / Embeds [Feature] Sitemaps [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Feature] Theme Tools Unit Tests [Feature] WPCOM API labels Jan 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: February 7, 2023.
  • Scheduled code freeze: January 30, 2023.

Debug Helper plugin:

  • Next scheduled release: February 7, 2023.
  • Scheduled code freeze: January 30, 2023.

Boost plugin:

  • Next scheduled release: February 7, 2023.
  • Scheduled code freeze: January 30, 2023.

Protect plugin:

  • Next scheduled release: February 7, 2023.
  • Scheduled code freeze: January 30, 2023.

@anomiex
Copy link
Contributor Author

anomiex commented Jan 5, 2023

Note, don't actually merge this into #28198. It's just set up that way because that's needed to fix some additional things before this can be merged, and doing it this way lets me see if CI flags anything I missed while dividing up the PRs.

sdixon194
sdixon194 previously approved these changes Jan 9, 2023
@sdixon194 sdixon194 added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jan 9, 2023
Base automatically changed from update/wpcs-pre-phpcbf-3 to trunk January 9, 2023 16:54
@anomiex anomiex merged commit 3104e37 into trunk Jan 9, 2023
@anomiex anomiex deleted the update/wpcs branch January 9, 2023 17:31
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jan 9, 2023
@jeherve jeherve added [Focus] Compatibility Ensuring our products play well with third-parties [Tests] Includes Tests labels Apr 12, 2023
@jeherve jeherve added the [Feature] Pay with PayPal aka Simple Payments label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Contact Form [Feature] Custom Content Types Custom post or content types (usually for testimonials and portfolios) and their settings. [Feature] Custom CSS [Feature] Extra Sidebar Widgets [Feature] Infinite Scroll [Feature] Masterbar WordPress.com Toolbar and Dashboard customizations [Feature] Pay with PayPal aka Simple Payments [Feature] Publicize Now Jetpack Social, auto-sharing [Feature] Sharing Post sharing, sharing buttons [Feature] Shortcodes / Embeds [Feature] Sitemaps [Feature] Subscriptions All subscription-related things such as paid and unpaid, user management, and newsletter settings. [Feature] Theme Tools [Feature] WPCOM API [Focus] Compatibility Ensuring our products play well with third-parties [Package] Autoloader [Package] Backup [Package] Codesniffer [Package] Connection [Package] My Jetpack [Package] Publicize [Package] Roles [Package] Status [Package] Sync [Package] Transport Helper [Package] VideoPress [Package] WAF [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Debug Helper Debug Tools plugin [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Pri] Normal [Status] Needs Test Review [Tests] Includes Tests [Type] Janitorial Unit Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants