|
1 | | -# .coderabbit.yaml |
| 1 | +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json |
2 | 2 | language: 'en-US' |
3 | | -early_access: false |
4 | | - |
| 3 | +tone_instructions: 'give formal and direct reviews with no humour and any other distracting text, only the necessary' |
5 | 4 | chat: |
6 | 5 | auto_reply: true |
7 | | - |
| 6 | + art: false |
8 | 7 | reviews: |
9 | | - poem: false |
10 | | - profile: 'assertive' # Options: assertive, chill, or thorough |
11 | | - high_level_summary: true |
12 | | - review_status: true |
13 | | - commit_status: true |
14 | | - collapse_walkthrough: false |
15 | | - |
16 | | - # Repo-specific guidance |
17 | | - # Custom instructions to guide the AI on Spring Boot specifics |
18 | | - instructions: | |
19 | | - Review the Java code focusing on Spring Boot best practices: |
20 | | - - Ensure proper use of @Service, @Repository, and @RestController annotations. |
21 | | - - Check for constructor-based dependency injection over @Autowired field injection. |
22 | | - - Verify that sensitive data is not logged and proper exception handling is in place. |
23 | | - - Monitor for efficient JPA/Hibernate usage to avoid N+1 query problems. |
24 | | - - Ensure Spring Boot configuration (application.properties/yaml) follows security standards. |
25 | | - - Look for proper use of @Transactional and thread-safety in shared services. |
26 | | -
|
27 | | - tone_instructions: "You are a senior Java architect. Provide constructive, technical, and concise feedback." |
28 | | - |
29 | | - # Use path + instructions |
30 | | - # Configure which files CodeRabbit should analyze or ignore |
31 | | - path_filters: |
32 | | - include: |
33 | | - - "src/main/java/**" |
34 | | - - "src/main/resources/*.yml" |
35 | | - - "src/main/resources/*.properties" |
36 | | - exclude: |
37 | | - - "**/generated/**" |
38 | | - - "src/test/**" # Optional: exclude tests if you only want logic reviews |
39 | | - |
| 8 | + profile: 'chill' |
| 9 | + request_changes_workflow: true |
40 | 10 | auto_review: |
41 | 11 | enabled: true |
42 | 12 | auto_incremental_review: true |
43 | | - drafts: false |
44 | | - base_branches: ['develop'] |
45 | | - ignore_title_keywords: ['WIP', 'Draft'] |
46 | | - labels: ['!skip-ai-review'] |
47 | | - ignore_usernames: ['dependabot', 'renovate[bot]'] |
48 | | - |
49 | | - finishing_touches: |
50 | | - docstrings: |
51 | | - enabled: true |
52 | | - unit_tests: |
53 | | - enabled: true |
54 | | - |
55 | | -# Valid schema: turn off gates entirely |
56 | | -pre_merge_checks: |
57 | | - mode: 'off' |
| 13 | + base_branches: |
| 14 | + - '^(?!release).*' |
| 15 | + poem: false |
| 16 | + high_level_summary: true |
| 17 | + suggested_labels: true |
| 18 | + auto_apply_labels: true |
| 19 | + labeling_instructions: |
| 20 | + - label: '⏱️ <10 Min Review' |
| 21 | + instructions: Apply for PRs with <200 lines changed |
| 22 | + - label: '⏱️ 10-30 Min Review' |
| 23 | + instructions: Apply for PRs with 200–1000 lines changed |
| 24 | + - label: '⏱️ 30-60 Min Review' |
| 25 | + instructions: Apply for PRs with 1000–2000 lines changed |
| 26 | + - label: '⏱️ 60+ Min Review' |
| 27 | + instructions: Apply for PRs with >2000 lines changed |
| 28 | + |
| 29 | + path_instructions: |
| 30 | + - path: '**' |
| 31 | + instructions: | |
| 32 | + ## General Project Standards |
| 33 | + ### Security & Performance |
| 34 | + - Validate and sanitize all incoming data (use Bean Validation with `@Valid` and constraints). |
| 35 | + - Always use prepared statements, parameterized queries, or Spring Data repositories. |
| 36 | + - Use Spring Security for authentication and method-level authorization. |
| 37 | + - Apply the principle of least privilege for access control. |
| 38 | + - Configure connection pools (HikariCP) properly for performance. |
| 39 | + - Cache frequently accessed results with `@Cacheable` and invalidate with `@CacheEvict`. |
| 40 | + - Offload long-running or blocking work using `@Async`, schedulers, or queues. |
| 41 | + - Avoid blocking I/O in reactive (WebFlux) contexts. |
| 42 | +
|
| 43 | + ### Code Quality & Documentation |
| 44 | + - Apply DRY, SOLID, and Clean Architecture principles. |
| 45 | + - Avoid framework coupling in domain or application layers. |
| 46 | + - Maintain up-to-date API documentation via SpringDoc (OpenAPI 3) or REST Docs. |
| 47 | + - Use Checkstyle or SpotBugs for static code analysis. |
| 48 | + - Prefer immutability and constructor injection for all beans. |
| 49 | +
|
| 50 | + - path: 'src/main/java/**' |
| 51 | + instructions: | |
| 52 | + ## Project & Package Structure |
| 53 | + - Follow DDD-inspired modular structure: |
| 54 | + ``` |
| 55 | + com.company.project |
| 56 | + ├── api # REST controllers, request/response DTOs |
| 57 | + ├── application # Services, use cases, orchestrators |
| 58 | + ├── domain # Entities, value objects, domain events, aggregates |
| 59 | + ├── infrastructure |
| 60 | + │ ├── persistence # JPA, repositories, adapters |
| 61 | + │ ├── messaging # Kafka, RabbitMQ adapters |
| 62 | + │ └── config # Spring @Configuration classes |
| 63 | + └── shared # Common utilities, constants, base abstractions |
| 64 | + ``` |
| 65 | + - Each module should have a clear boundary and minimal dependencies. |
| 66 | + - No circular dependencies between packages. |
| 67 | + - Do not mix domain and infrastructure code. |
| 68 | +
|
| 69 | + - path: '**/*.java' |
| 70 | + instructions: | |
| 71 | + ## General Java + Spring Coding Standards |
| 72 | + ### Style & Conventions |
| 73 | + - Class names: PascalCase. Methods/fields: camelCase. Constants: UPPER_CASE. |
| 74 | + - Avoid wildcard imports; import explicitly. |
| 75 | + - Use Lombok judiciously. Avoid `@Data`; prefer `@Value`, `@Getter`, and explicit constructors. |
| 76 | + - Apply `final` to fields injected via constructors. |
| 77 | + - Avoid mutable static state or utility singletons. |
| 78 | +
|
| 79 | + ### Dependency Injection |
| 80 | + - Prefer constructor-based injection. Avoid field injection. |
| 81 | + - Mark service components with `@Service` or `@Component`. |
| 82 | + - Use `@ConfigurationProperties` for structured config, validated with `@Validated`. |
| 83 | + - Keep beans stateless wherever possible. |
| 84 | +
|
| 85 | + ### Methods & Classes |
| 86 | + - Keep methods concise (<20 lines). |
| 87 | + - Limit public methods in classes; prefer package-private visibility for internal logic. |
| 88 | + - Extract reusable logic to smaller, cohesive components. |
| 89 | + - Avoid logic inside constructors or `@PostConstruct` unless necessary. |
| 90 | + - Prefer returning Optional or sealed result types instead of null. |
| 91 | +
|
| 92 | + ### Logging & Exceptions |
| 93 | + - Use SLF4J (`@Slf4j`) for logging. |
| 94 | + - Never log sensitive data (PII, tokens). |
| 95 | + - Throw domain-specific exceptions rather than generic ones. |
| 96 | + - Use `@ControllerAdvice` with `@ExceptionHandler` for global error mapping. |
| 97 | +
|
| 98 | + ### Documentation |
| 99 | + - Public methods and classes MUST have Javadoc. |
| 100 | + - Document complex business rules with “why” comments, not “what”. |
| 101 | +
|
| 102 | + - path: 'src/main/java/**/api/**/*.java' |
| 103 | + instructions: | |
| 104 | + ## API & Controllers |
| 105 | + - Use `@RestController` for REST endpoints, `@RequestMapping` for base paths. |
| 106 | + - Controllers must delegate all logic to application or domain layers. |
| 107 | + - Validate inputs with `@Valid` and Jakarta validation annotations. |
| 108 | + - Always return DTOs, never entities. |
| 109 | + - Use meaningful HTTP status codes (`ResponseEntity` preferred). |
| 110 | + - Document endpoints using OpenAPI annotations or SpringDoc. |
| 111 | + - Avoid excessive controller logic — aim for single responsibility per endpoint. |
| 112 | +
|
| 113 | + - path: 'src/main/java/**/application/**/*.java' |
| 114 | + instructions: | |
| 115 | + ## Application Layer (Use Cases) |
| 116 | + - Services encapsulate use cases — stateless and orchestrate domain operations. |
| 117 | + - Annotate with `@Service`; manage transactions with `@Transactional`. |
| 118 | + - Avoid direct dependency on controllers or persistence details. |
| 119 | + - Return well-defined domain or DTO responses. |
| 120 | + - Avoid leaking persistence entities or DTOs outside the application layer. |
| 121 | +
|
| 122 | + - path: 'src/main/java/**/domain/**/*.java' |
| 123 | + instructions: | |
| 124 | + ## Domain Layer |
| 125 | + - Contains entities, value objects, and domain events only. |
| 126 | + - No dependencies on Spring, frameworks, or infrastructure. |
| 127 | + - Entities should encapsulate behavior and invariants. |
| 128 | + - Use immutable patterns for Value Objects (explicit constructors, final fields). Lombok `@Value` may be used as it's compile-time only. |
| 129 | + - Domain events should be POJOs with clear purpose. |
| 130 | + - Domain services should express business logic that doesn’t belong to entities. |
| 131 | +
|
| 132 | + - path: 'src/main/java/**/infrastructure/**/*.java' |
| 133 | + instructions: | |
| 134 | + ## Infrastructure Layer |
| 135 | + - Contains all technical implementations (persistence, messaging, integration). |
| 136 | + - JPA entities should reside here, separate from domain models. |
| 137 | + - Use repositories extending `JpaRepository` or custom interfaces. |
| 138 | + - Mark adapters with `@Repository`, `@Component`, or `@Configuration`. |
| 139 | + - Manage transactions only at the service level, not in repositories. |
| 140 | + - Define mappers for converting between persistence models and domain models. |
| 141 | +
|
| 142 | + - path: 'src/main/java/**/config/**/*.java' |
| 143 | + instructions: | |
| 144 | + ## Configuration & Bootstrapping |
| 145 | + - Use `@Configuration` for bean definitions. |
| 146 | + - Use `@EnableScheduling`, `@EnableAsync`, or other annotations only where necessary. |
| 147 | + - Configuration must be environment-agnostic. |
| 148 | + - Avoid business logic in configuration classes. |
| 149 | + - Use profiles (`@Profile`) for environment-specific beans. |
| 150 | + - Externalize configuration in `application.yml` and validate on startup. |
| 151 | +
|
| 152 | + - path: 'src/test/java/**' |
| 153 | + instructions: | |
| 154 | + ## Testing Standards |
| 155 | + - Use JUnit 5, Mockito, and AssertJ. |
| 156 | + - Name tests `ClassNameTest` or `ClassNameIT` (for integration). |
| 157 | + - Unit tests must be isolated (mock dependencies). |
| 158 | + - Use Testcontainers for database or integration tests. |
| 159 | + - Use `@SpringBootTest` only for full-context integration tests. |
| 160 | + - Verify both happy path and edge cases. |
| 161 | + - Maintain >80% coverage for core business logic. |
| 162 | +
|
| 163 | + - path: '{pom.xml,build.gradle,README.md,application.yml,application.properties}' |
| 164 | + instructions: | |
| 165 | + ## Project-Level Standards |
| 166 | + - **pom.xml / build.gradle:** |
| 167 | + - Use Java 21+ and Spring Boot 3.x. |
| 168 | + - Include dependencies: Spring Boot Starter (Web, Data JPA, Validation, Test). |
| 169 | + - Enforce static analysis: Checkstyle, Spotless, PMD. |
| 170 | + - Configure `jacoco` or `kover` for code coverage reporting. |
| 171 | + - **README.md:** |
| 172 | + - Must include setup, build, and run instructions. |
| 173 | + - List all environment variables and required external services. |
| 174 | + - Describe how to run tests and generate API docs. |
| 175 | + - **application.yml:** |
| 176 | + - Organize by domain (e.g., `spring.datasource`, `app.security`, `app.cache`). |
| 177 | + - Never commit secrets. |
| 178 | + - Validate configuration via `@ConfigurationProperties`. |
| 179 | + - Provide `application-example.yml` for reference. |
0 commit comments