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.

You can also trigger a code review on a git branch, uncommitted changes, or current file from your IDE. IDE reviews contain the same content as the Sourcery reviews 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.

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.

Triggering a Code Review

In GitHub or GitLab you can trigger a Sourcery code review by commenting @sourcery-ai review on any pull request. By default Sourcery will automatically review the pull request when it is marked ready for review.

In IDE you can start a Sourcery review by opening the Sourcery sidebar, going to the Review tab, choosing the review context (current file or branch), and clicking "Review My Code".