@corbat-tech/coding-standards-mcp 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -83,19 +83,89 @@ Corbat: ✓ Detected: Java 21, Spring Boot 3, Maven
83
83
 
84
84
  ---
85
85
 
86
- ## Benchmark Results
86
+ ## Benchmark Results v2.0
87
87
 
88
- Tested across 20 real-world scenarios:
88
+ ### Overall Impact
89
89
 
90
- | Metric | Without | With | Impact |
91
- |--------|:-------:|:----:|:------:|
92
- | **Quality Score** | 63/100 | 93/100 | +48% |
93
- | **Code Smells** | 43 | 0 | -100% |
94
- | **SOLID Compliance** | 50% | 89% | +78% |
95
- | **Tests Generated** | 219 | 558 | +155% |
96
- | **SonarQube** | FAIL | PASS | Fixed |
90
+ <div align="center">
91
+
92
+ | Metric | Without Corbat | With Corbat | **Improvement** |
93
+ |--------|:--------------:|:-----------:|:---------------:|
94
+ | **Quality Score** | 4.6/10 | 7.7/10 | **+67%** |
95
+ | **Custom Errors** | 3 | 18 | **+500%** |
96
+ | **Interfaces/Ports** | 19 | 41 | **+116%** |
97
+ | **Files (modularity)** | 55 | 95 | **+73%** |
98
+
99
+ </div>
97
100
 
98
- [View detailed benchmark report with code samples](docs/comparison-tests/RESULTS-REPORT.md)
101
+ ### By Complexity Level
102
+
103
+ | Category | Scenarios | Without | With | **Improvement** |
104
+ |----------|-----------|:-------:|:----:|:---------------:|
105
+ | **Basic** | UserService, REST API, React Form | 4.0 | 7.6 | **+90%** |
106
+ | **Intermediate** | Kafka Consumer, FastAPI, Go HTTP | 4.3 | 7.2 | **+67%** |
107
+ | **Advanced** | Saga, Circuit Breaker, Event Sourcing | 5.6 | 8.2 | **+46%** |
108
+
109
+ ### Pattern Detection
110
+
111
+ | Pattern | Without Corbat | With Corbat |
112
+ |---------|:--------------:|:-----------:|
113
+ | Hexagonal Architecture | 0/10 scenarios | **10/10** |
114
+ | Repository Pattern | 2/10 | **7/10** |
115
+ | Custom Error Types | 1/10 | **8/10** |
116
+ | Dependency Injection | 2/10 | **10/10** |
117
+ | Saga Pattern | 0/10 | **1/1** (when needed) |
118
+
119
+ ### Real Example: Saga Pattern (Scenario 07)
120
+
121
+ <table>
122
+ <tr>
123
+ <th>Without Corbat</th>
124
+ <th>With Corbat</th>
125
+ </tr>
126
+ <tr>
127
+ <td>
128
+
129
+ ```java
130
+ // Hardcoded rollback, not extensible
131
+ try {
132
+ targetAccount.credit(amount);
133
+ } catch (Exception e) {
134
+ rollbackDebit(sourceAccount, amount);
135
+ throw new TransferException(...);
136
+ }
137
+ ```
138
+
139
+ </td>
140
+ <td>
141
+
142
+ ```java
143
+ // Reusable Saga Pattern
144
+ public interface SagaStep<T> {
145
+ void execute(T context);
146
+ void compensate(T context);
147
+ }
148
+
149
+ public class SagaOrchestrator<T> {
150
+ public void execute(T context) {
151
+ for (SagaStep<T> step : steps) {
152
+ step.execute(context);
153
+ executedSteps.add(step);
154
+ }
155
+ }
156
+ // Auto-rollback on failure
157
+ }
158
+ ```
159
+
160
+ </td>
161
+ </tr>
162
+ <tr>
163
+ <td>9 files, 292 LOC, manual rollback</td>
164
+ <td><b>17 files, 707 LOC, orchestrated compensation</b></td>
165
+ </tr>
166
+ </table>
167
+
168
+ [View full benchmark analysis with 10 scenarios](benchmarks/v2/ANALYSIS.md)
99
169
 
100
170
  ---
101
171
 
@@ -105,36 +175,45 @@ Tested across 20 real-world scenarios:
105
175
 
106
176
  ```typescript
107
177
  class UserService {
108
- private users: User[] = [];
178
+ private users: Map<string, User> = new Map();
109
179
 
110
- getUser(id: string) {
111
- return this.users.find(u => u.id === id);
180
+ getById(id: string): User | undefined {
181
+ return this.users.get(id);
112
182
  }
113
183
 
114
- createUser(name: string, email: string) {
115
- const user = { id: Date.now(), name, email };
116
- this.users.push(user);
184
+ createUser(input: CreateUserInput): User {
185
+ if (!input.name) throw new Error('Name is required');
186
+ const user = { id: uuidv4(), ...input };
187
+ this.users.set(user.id, user);
117
188
  return user;
118
189
  }
119
190
  }
120
- // Problems: returns undefined, no validation, no DI, no tests
191
+ // Returns undefined Generic errors ✗ No DI Hardcoded storage
121
192
  ```
122
193
 
