Skip to content

Commit ef84bcd

Browse files
author
Ansh Varshney
committed
fix: edited .coderabbit.yml acc to instructions.
1 parent 4cb7754 commit ef84bcd

1 file changed

Lines changed: 59 additions & 35 deletions

File tree

.coderabbit.yaml

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@ reviews:
1818
high_level_summary: true
1919
suggested_labels: true
2020
auto_apply_labels: true
21-
finishing_touches: true
21+
finishing_touches:
22+
# docstrings: auto-generates Javadoc for functions changed in the PR,
23+
# then opens a follow-up PR containing only the docstring edits.
24+
docstrings:
25+
enabled: true
26+
# unit_tests: suggests unit-test stubs for new/changed methods.
27+
unit_tests:
28+
enabled: true
29+
# simplify: reviews changed code for reuse, quality, and efficiency
30+
# and applies targeted improvements (disabled by default upstream; enabled here).
31+
simplify:
32+
enabled: true
33+
# custom: up to 5 named recipes triggerable via @coderabbitai run <name>.
34+
custom: []
2235
labeling_instructions:
2336
- label: '⏱️ <10 Min Review'
2437
instructions: Apply for PRs with <200 lines changed
@@ -111,14 +124,13 @@ reviews:
111124
org.apache.fineract.selfservice.<module>
112125
├── api # REST resource classes and Swagger annotation holders only
113126
├── data # Read-model DTOs and command/response objects
114-
├── domain # Entities, value objects, domain events — zero framework dependencies
127+
├── domain # Entities / value objects — may carry JPA annotations per Fineract convention
115128
├── exception # Domain-specific exception types
116129
├── handler # CQRS command handlers
117130
├── service # Application services and use-case orchestrators
118131
└── starter # Spring Boot auto-configuration entry points
119132
```
120133
- No circular dependencies between packages within or across modules.
121-
- Domain must not import from api, service, handler, or starter packages.
122134
- Starter classes are the only place where the module wires itself into Spring Boot.
123135
124136
# ── API / CONTROLLER LAYER ────────────────────────────────────────────────
@@ -183,40 +195,52 @@ reviews:
183195
- Use `@Async` with a configured `ThreadPoolTaskExecutor` for any blocking or long-running operation.
184196
Flag any `Thread.sleep()` or blocking I/O call on a request thread.
185197
186-
# ── DOMAIN LAYER — ZERO FRAMEWORK TOLERANCE ───────────────────────────────
198+
# ── DOMAIN LAYER ──────────────────────────────────────────────────────────
187199
- path: 'src/main/java/**/domain/**/*.java'
188200
instructions: |
189-
## Domain Layer — Framework Independence is MANDATORY
190-
191-
### Forbidden Imports — Flag Every Occurrence
192-
The following import namespaces must NEVER appear in the domain layer.
193-
Flag immediately if any of the following prefixes are found in an import statement:
194-
195-
- `org.springframework.` — No Spring annotations, beans, context, or utilities.
196-
- `jakarta.persistence.` — No JPA annotations (`@Entity`, `@Table`, `@Column`, `@Id`, `@ManyToOne`, etc.).
197-
- `javax.persistence.` — Legacy JPA namespace, also banned.
198-
- `org.hibernate.` — No Hibernate-specific annotations or types.
199-
- `jakarta.ws.rs.` — No JAX-RS (Jersey) web annotations.
200-
- `javax.ws.rs.` — Legacy JAX-RS, also banned.
201-
- `jakarta.servlet.` — No Servlet API.
202-
- `com.fasterxml.jackson.` — No Jackson annotations on domain objects.
203-
- `io.swagger.` — No Swagger/OpenAPI annotations on domain objects.
204-
205-
### What Belongs Here
206-
- **Entities**: model business concepts with behaviour, not just data.
207-
Entities must protect their own invariants in constructors or factory methods.
208-
- **Value Objects**: immutable, all fields `final`, no setters.
209-
Lombok `@Value` is acceptable (compile-time only, no runtime Spring dependency).
210-
- **Domain Events**: plain POJOs named after what happened (e.g., `LoanRepaymentMadeEvent`).
211-
- **Repository interfaces**: interfaces only — zero implementation code.
212-
Implementations live in the infrastructure or starter layer.
213-
- **Domain Services**: stateless classes for business logic that spans multiple entities.
214-
215-
### Invariants & Behaviour
216-
- Avoid anemic domain models (entities with only getters/setters and no behaviour).
217-
Flag any entity class where all methods are trivial accessors with no business logic.
218-
- Do not expose setters for fields that must not change after construction — use private setters or none.
219-
- `equals` and `hashCode` on entities must be based solely on the persistent identity (primary key).
201+
## Domain Layer
202+
203+
This repository follows Fineract's Active Record convention: domain classes
204+
are also JPA entities. `jakarta.persistence.*` annotations (`@Entity`, `@Table`,
205+
`@Column`, `@ManyToOne`, etc.) are **permitted and expected** here. Do not flag them.
206+
207+
### Permitted in Domain Classes
208+
- `jakarta.persistence.*` — JPA mapping annotations are standard in this codebase.
209+
- `org.springframework.security.*` — domain user objects implement Spring Security
210+
interfaces (e.g., `UserDetails`) per Fineract convention.
211+
- `org.apache.fineract.*` — cross-module Fineract types (Office, Client, Role, etc.).
212+
213+
### Forbidden in Domain Classes
214+
- `jakarta.ws.rs.*` / `javax.ws.rs.*` — JAX-RS/Jersey annotations belong in `api` only.
215+
Flag any occurrence.
216+
- `jakarta.servlet.*` / `javax.servlet.*` — Servlet API must not appear here.
217+
Flag any occurrence.
218+
- `io.swagger.*` — Swagger/OpenAPI annotations belong in `*ApiResourceSwagger.java` only.
219+
Flag any occurrence.
220+
- `com.fasterxml.jackson.*` — Jackson serialisation annotations do not belong on domain
221+
objects; use dedicated DTO classes in the `data` package instead. Flag any occurrence.
222+
223+
### JPA Usage Rules
224+
- `@Data` (Lombok) is banned on JPA entities — it generates `equals`/`hashCode` on mutable
225+
state and breaks Hibernate dirty-checking. Flag any occurrence.
226+
- `equals` and `hashCode` on entities must be based solely on the persistent identity
227+
(primary key). Flag any implementation that compares mutable business fields.
228+
- `@ManyToMany(fetch = FetchType.EAGER)` should be flagged as a potential N+1 source.
229+
Prefer `LAZY` and document any intentional eager fetch with an inline comment.
230+
- `CascadeType.ALL` on a `@ManyToOne` should be flagged — cascading deletes from the
231+
child side of a relationship is almost always unintentional.
232+
233+
### Behaviour & Invariants
234+
- Domain classes must contain business behaviour, not just getters and setters.
235+
Flag any class in `domain/` where every method is a trivial accessor with no logic.
236+
- Invariants must be enforced in constructors or factory methods (`fromJson`, `create`, etc.).
237+
Flag classes where the no-arg constructor leaves the object in a state that violates
238+
its own business rules.
239+
- Soft-delete methods must mark the record as deleted AND invalidate unique-constraint
240+
fields (e.g., prepend the ID to the username) in a single atomic method call.
241+
Flag implementations that do one but not the other.
242+
- Do not expose setters for identity or unique-constraint fields (primary key, username).
243+
These must only be set at construction time.
220244
221245
# ── HANDLER LAYER (CQRS) ──────────────────────────────────────────────────
222246
- path: 'src/main/java/**/handler/**/*.java'

0 commit comments

Comments
 (0)