[wp-trac] [WordPress Trac] #59161: Composer: update to WordPressCS 3.0.0

WordPress Trac noreply at wordpress.org
Mon Aug 21 15:47:59 UTC 2023


#59161: Composer: update to WordPressCS 3.0.0
------------------------------+-------------------------------
 Reporter:  jrf               |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  6.4
Component:  Build/Test Tools  |     Version:  trunk
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:  coding-standards
------------------------------+-------------------------------
Description changed by jrf:

Old description:

> WordPressCS 3.0.0 has just been released. 🎉
>
> This is an important release which makes significant changes to improve
> the accuracy, performance, stability and maintainability of all sniffs,
> as well as making WordPressCS much better at handling modern PHP.
>
> I'd recommend for WordPress Core to upgrade to using WordPressCS 3.0.0 at
> the earliest convenience to benefit from the latest sniff goodies and to
> prevent new code issues entering the codebase.
>
> I have a patch ready to go for this, which I will pull in a moment.
> The patch consists of a number of commits to make it easier to review the
> changes.
>
> There are likely some changes included which touch Gutenberg files, so a
> check will need to be done to see what needs to be pulled to the
> Gutenberg project.
>
> This patch fixes everything but one issue: violations being flagged
> against the "one object declaration per file" rule.
> As fixing those is more involved, those should be handled separately.
> To that end, I'll be downgrading that error to a warning for the time
> being to allow the build to pass.
>
> The patch also includes a full review of all PHPCS "ignore annotations"
> used in the WP Core codebase and removes a significant number of them.
> Again: there may be some parts of these changes which need to be pulled
> to the Gutenberg repo.
>
> Once the patch has been landed in WP Core, contributors/core committers
> will need to run `composer update --with dependencies` on their local
> machine to pull in the latest versions of the CS dependencies.
> This is also mentioned in the Make post.
>
> Refs:
> * https://github.com/WordPress/WordPress-Coding-
> Standards/releases/tag/3.0.0
> * Make post link
>

> ### Impact
>
> This is the CS status of WP Core `trunk` with the current CS
> dependencies:
>
> {{{
> PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
> -----------------------------------------------------------------------------
>     SOURCE
> COUNT
> -----------------------------------------------------------------------------
> [ ] WordPress.PHP.StrictComparisons.LooseComparison
> 339
> [ ] WordPress.DB.PreparedSQL.InterpolatedNotPrepared
> 145
> [ ] WordPress.DB.PreparedSQL.NotPrepared
> 103
> [ ] WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
> 39
> [ ] WordPress.Files.FileName.InvalidClassFileName                       9
> [x] Generic.Formatting.MultipleStatementAlignment.NotSameWarning        6
> -----------------------------------------------------------------------------
> A TOTAL OF 641 SNIFF VIOLATIONS WERE FOUND IN 6 SOURCES
> -----------------------------------------------------------------------------
> PHPCBF CAN FIX THE 1 MARKED SOURCES AUTOMATICALLY (6 VIOLATIONS IN TOTAL)
> -----------------------------------------------------------------------------
> }}}
>
> This will be the CS status of WP Core on WordPressCS 3.0.0 with the patch
> applied:
>
> {{{
> PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
> -----------------------------------------------------------------------------
>     SOURCE
> COUNT
> -----------------------------------------------------------------------------
> [x] Universal.Operators.StrictComparisons.LooseEqual
> 233
> [ ] WordPress.DB.PreparedSQL.InterpolatedNotPrepared
> 145
> [x] Universal.Operators.StrictComparisons.LooseNotEqual
> 106
> [ ] WordPress.DB.PreparedSQL.NotPrepared
> 103
> [ ] WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
> 39
> [ ] Generic.Files.OneObjectStructurePerFile.MultipleFound
> 29
> [ ] WordPress.Files.FileName.InvalidClassFileName                       9
> -----------------------------------------------------------------------------
> A TOTAL OF 664 SNIFF VIOLATIONS WERE FOUND IN 7 SOURCES
> -----------------------------------------------------------------------------
> PHPCBF CAN FIX THE 2 MARKED SOURCES AUTOMATICALLY (339 VIOLATIONS IN
> TOTAL)
> -----------------------------------------------------------------------------
> }}}