123
194
  ### After: With Corbat MCP
124
195
 
125
196
  ```typescript
197
+ // Port (interface)
126
198
  interface UserRepository {
127
- findById(id: UserId): User | null;
199
+ findById(id: string): User | null;
128
200
  save(user: User): void;
201
+ existsByEmail(email: string): boolean;
129
202
  }
130
203
 
204
+ // Custom errors
205
+ class UserNotFoundError extends Error { /*...*/ }
206
+ class UserAlreadyExistsError extends Error { /*...*/ }
207
+ class InvalidUserInputError extends Error { /*...*/ }
208
+
209
+ // Service with DI
131
210
  class UserService {
132
211
  constructor(
133
212
  private readonly repository: UserRepository,
134
213
  private readonly idGenerator: IdGenerator
135
214
  ) {}
136
215
 
137
- getUser(id: UserId): User {
216
+ getUserById(id: string): User {
138
217
  const user = this.repository.findById(id);
139
218
  if (!user) throw new UserNotFoundError(id);
140
219
  return user;
@@ -142,18 +221,17 @@ class UserService {
142
221
 
143
222
  createUser(input: CreateUserInput): User {
144
223
  this.validateInput(input);
145
- const user = User.create(
146
- this.idGenerator.generate(),
147
- input.name.trim(),
148
- input.email.toLowerCase()
149
- );
224
+ this.ensureEmailNotTaken(input.email);
225
+ const user = createUser(this.idGenerator.generate(), input);
150
226
  this.repository.save(user);
151
227
  return user;
152
228
  }
153
229
  }
154
- // ✓ Dependency injection Custom errors ✓ Validation15 tests
230
+ // ✓ Repository interface 3 custom errors DI 11 tests Testable
155
231
  ```
156
232
 
233
+ **Result:** 3 files → 7 files | 129 LOC → 308 LOC | 0 interfaces → 4 interfaces | 0 custom errors → 3
234
+
157
235
  ---
158
236
 
159
237
  ## Built-in Profiles
@@ -253,7 +331,7 @@ Your Prompt ──▶ Corbat MCP ──▶ AI + Standards
253
331
  | [Setup Guide](docs/setup.md) | Installation for all 25+ tools |
254
332
  | [Templates](docs/templates.md) | Ready-to-use `.corbat.json` configurations |
255
333
  | [Compatibility](docs/compatibility.md) | Full list of supported tools |
256
- | [Benchmark Report](docs/comparison-tests/RESULTS-REPORT.md) | 20 real-world tests with code samples |
334
+ | [Benchmark v2 Analysis](benchmarks/v2/ANALYSIS.md) | 10 scenarios with detailed comparison |
257
335
  | [API Reference](docs/full-documentation.md) | Tools, prompts, and configuration |
258
336
 
259
337
  ---
@@ -262,6 +340,12 @@ Your Prompt ──▶ Corbat MCP ──▶ AI + Standards
262
340
 
263
341
  **Stop fixing AI code. Start shipping it.**
264
342
 
343
+ | Without Corbat | With Corbat |
344
+ |:--------------:|:-----------:|
345
+ | 4.6/10 quality | **7.7/10 quality** |
346
+ | 3 custom errors | **18 custom errors** |
347
+ | 0% hexagonal | **100% hexagonal** |
348
+
265
349
  *Recommended by [corbat-tech](https://corbat.tech) — We use Claude Code internally, but Corbat MCP works with any MCP-compatible tool.*
266
350
 
267
351
  </div>
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Lightweight code analyzer using regex and heuristics.
3
+ * No AST parsing to keep it fast and dependency-free.
4
+ *
5
+ * This module provides real code analysis instead of just returning checklists.
6
+ * It detects anti-patterns, measures code quality metrics, and provides
7
+ * actionable feedback.
8
+ */
9
+ export interface AnalysisIssue {
10
+ type: 'CRITICAL' | 'WARNING' | 'INFO';
11
+ rule: string;
12
+ message: string;
13
+ line?: number;
14
+ suggestion?: string;
15
+ }
16
+ export interface CodeMetrics {
17
+ totalLines: number;
18
+ codeLines: number;
19
+ commentLines: number;
20
+ methodCount: number;
21
+ classCount: number;
22
+ interfaceCount: number;
23
+ testCount: number;
24
+ maxMethodLines: number;
25
+ maxClassLines: number;
26
+ customErrorCount: number;
27
+ importCount: number;
28
+ }
29
+ export interface AnalysisResult {
30
+ issues: AnalysisIssue[];
31
+ score: number;
32
+ summary: string;
33
+ metrics: CodeMetrics;
34
+ passed: boolean;
35
+ }
36
+ /**
37
+ * Analyze code and return issues, metrics, and score.
38
+ */
39
+ export declare function analyzeCode(code: string): AnalysisResult;
40
+ /**
41
+ * Format analysis result as markdown.
42
+ */
43
+ export declare function formatAnalysisAsMarkdown(result: AnalysisResult): string;
44
+ //# sourceMappingURL=code-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-analyzer.d.ts","sourceRoot":"","sources":["../../src/analysis/code-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAmLD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CA+FxD;AA0OD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAwFvE"}