mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
feat: add repository pattern validation (v0.5.0)
Add comprehensive Repository Pattern validation to detect violations and ensure proper domain-infrastructure separation. Features: - ORM type detection in repository interfaces (25+ patterns) - Concrete repository usage detection in use cases - Repository instantiation detection (new Repository()) - Domain language validation for repository methods - Smart violation reporting with fix suggestions Tests: - 31 new tests for repository pattern detection - 292 total tests passing (100% pass rate) - 96.77% statement coverage, 83.82% branch coverage Examples: - 8 example files (4 bad patterns, 4 good patterns) - Demonstrates Clean Architecture and SOLID principles
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* ❌ BAD EXAMPLE: Technical method names
|
||||
*
|
||||
* Repository interface uses database/ORM terminology instead of domain language.
|
||||
* Methods should reflect business operations, not technical implementation.
|
||||
*/
|
||||
|
||||
interface IUserRepository {
|
||||
findOne(id: string): Promise<User | null>
|
||||
|
||||
findMany(filter: any): Promise<User[]>
|
||||
|
||||
insert(user: User): Promise<void>
|
||||
|
||||
updateOne(id: string, data: any): Promise<void>
|
||||
|
||||
deleteOne(id: string): Promise<void>
|
||||
|
||||
query(sql: string): Promise<any>
|
||||
|
||||
execute(command: string): Promise<void>
|
||||
|
||||
select(fields: string[]): Promise<User[]>
|
||||
}
|
||||
|
||||
class User {
|
||||
constructor(
|
||||
public id: string,
|
||||
public email: string,
|
||||
public name: string,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user