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
Add placeholder support to code analyzer scan #37608
base: trunk
Are you sure you want to change the base?
Conversation
Hi @psealock, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
1 similar comment
Hi @psealock, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: 1294de6
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into the error on step 22, so haven't proceeded. This is looking great so far.
One question I have when x.x.x
is used.
You shouldn't see the hook with @SInCE x.x.x because the --allowPlaceholder flag was not included.
Should it error out when --allowPlaceholder
isn't used? I'm not sure the answer because I suppose it depends how the tool is supposed to be used. Is there a time when we want to ignore an introduced x.x.x
? Maybe we should not have the flag at all and surface the change regardless?
filePath, | ||
name, | ||
hookType, | ||
description, | ||
changeType, | ||
version, | ||
ghLink, | ||
isPlaceholder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Step 22 I get an error here when running pnpm run analyzer scan hooks "test/hook-version" "trunk" --since "8.0.0"
.
ReferenceError: isPlaceholder is not defined
at scanForHookChanges (/Users/paulsealock/Workspace/psealock-woocommerce/tools/code-analyzer/src/lib/hook-changes.ts:115:7)
at async scanChangesForHooks (/Users/paulsealock/Workspace/psealock-woocommerce/tools/code-analyzer/src/lib/scan-changes.ts:87:22)
at async Command.<anonymous> (/Users/paulsealock/Workspace/psealock-woocommerce/tools/code-analyzer/src/commands/analyzer/analyzer-scan.ts:83:26)
Submission Review Guidelines:
Changes proposed in this Pull Request:
This PR updates the code analyzer scan command to also support placeholders. In addition, this PR fixes an issue I discovered while writing the testing instructions for this PR. Prior to this change, only the first
do_action
orapply_filter
changed in a file would be detected. If there were multiple actions or filters added to a single file, the subsequent ones would be ignored.Partially addresses #35754
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
pnpm i
.trunk
.test/template-version
) in your fork.plugins/woocommerce/templates
, but do not update the@version
tag in the file that you change.tools/code-analyzer
directory.pnpm run analyzer scan templates "YOURBRANCH" "trunk" --since "8.0.0"
.@version
tag to8.0.0
. Commit and push changes.pnpm run analyzer scan templates "YOURBRANCH" "trunk" --since "8.0.0"
.@version
tag tox.x.x
. Commit and push changes.pnpm run analyzer scan templates "YOURBRANCH" "trunk" --since "8.0.0"
.pnpm run analyzer scan templates "YOURBRANCH" "trunk" --allowPlaceholder --since "8.0.0"
woocommerce/woocommerce
) using your test branch. Verify that thepr-highlight-changes.yml
workflow runs, and passes, and that there's a notice about a version bump placeholder being found.test/hook-version
) in your fork.do_action
orapply_filter
call to a php file in thewoocommerce
plugin. Include the docblock and@since 8.0.0
. For example:pnpm run analyzer scan hooks "YOURBRANCH" "trunk" --since "8.0.0"
.do_action
orapply_filter
call to a php file in thewoocommerce
plugin. Include the docblock and@since x.x.x
. You may want to use the same file you used in the previous step to verify that this PR also addresses the issue where previously only a single hook was detected in each file. For example:pnpm run analyzer scan hooks "YOURBRANCH" "trunk" --since "8.0.0"
.@since x.x.x
because the--allowPlaceholder
flag was not included.--allowPlaceholder
. You should see the placeholder hook.