Enforce exact scope indentation in PHPCS#13140
Open
faisalahammad wants to merge 2 commits into
Open
Conversation
…ication The component is shown for any initial setup error, not only Analytics activation, so the new name describes its purpose better. - Rename component and stories file. - Update import, component name, constant, notification ID, and CSS class in SetupUsingProxyWithSignIn/index.js. - Update story usage and test descriptions. - Rename 6 Backstop reference PNGs (pixels unchanged).
Set Generic.WhiteSpace.ScopeIndent to exact=true in phpcs.xml so the sniff flags lines indented deeper than the expected scope, not just lines indented less. The default exact=false inherits from WordPress-Core and only checks the lower bound, which lets over-indented code slip through CI. Auto-fixed 189 pre-existing over-indent violations across 52 PHP files using phpcbf. All changes are whitespace-only except one real over-indent bug in tests/phpunit/integration/Core/Tags/Guards/Tag_Environment_Type_GuardTest.php where two use statements were indented at file scope. Fixes google#12934.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses issue:
Relevant technical choices
Set
Generic.WhiteSpace.ScopeIndenttoexact=trueinphpcs.xml. The defaultexact=false(inherited fromWordPress-Core) only checks the lower bound of indentation, so lines indented deeper than the expected scope slip through CI. Flipping toexact=truemakes the sniff enforce the full range: under- and over-indented lines both fail.This also turned up 189 pre-existing over-indent violations across 52 PHP files, all auto-fixed by
phpcbf. One real bug was uncovered:tests/phpunit/integration/Core/Tags/Guards/Tag_Environment_Type_GuardTest.phphad twousestatements indented at file scope.Repro to confirm the rule works:
Running
composer run lint -- /tmp/test_indent.phpnow reportsGeneric.WhiteSpace.ScopeIndent.IncorrectExact. Clean code keeps passing.PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist