AI Code Review
Kody Rules
Kody Rules are customizable guidelines your team sets up to automatically enforce code quality, consistency, security, and maintainability.
How to use Kody Rules
You can use Kody Rules in two ways:
Create Custom Rules
Define rules based on your team’s exact needs. Kody Rules can be applied at two different levels:
File-Level Rules
Analyze individual files to catch issues within specific code files:
- Rule name: Clearly define the rule purpose.
- File Paths: Limit rules to specific files or directories using glob patterns.
- Severity: Set to Critical, High, Medium, or Low.
- Detailed Instructions: Clearly state what’s expected and why.
Example:
- Rule: “Avoid equality operators (==, !=) in loop termination conditions.”
- Path: src/**/*.ts
- Severity: Critical
- Instructions: “Using equality operators (== or !=) can cause infinite loops if exact values aren’t matched.”
Pull Request-Level Rules
Analyze the entire Pull Request for cross-file validation and PR-specific requirements:
The creation process is identical to file-level rules, but you must select the “Pull-request” scope. PR-level rules receive the complete list of changed files and PR information (title, description), enabling analysis of the overall context.
Examples:
- Every service file must have a corresponding test file
- PR description must be complete, clearly stating what was added or removed
- When a new route is created in a controller, it must be registered in routes.json
Import from Rules Library
Leverage proven best practices instantly:
- Navigate to Discovery Rules in your Kodus dashboard.
- Filter rules by severity, language, or tags.
- Import and activate rules with a single click.
Examples:
- Security: “Disallow use of insecure MD5 hashing.”
- Maintainability: “Limit React components to less than 150 lines.”