Home Articles

PR Review Using CodeRabbit: Your AI-Powered Code Review Buddy

Introduction

AI-Powered Code Review Buddy

AI-Powered Code Review Buddy

Installation

You can install CodeRabbit extension directly in Cursor IDE or VS Code directly. This will help us in reviewing the code changes (both uncommitted and committed).

CodeRabbit Extension

CodeRabbit Extension

Authorization

This is how the coderabbitai authorizes the GitHub repository.

coderabbitai Authorization

coderabbitai Authorization

You will have two different options to authorize the GitHub Repositories.

  • All repositories

  • Only select repositories

There are some permission levels

  • Read access to actions, discussions and so on

  • Read and write access to code, commit, issues and PRs since it provides you the line by line review comments and also suggestions.

Authorize specific repositories Confirmation screen

Authorize specific repositories Confirmation screen

Code Review Flow

Review Flow

Review Flow

Code Review in Cursor IDE

CodeRabbit code review in Cursor/VS Code IDE

CodeRabbit code review in Cursor/VS Code IDE

Please find the animated Version below:

Animated version to review changes

Animated version to review changes

Suggest Code Review Comments in Cursor IDE

Improper Error Handling - Remove Force Unwrapping

Code Review and suggestions

Code Review and suggestions

Refractor Suggestion

Refractor Suggestion

Refractor Suggestion

GitHub Pull Request

Let’s talk about something that happens after Pull Request.

PR Summary

Writing a meaningful Pull Request is still a challenge for many developers. Pull Request is a crucial skill for collaborative coding among the team. This will really help the developers to understand based on the code changes.

PR Summary generated by CodeRabbit

PR Summary generated by CodeRabbit

PR - Code Walkthrough

Code Walkthrough helps the Junior developers to know the changes during their KT session. Also, this will help the developer to check their knowledge on those changes.

PR - Code Walkthrough generated by CodeRabbit

PR - Code Walkthrough generated by CodeRabbit

PR - Sequence Diagram

Sequence Diagram does help to understand the project flow and thus helps the junior developers to learn as quickly as possible.

 PR - Sequence Diagrams generated by CodeRabbit

PR - Sequence Diagrams generated by CodeRabbit

Configuration File .coderabbit.yaml

Before getting detailed review comments, we should know something about the CodeRabbit Configuration file .coderabbit.yaml file.

YAML is a human-readable data serialization language that is often used for writing configuration files. YAML is also a superset of JSON, so JSON files are valid in YAML.

language: en

# Review configuration
reviews:
  # Enable detailed reviews with context
  profile: "chill" # Options: "chill", "assertive"

  # Request changes workflow
  request_changes_workflow: true

  # Auto-reviews for pull requests
  auto_review:
    enabled: true
    drafts: false

# Path-based review settings
path_instructions:
  # SwiftUI Views - Focus on performance and accessibility
  - path: "**/*View.swift"
    instructions: |
      When reviewing SwiftUI views, pay special attention to:
      - View composition and hierarchy optimization
      - Proper use of @State, @Binding, @ObservedObject, @StateObject, @Environment
      - Accessibility modifiers and labels (.accessibilityLabel, .accessibilityHint)
      - Performance implications of complex view hierarchies
      - Proper use of LazyVStack/LazyHStack for large lists
      - Memory management and retain cycles in closures
      - Dark mode and dynamic type support
      - Internationalization and localization
      - Main thread UI updates enforcement
      - SwiftUI view body complexity (should not exceed 10-15 lines)

.coderabbit.yaml


Review Settings

reviews:
  auto_review: true
  request_changes_workflow: true
  draft_reviews: false

Review Settings


Path Filters (File Inclusion/Exclusion)

This section includes swift files and excludes dependencies, build folders and so on.

path_filters:
  - "**/*.swift"
  - "**/*.h"
  - "**/*.m"
  ...
  - "!**/Pods/**"

Path Filters

iOS/Swift Review Rules

rules:
  swift:
    naming_conventions: true
    camel_case_enforcement: true
    force_unwrapping_detection: true
    ...
  ios:
    main_thread_violations: true
    keychain_usage_review: true
    ...

iOS/Swift Review Rules

This is the heart of the configuration.

Checks for Swift programming coding standards such as naming conventions, retain cycles, memory leaks and SwiftUI Best practices.

Rules that are helpful to validates main-thread UI updates, security (Keychain), battery usage, and accessibility.


Severity Levels

CodeRabbit classifies issues by impact

severity:
  critical:
    - security_vulnerabilities
    - memory_leaks
  high:
    - performance_issues
  medium:
    - code_style_violations
  low:
    - documentation_missing

Severity Levels

Integrations

CodeRabbit integrates with GitHub PRs, Xcode, CI/CD

integrations:
  github:
    pr_comments: true
    inline_comments: true
    summary_comments: true
    status_checks: true

Integrations

AI Powered Suggestions

This leverages CodeRabbit’s AI for smart recommendations

ai_suggestions:
  enabled: true
  suggestion_types:
    - performance_optimization
    - security_improvements

AI powered suggestions

Code Review Examples

We can explore some of the code review examples that has been generated by CodeRabbit along with our .coderabbit.yaml configuration file

Potential Issue - Timer is never invalidated

Potential Issue - Memory Leak

Potential Issue - Memory Leak

Refractor Suggestion - SwiftUI

We should maintain SwiftUI views by eliminating code duplication. There are other concepts such as ViewModifier and ViewBuilder.

Refractor Suggestion - SwiftUI

Refractor Suggestion - SwiftUI

Committable Suggestion

CodeRabbit AI that helps you to commit the suggestion code and can be merged easily.

Committable Suggestion

Committable Suggestion

Refractor Suggestion: Async/Await task Modifier

Async await task modifier

Async await task modifier

Add meaningful UI test assertions for the GitHub Explorer functionality

Meaningful UI Test Assertions

Meaningful UI Test Assertions

SPONSOR

iOS Conference AI Image

The Unique iOS Swift Conference in the UK

SwiftLeeds is a premier iOS conference taking place on October 7-8 this year. If you’re looking to stay updated on the latest trends in iOS development and connect with like-minded professionals, this event is a must-attend! Don’t miss out—book your tickets now!

Get your tickets!

Final Thoughts

AI-powered tech lead—guiding your code quality, mentoring your team, and flagging issues before they hit production. CodeRabbit isn’t just a reviewer—it’s a co-pilot for your iOS development workflow.


Note

Please find the GitHub PR Code Review for reference.

This is a free third party commenting service we are using for you, which needs you to sign in to post a comment, but the good bit is you can stay anonymous while commenting.