-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy path.coderabbit.yaml
More file actions
193 lines (175 loc) · 6.83 KB
/
.coderabbit.yaml
File metadata and controls
193 lines (175 loc) · 6.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# CodeRabbit Configuration for SOLID Principles & Clean Code
# Reference: https://docs.coderabbit.ai/reference/configuration
language: en-US
tone_instructions: "Focus on SOLID principles, clean code practices, and maintainable architecture. Be thorough but constructive in feedback."
reviews:
profile: chill
high_level_summary: true
poem: true
auto_review:
enabled: true
drafts: false
base_branches:
- main
- test
# Pre-merge checks for SOLID principles and clean code
pre_merge_checks:
docstrings:
mode: "off"
title:
mode: "off"
description:
mode: "off"
custom_checks:
- mode: "warning" # Change to "error" to block merges on violations
name: "SOLID & Clean Code"
instructions: |
## Single Responsibility Principle (SRP)
- Each class/function should have only one reason to change
- Functions should do one thing and do it well
- Avoid god classes or functions with multiple responsibilities
- Look for functions longer than 20 lines or classes with >200 lines
## Open/Closed Principle (OCP)
- Classes should be open for extension but closed for modification
- Prefer composition over inheritance
- Use interfaces and abstract classes for extensibility
- Avoid modifying existing code when adding new features
## DRY Principle (Don't Repeat Yourself)
- Eliminate code duplication by extracting common functionality
- Create reusable functions, components, and utilities
- Use constants for repeated values
- Consolidate similar logic into shared modules
- Avoid copy-paste programming
- Extract repeated patterns into abstractions
- Use configuration objects instead of hardcoded values
## KISS Principle (Keep It Simple, Stupid)
- Prefer simple solutions over complex ones
- Avoid over-engineering and premature optimization
- Use clear, readable code over clever code
- Choose straightforward algorithms over complex ones
- Avoid unnecessary abstractions and layers
- Write code that's easy to understand and maintain
- Prefer explicit over implicit behavior
## Clean Code Practices
- Use descriptive names for variables, functions, and classes
- Keep functions small and focused
- Avoid deep nesting (max 3 levels)
- Use meaningful comments, not obvious ones
- Follow consistent naming conventions
- Handle errors gracefully
- Write self-documenting code
# Path-specific instructions for different file types
path_instructions:
# React Components
- path: "components/**/*.tsx"
instructions: |
For React components, ensure:
- Single responsibility per component
- Proper prop interfaces (ISP)
- Use composition over inheritance
- Avoid prop drilling (use context or state management)
- Keep components under 200 lines
- Extract custom hooks for complex logic
- Use TypeScript interfaces for props
- DRY: Extract common UI patterns into reusable components
- KISS: Prefer simple component structure over complex abstractions
# Hooks
- path: "hooks/**/*.ts"
instructions: |
For custom hooks, ensure:
- Single responsibility per hook
- Return consistent interface
- Handle edge cases and errors
- Use proper dependency arrays
- Keep hooks focused and reusable
- Follow naming convention (use prefix)
- DRY: Extract common hook logic into shared utilities
- KISS: Avoid complex hook compositions, prefer simple state management
# API Routes
- path: "app/api/**/*.ts"
instructions: |
For API routes, ensure:
- Single responsibility per route handler
- Proper error handling and validation
- Use dependency injection for services
- Follow RESTful principles
- Validate input parameters
- Return consistent response formats
- DRY: Extract common validation and error handling logic
- KISS: Use simple, straightforward request/response patterns
# Utility Functions
- path: "lib/**/*.ts"
instructions: |
For utility functions, ensure:
- Pure functions when possible
- Single responsibility per function
- Proper error handling
- Use TypeScript for type safety
- Avoid side effects
- Keep functions under 50 lines
- DRY: Consolidate similar logic into shared utilities
- KISS: Prefer simple, readable implementations over clever optimizations
# Providers/Context
- path: "providers/**/*.tsx"
instructions: |
For React providers, ensure:
- Single responsibility per provider
- Proper context interface design
- Avoid prop drilling
- Use composition for complex state
- Handle loading and error states
- Keep providers focused and testable
- DRY: Extract common provider patterns into reusable hooks
- KISS: Avoid over-abstracting state management, keep it simple
# Utils folder restrictions
- path: "utils/**"
instructions: |
❌ NEVER use the utils folder!
- This folder is deprecated and should not be used
- Instead, organize utilities by domain: lib/[domain]/[functionName].ts
- Example: lib/auth/validateToken.ts instead of utils/auth.ts
- This provides better organization and discoverability
# Generic lib/utils restrictions
- path: "lib/utils/**"
instructions: |
❌ NEVER use a generic utils folder in lib!
- Avoid lib/utils/ as it creates a catch-all dumping ground
- Instead, organize by domain: lib/[domain]/[functionName].ts
- Example: lib/validation/emailValidator.ts instead of lib/utils/validation.ts
- Example: lib/formatting/dateFormatter.ts instead of lib/utils/formatters.ts
- This makes code more discoverable and maintainable
# File patterns to include/exclude
path_filters:
- "src/**"
- "components/**"
- "hooks/**"
- "lib/**"
- "providers/**"
- "app/**"
- "!**/*.test.*"
- "!**/*.spec.*"
- "!**/node_modules/**"
- "!**/dist/**"
- "!**/build/**"
# Additional checks
commit_status: true
review_status: true
changed_files_summary: true
sequence_diagrams: true
estimate_code_review_effort: true
assess_linked_issues: true
related_issues: true
related_prs: true
suggested_labels: true
suggested_reviewers: true
# Knowledge base configuration
knowledge_base:
learnings:
scope: auto
issues:
scope: auto
pull_requests:
scope: auto
# Global settings
early_access: false
enable_free_tier: true