...

/

AI‑Assisted Code Review

AI‑Assisted Code Review

Explore AI-assisted code reviews with Copilot to catch bugs, improve code quality, and provide thoughtful, constructive feedback.

Why code review and Copilot?

Code reviews are important for catching bugs, improving code quality, and helping junior developers grow. They create space for learning and ensure that the whole team benefits from better coding practices.

But manual code reviews can be time-consuming, especially when they focus on minor style issues. That’s where GitHub Copilot becomes a powerful tool. Copilot can quickly draft review comments, allowing senior developers to shift their attention to more meaningful feedback, like improving design, fixing logic, and mentoring junior teammates.

Let’s see this in action with a real-world example.

Requesting a Copilot review

Imagine you’re a senior developer reviewing a pull request (PR) submitted by a junior teammate. The file is small, but you can provide thoughtful, helpful feedback.

Here’s the file they’ve submitted:

# email_utils.py
import re
# NOTE: chose a shorter regex but lost some precision
_RE = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
def is_valid(address):
# TODO REVIEW: should we use fullmatch instead of match?
return bool(_RE.match(address))
def get_domain(addr):
# returns everything after the last "@"
return addr[addr.rfind("@") + 1:] # BUG: returns whole string if "@" missing
def local_part(addr):
return addr.split("@")[0] # lacks error handling for malformed addr
def masked_email(e, show=2):
"""
Mask an email so only *show* chars of the local part remain visible,
e.g. jo******@example.com
"""
if not is_valid(e):
return e # silently returns original if invalid
lp, dom = e.split("@")
masked = lp[:show] + "*" * (len(lp) - show)
return masked + "@" + dom
Email utilities module

As you review, Copilot can help you spot key issues quickly. In this file, Copilot should detect the following:

  • Logic bug in get_domain when "@" is missing.

  • Validation flaw: Using .match instead of .fullmatch.

  • Vague variable names: _RE, e, addr.

  • Missing error handling in local_part and masked_email. ...