Automated Code Reviews
The Dice Chess Engine uses CodeRabbit for automated pull request reviews. CodeRabbit analyzes every PR against main and provides inline feedback on correctness, performance, and style — with domain-specific awareness of our chess engine architecture.
Quality Toolchain Overview
Section titled “Quality Toolchain Overview”CodeRabbit is one layer in a multi-stage quality pipeline:
graph LR
subgraph Local
A["pre-commit hooks<br/>(scalafmt + betterleaks)"] --> B["mise run check<br/>(full gate, before PR)"]
end
subgraph CI
C["sbt scalafmt + scalafix + MUnit"] --> D["SonarCloud"]
C --> E["CodeRabbit"]
C --> F["JetBrains Qodana"]
end
B -.->|same checks| C
| Layer | Tool | Purpose |
|---|---|---|
| Pre-commit | gitleaks |
Intercept leaked secrets before they reach Git history |
| Pre-commit | pre-commit-hooks |
Trailing whitespace, YAML syntax, merge conflicts |
| CI | scalafmt |
Enforce consistent Scala code formatting |
| CI | scalafix |
Enforce strict syntax rules (ban null, throw, return) |
| CI | MUnit + scoverage |
Unit tests with coverage reporting (>85%) |
| CI | CodeRabbit | AI-powered PR review with domain-specific instructions |
| CI | SonarCloud | Static analysis: code smells, vulnerabilities, coverage metrics |
| CI | Qodana | JetBrains deep code inspection |
Strict Typing & Linting (Scalafix & Compiler Flags)
Section titled “Strict Typing & Linting (Scalafix & Compiler Flags)”To ensure memory safety, functional purity, and a high-performance codebase, we enforce strict compiler and linter rules. These constraints prevent common anti-patterns like NullPointerExceptions and obscure control flow bugs.
Scala 3 Compiler Flags
Section titled “Scala 3 Compiler Flags”-Yexplicit-nulls: Changes the Scala 3 type system so that reference types (likeStringorAnyRef) are non-nullable by default. This forces developers to useOption[T]to safely represent the absence of a value, eliminating implicit nulls at the compiler level.-language:strictEquality: Requires explicit opt-in (viaCanEqualtypeclasses) to compare two objects with==. This catches bug-prone comparisons (like comparing aSquareto aPiece) at compile-time instead of silently returningfalseat runtime.
Scalafix Rules (DisableSyntax)
Section titled “Scalafix Rules (DisableSyntax)”We actively ban problematic keywords through .scalafix.conf:
null: Thenullkeyword is strictly forbidden. This protects the JS boundary (where JS might passnull), forcing us to safely wrap it viaOption(value)instead.throw: Throwing exceptions breaks referential transparency and control flow. We usesys.errorfor truly unrecoverable fatal errors, orEither/Optionfor business logic errors.return: Explicitreturnstatements are banned because they can cause unintended behavior inside lambdas and closures. We instead rely on Scala 3’sboundary/breakconstructs for early exit logic, or simply standard functional expressions (if/else).
Configuration
Section titled “Configuration”All CodeRabbit settings live in .coderabbit.yaml at the repository root. The file uses the v2 schema and is version-controlled alongside the codebase.
Review Profile
Section titled “Review Profile”The review profile is set to assertive, which provides rigorous, performance-oriented feedback — appropriate for a chess engine where micro-optimization and bitwise correctness are critical.
Disabled Features
Section titled “Disabled Features”| Feature | Reason |
|---|---|
high_level_summary |
Adds noise to PR threads without actionable value |
poem |
Decorative; distracting in a technical engine project |
eslint |
No hand-written JavaScript — all JS is machine-generated by Scala.js |
biome |
No JS/TS source code to format or lint |
Enabled Tools
Section titled “Enabled Tools”| Tool | What It Checks |
|---|---|
actionlint |
Validates GitHub Actions workflow YAML syntax and expressions |
gitleaks |
Detects leaked secrets (complements the pre-commit hook) |
shellcheck |
Lints shell scripts embedded in mise.toml and CI workflows |
markdownlint |
Validates documentation and README markdown formatting |
Path Filters
Section titled “Path Filters”Build artifacts, generated files, and vendored dependencies are excluded from review to reduce noise:
path_filters: - "!**/target/**" # SBT build output - "!**/project/target/**" # SBT meta-build output - "!dist/**" # NPM package distribution - "!**/*.lock" # Lock files - "!**/package-lock.json" # NPM lock file - "!docs/public/**" # Static assetsDomain-Specific Review Instructions
Section titled “Domain-Specific Review Instructions”CodeRabbit supports path-based review instructions — targeted guidance that activates only when a PR touches specific directories. This gives the AI reviewer domain knowledge about our engine architecture.
Configured Paths
Section titled “Configured Paths”| Path Pattern | Review Focus |
|---|---|
shared/**/domain/** |
Opaque type contracts, zero-cost abstraction, bitwise correctness |
shared/**/movegen/** |
Magic Bitboards, GC-free hot paths, Dice Chess rule enforcement |
shared/src/test/** |
Test DSL usage, edge case coverage, JSON fixture validity |
.github/workflows/** |
Pinned action SHAs, consistent Java/Node versions, no redundant tool installs |
docs/** |
Starlight frontmatter, Mermaid syntax, internal link integrity |
build.sbt |
Cross-compilation consistency, plugin configuration |
Example: Move Generation Instructions
Section titled “Example: Move Generation Instructions”When a PR modifies files under shared/**/movegen/**, CodeRabbit receives these instructions:
Prioritize correctness of bitwise shift/mask operations. Flag any heap allocations in hot paths. Verify Magic Bitboard lookup tables are indexed correctly. Check that Dice Chess rules are applied: max 3 micro-moves per turn, maximal micro-move count enforcement, and correct piece filtering by dice roll value.
This ensures the AI reviewer focuses on engine-specific concerns rather than generic code style.
Interacting with CodeRabbit
Section titled “Interacting with CodeRabbit”On any PR, you can use comment commands to interact with CodeRabbit:
| Command | Effect |
|---|---|
@coderabbitai review |
Trigger a full re-review of the PR |
@coderabbitai resolve |
Mark all CodeRabbit comments as resolved |
@coderabbitai configuration |
Display the current effective configuration |
@coderabbitai help |
List all available commands |