Skip to content

Sourcery Code Reviews

Sourcery reviews every pull request or merge request you make. Each time a PR/MR is opened, Sourcery starts a code review and adds a review directly in GitHub or Gitlab.

Our goal is to give you the same type of feedback you would expect from a peer review, but much faster. If you ever find that something is missing from one of our reviews please let us know.

The Pieces of a Sourcery Review

PR Summary

At the top of each PR we add in a summary of the major changes to the code.

PR Summary

You can trigger a re-generation of the PR summary by writing @sourcery-ai summary in the PR body or in a comment on the PR.

Review Guide

The review guide thematically groups together each of the major changes made in the PR and lists which files contribute to those changes.

Review Guide

If applicable, Sourcery will also provide diagrams to help you understand the changes made in the PR.

Diagrams

If there is a GitHub issue linked to the PR, Sourcery will assess whether the PR addresses the issue. Sourcery will also try to find any other issues that are related to the PR and list them.

You can trigger a re-generation of the review guide by writing @sourcery-ai guide in a PR comment.

Overall Review

Each review has a primary review comment where Sourcery gives its overall impression of the changes and gives feedback on higher level issues around the code change.

Overall Review

Individual Review Comments

Sourcery will place comments in line for individual sections of code with feedback that is specific to that code change.

Individual Comments

Improvement Suggestions In certain cases, Sourcery will propose a suggested code change that would address an issue it raises as an individual comment. You can commit these suggestions directly if you are happy with them.

The PR Summary, Review Guide, and Review Comments are all configurable and can be disabled.

You can trigger a new Sourcery review by writing @sourcery-ai review in a PR comment.

How Sourcery Reviews Code

To review code changes Sourcery looks at the diff of the code change and uses a blend of large language model (LLM) analysis and static analysis.

We use a series of AI code reviewers each with different specialities to review the code from a number of different angles. For example, we have a Complexity reviewer that is specifically focused on whether the changes made to the code are being made in the cleanest and simplest way possible or if they are introducing unnecessary complexity to the code.

Some of the current reviewers are:

  • General code quality
  • Security
  • Complexity
  • Documentation
  • Testing
  • Custom review instructions

On top of these reviewers we use our own static analysis engine that uses a rules based system to identify potential code quality issues that need to be flagged and fixed during a PR.

After all of the potential comments on a PR are generated we have a validation process to reduce false positives and unhelpful comments, factors to generate overall reviews and review summaries, and finally present the full review to you.

Interacting with Sourcery

You can reply to any of Sourcery's comments to start a conversation with Sourcery. This can be particularly useful if you are looking for additional information for Sourcery about a comment or would like a proposed fix to an issue Sourcery identified.

On any individual review comment you can add a thumbs up or thumbs down reaction to Sourcery's comment to provide feedback on whether or not the comment was useful and help us improve our comments over time.

Requesting a new review

At any point you can ask Sourcery to review an existing PR if it hasn't previously reviewed it or to re-review a PR it has previously reviewed.

Add a comment on the PR (only in GitHub) saying "@sourcery-ai review" and Sourcery will start the review.

Customising your code reviews

You can configure your code reviews through the Sourcery dashboard. See our section on Configuration for more details on configuring Sourcery's code reviews.

Customisation options include adding custom review instructions, configuring the language, and enabling or disabling sections of the review.

IDE Code Reviews

In addition to reviewing code in GitHub or GitLab, Sourcery can review code in VS Code or in any JetBrains IDEs. See our Getting Started section for more details on setting up IDE reviews.