When code review is enabled, P42 analyzes and verifies code changes in the repository whenever:
- Pull requests are opened, or
- Commits are made to the default branch of the GitHub repository.
The P42 code review suggests opportunities to apply the enabled P42 code actions. Code reviews are represented as GitHub checks.
Code Review Status
The final result of a code review (success, neutral, or failure) depends on the found suggestions and the code review setting of the code actions (hint vs. blocker):
- Success: P42 has no suggestions.
- Neutral: P42 has suggestions in hint code actions. P42 has no suggestions in blocker code actions. Neutral results do not fail the overarching GitHub check.
- Failure: P42 has suggestions in blocker code actions. P42 might also have suggestions in hint code actions.
📝 You need to set code actions to blockers in the code review setting to make P42 mark your pull requests as failures.
While a code review is running, the check is shown as pending or in progress.
Pull Request Reviews
When code review is enabled for a repository, P42 performs code analysis for enabled code actions whenever pull requests are created or updated.
📝 P42 code reviews for pull requests are limited to the files that have been added or changed in the pull request.
To see the status for pull request code review:
- Navigate to the pull request page for your GitHub repository. For example, go
- Click on the check status indicator next to your pull request title (green check mark or red cross).
- In the checks summary popup, click on Details to view the code review report.
Default Branch Code Review
When code review is enabled for a repository, P42 performs code analysis for enabled code actions whenever commits are made to the repository's default branch.
📝 The check status for default branch commits represents all suggestions for the default branch. The details and annotations sections of the check result are limited to suggestions for files that have been added or changed since the last scan.
To see the status for commit code reviews:
- Navigate to your GitHub repository. For example, go to
Click on the check status indicator (green check mark or red cross) next to your commit hash. You should see a
P42entry in the popup.
In the checks summary popup, click on Details in the P42 entry to view the code review report.
Code Review Report
You can find the following information in the GitHub checks page for your repository:
Suggestion Count Count of how many suggestions have been found. For default branch checks, the number of 'new' suggestions that have been found since the last analysis is also shown.
Code Action Overview A list of P42 code actions that produced suggestions. For each code action, an information/fail indicator, the name with a link to documentation, and the number of suggestions are shown. Additional information on the check run is shown below the list.
Details The details section contains all suggestions (for pull requests) or all new suggestions (for default branch checks). It is sorted by code action and filename. A message, an optional safety message, and a diff of the suggested change are provided for each suggestion.
Annotations The annotations section contains code annotations for all suggestions (for pull requests) or all new suggestions (for default branch checks). For each suggestion, the annotation includes the filename, the code action, the message, an optional safety message, and a partial diff of the suggested change (under "raw output").
View more details A link to the scanned repository on P42.
Re-run Action Only available when there have been blocking suggestions. Triggers a re-run of the analysis, which can lead to different results, e.g., when code action gets disabled or changed to hint/blocker.
P42 shows inline annotations in the changed files on your commit or pull request diffs ("Files changed" tab):
For each code action suggestion, P42 creates an annotation. The annotation contains:
- The filename.
- The code action.
- The message.
- An optional safety message.
- A partial diff of the suggested change (under "raw output").
📝 You can use the P42 JS Assistant for VS Code to comfortably update your code with the same code actions that P42 uses.