Code Review

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:

  1. Navigate to the pull request page for your GitHub repository. For example, go to https://github.com/UserA/sample-repository-1/pulls.
  2. Click on the check status indicator next to your pull request title (green checkmark or red cross). GitHub pull request code review status indicator
  3. In the checks summary popup, click on Details to view the code review report. GitHub pull request code review popup

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:

  1. Navigate to your GitHub repository. For example, go to https://github.com/UserA/sample-repository-1.
  2. Click on the check status indicator (green checkmark or red cross) next to your commit hash. You should see a P42+ entry in the popup.

    GitHub check status indicator

  3. In the checks summary popup, click on Details in the P42+ entry to view the code review report.

    GitHub commit code review popup

Code Review Report

You can find the following information in the GitHub checks page for your repository:

GitHub Code Review Report

  1. 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.

  2. 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.

  3. 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.

  4. 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").

  5. View more details A link to the scanned repository on P42+.

  6. 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.

Inline Comments

P42+ shows inline annotations in the changed files on your commit or pull request diffs ("Files changed" tab):

P42+ Inline Comments}

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 JavaScript Assistant for VS Code to comfortably update your code with the same code actions that P42+ uses.

Quick Navigation