New description:

 WordPressCS 3.0.0 has just been released. 🎉

 This is an important release which makes significant changes to improve
 the accuracy, performance, stability and maintainability of all sniffs, as
 well as making WordPressCS much better at handling modern PHP.

 I'd recommend for WordPress Core to upgrade to using WordPressCS 3.0.0 at
 the earliest convenience to benefit from the latest sniff goodies and to
 prevent new code issues entering the codebase.

 I have a patch ready to go for this, which I will pull in a moment.
 The patch consists of a number of commits to make it easier to review the
 changes.

 There are likely some changes included which touch Gutenberg files, so a
 check will need to be done to see what needs to be pulled to the Gutenberg
 project.

 This patch fixes everything but one issue: violations being flagged
 against the "one object declaration per file" rule.
 As fixing those is more involved, those should be handled separately.
 To that end, I'll be downgrading that error to a warning for the time
 being to allow the build to pass.

 The patch also includes a full review of all PHPCS "ignore annotations"
 used in the WP Core codebase and removes a significant number of them.
 Again: there may be some parts of these changes which need to be pulled to
 the Gutenberg repo.

 Once the patch has been landed in WP Core, contributors/core committers
 will need to run `composer update --with dependencies` on their local
 machine to pull in the latest versions of the CS dependencies.
 This is also mentioned in the Make post.

 Refs:
 * https://github.com/WordPress/WordPress-Coding-
 Standards/releases/tag/3.0.0
 * https://make.wordpress.org/core/2023/08/21/wordpresscs-3-0-0-is-now-
 available/


 ### Impact

 This is the CS status of WP Core `trunk` with the current CS dependencies:

 {{{
 PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
 -----------------------------------------------------------------------------
     SOURCE
 COUNT
 -----------------------------------------------------------------------------
 [ ] WordPress.PHP.StrictComparisons.LooseComparison
 339
 [ ] WordPress.DB.PreparedSQL.InterpolatedNotPrepared
 145
 [ ] WordPress.DB.PreparedSQL.NotPrepared
 103
 [ ] WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase  39
 [ ] WordPress.Files.FileName.InvalidClassFileName                       9
 [x] Generic.Formatting.MultipleStatementAlignment.NotSameWarning        6
 -----------------------------------------------------------------------------
 A TOTAL OF 641 SNIFF VIOLATIONS WERE FOUND IN 6 SOURCES
 -----------------------------------------------------------------------------
 PHPCBF CAN FIX THE 1 MARKED SOURCES AUTOMATICALLY (6 VIOLATIONS IN TOTAL)
 -----------------------------------------------------------------------------
 }}}

 This will be the CS status of WP Core on WordPressCS 3.0.0 with the patch
 applied:

 {{{
 PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
 -----------------------------------------------------------------------------
     SOURCE
 COUNT
 -----------------------------------------------------------------------------
 [x] Universal.Operators.StrictComparisons.LooseEqual
 233
 [ ] WordPress.DB.PreparedSQL.InterpolatedNotPrepared
 145
 [x] Universal.Operators.StrictComparisons.LooseNotEqual
 106
 [ ] WordPress.DB.PreparedSQL.NotPrepared
 103
 [ ] WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase  39
 [ ] Generic.Files.OneObjectStructurePerFile.MultipleFound               29
 [ ] WordPress.Files.FileName.InvalidClassFileName                       9
 -----------------------------------------------------------------------------
 A TOTAL OF 664 SNIFF VIOLATIONS WERE FOUND IN 7 SOURCES
 -----------------------------------------------------------------------------
 PHPCBF CAN FIX THE 2 MARKED SOURCES AUTOMATICALLY (339 VIOLATIONS IN
 TOTAL)
 -----------------------------------------------------------------------------
 }}}

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59161#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list