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

Support the WordPress PHPCS ruleset #329

Merged
merged 34 commits into from
Jun 22, 2024
Merged

Support the WordPress PHPCS ruleset #329

merged 34 commits into from
Jun 22, 2024

Conversation

akirk
Copy link
Owner

@akirk akirk commented Jun 18, 2024

This adds support for the WordPress PHPCS ruleset and addresses the 752 reported problems.

This was a lot of work but I hope we can benefit from the rules going forward. Likely it also fixed some insufficient escaping. Hopefully it didn't break too much, I tried to test all UI-related features that I modified.

> @php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 5.6- '--report=source'
..E.E..WWW..E..WWEEEEEWWWE..EE..EEE.EEE.W.EEW.EWE........E..  60 / 136 (44%)
WE.E..E...E.W......W...E.E...EEE...EE.EE.EE..EE...E......... 120 / 136 (88%)
................                                             136 / 136 (100%)



PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
-------------------------------------------------------------------------------------------
    SOURCE                                                                            COUNT
-------------------------------------------------------------------------------------------
[ ] WordPress.Security.ValidatedSanitizedInput.InputNotSanitized                      175
[ ] WordPress.Security.ValidatedSanitizedInput.MissingUnslash                         145
[ ] WordPress.Security.NonceVerification.Recommended                                  105
[ ] WordPress.Security.ValidatedSanitizedInput.InputNotValidated                      69
[ ] WordPress.WP.GlobalVariablesOverride.Prohibited                                   46
[ ] WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode                         33
[ ] WordPress.Security.NonceVerification.Missing                                      30
[ ] WordPress.DB.DirectDatabaseQuery.DirectQuery                                      25
[ ] WordPress.DB.DirectDatabaseQuery.NoCaching                                        23
[ ] Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed                   16
[ ] WordPress.WP.Capabilities.Unknown                                                 13
[ ] Squiz.Operators.IncrementDecrementUsage.Found                                     9
[ ] WordPress.PHP.IniSet.display_errors_Disallowed                                    6
[ ] WordPress.DB.SlowDBQuery.slow_db_query_meta_key                                   5
[ ] Generic.CodeAnalysis.UnusedFunctionParameter.Found                                4
[ ] Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence.MissingParentheses  3
[ ] Squiz.PHP.NonExecutableCode.Unreachable                                           3
[ ] WordPress.DB.SlowDBQuery.slow_db_query_meta_value                                 3
[ ] WordPress.WP.EnqueuedResourceParameters.NotInFooter                               3
[ ] Generic.Strings.UnnecessaryStringConcat.Found                                     2
[ ] Squiz.PHP.CommentedOutCode.Found                                                  2
[ ] Squiz.PHP.DisallowSizeFunctionsInLoops.Found                                      2
[ ] Universal.CodeAnalysis.ConstructorDestructorReturn.ReturnValueFound               2
[x] Universal.ControlStructures.DisallowLonelyIf.Found                                2
[ ] WordPress.PHP.DevelopmentFunctions.error_log_print_r                              2
[ ] WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler                    2
[ ] WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize                       2
[ ] WordPress.WP.AlternativeFunctions.file_system_operations_fclose                   2
[ ] WordPress.WP.AlternativeFunctions.file_system_operations_fwrite                   2
[ ] WordPress.WP.AlternativeFunctions.json_encode_json_encode                         2
[ ] Generic.CodeAnalysis.EmptyStatement.DetectedElse                                  1
[ ] Generic.CodeAnalysis.EmptyStatement.DetectedIf                                    1
[ ] Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed                       1
[ ] Generic.CodeAnalysis.UnconditionalIfStatement.Found                               1
[ ] Universal.Files.SeparateFunctionsFromOO.Mixed                                     1
[ ] WordPress.DB.SlowDBQuery.slow_db_query_tax_query                                  1
[ ] WordPress.PHP.DevelopmentFunctions.error_log_error_log                            1
[ ] WordPress.PHP.DevelopmentFunctions.error_log_var_dump                             1
[ ] WordPress.PHP.DevelopmentFunctions.error_log_var_export                           1
[ ] WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize                         1
[ ] WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec                           1
[ ] WordPress.WP.Capabilities.RoleFound                                               1
[ ] WordPress.WP.CronInterval.CronSchedulesInterval                                   1
[ ] WordPress.WP.DiscouragedFunctions.query_posts_query_posts                         1
-------------------------------------------------------------------------------------------
A TOTAL OF 752 SNIFF VIOLATIONS WERE FOUND IN 44 SOURCES
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SOURCES AUTOMATICALLY (2 VIOLATIONS IN TOTAL)
-------------------------------------------------------------------------------------------

Time: 13.64 secs; Memory: 56MB

@akirk akirk marked this pull request as ready for review June 22, 2024 08:06
@akirk akirk merged commit 2510de7 into main Jun 22, 2024
34 checks passed
@akirk akirk deleted the increase-phpcs-ruleset branch June 22, 2024 08:23
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.

1 participant