@su-record/vibe 2.6.16 → 2.6.18
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/CLAUDE.md +681 -681
- package/LICENSE +21 -21
- package/README.md +235 -203
- package/agents/architect-low.md +41 -41
- package/agents/architect-medium.md +59 -59
- package/agents/architect.md +80 -80
- package/agents/build-error-resolver.md +115 -115
- package/agents/compounder.md +261 -261
- package/agents/diagrammer.md +178 -178
- package/agents/e2e-tester.md +266 -266
- package/agents/explorer-low.md +42 -42
- package/agents/explorer-medium.md +59 -59
- package/agents/explorer.md +48 -48
- package/agents/implementer-low.md +43 -43
- package/agents/implementer-medium.md +52 -52
- package/agents/implementer.md +54 -54
- package/agents/refactor-cleaner.md +143 -143
- package/agents/research/best-practices-agent.md +199 -199
- package/agents/research/codebase-patterns-agent.md +157 -157
- package/agents/research/framework-docs-agent.md +188 -188
- package/agents/research/security-advisory-agent.md +213 -213
- package/agents/review/architecture-reviewer.md +107 -107
- package/agents/review/complexity-reviewer.md +116 -116
- package/agents/review/data-integrity-reviewer.md +88 -88
- package/agents/review/git-history-reviewer.md +103 -103
- package/agents/review/performance-reviewer.md +86 -86
- package/agents/review/python-reviewer.md +150 -150
- package/agents/review/rails-reviewer.md +139 -139
- package/agents/review/react-reviewer.md +144 -144
- package/agents/review/security-reviewer.md +80 -80
- package/agents/review/simplicity-reviewer.md +140 -140
- package/agents/review/test-coverage-reviewer.md +116 -116
- package/agents/review/typescript-reviewer.md +127 -127
- package/agents/searcher.md +54 -54
- package/agents/simplifier.md +120 -120
- package/agents/tester.md +49 -49
- package/agents/ui-previewer.md +268 -268
- package/commands/vibe.analyze.md +356 -356
- package/commands/vibe.reason.md +329 -329
- package/commands/vibe.review.md +412 -412
- package/commands/vibe.run.md +1266 -1266
- package/commands/vibe.spec.md +1054 -1054
- package/commands/vibe.spec.review.md +319 -319
- package/commands/vibe.trace.md +161 -161
- package/commands/vibe.utils.md +376 -376
- package/commands/vibe.verify.md +375 -375
- package/dist/cli/collaborator.js +52 -52
- package/dist/cli/detect.js +32 -32
- package/dist/cli/hud.js +20 -20
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +120 -118
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/llm.js +144 -144
- package/dist/cli/postinstall.d.ts +1 -0
- package/dist/cli/postinstall.d.ts.map +1 -1
- package/dist/cli/postinstall.js +859 -859
- package/dist/cli/postinstall.js.map +1 -1
- package/dist/cli/setup/ProjectSetup.d.ts +2 -2
- package/dist/cli/setup/ProjectSetup.d.ts.map +1 -1
- package/dist/cli/setup/ProjectSetup.js +51 -17
- package/dist/cli/setup/ProjectSetup.js.map +1 -1
- package/dist/lib/DeepInit.js +24 -24
- package/dist/lib/IterationTracker.js +11 -11
- package/dist/lib/PythonParser.js +108 -108
- package/dist/lib/ReviewRace.js +96 -96
- package/dist/lib/SkillFrontmatter.js +28 -28
- package/dist/lib/SkillQualityGate.js +9 -9
- package/dist/lib/SkillRepository.js +159 -159
- package/dist/lib/UltraQA.js +77 -77
- package/dist/lib/gemini-api.js +5 -5
- package/dist/lib/gpt-api.js +4 -4
- package/dist/lib/memory/KnowledgeGraph.js +4 -4
- package/dist/lib/memory/MemorySearch.js +20 -20
- package/dist/lib/memory/MemoryStorage.js +64 -64
- package/dist/orchestrator/AgentManager.js +12 -12
- package/dist/orchestrator/MultiLlmResearch.js +8 -8
- package/dist/orchestrator/SmartRouter.js +11 -11
- package/dist/orchestrator/SwarmOrchestrator.d.ts +144 -0
- package/dist/orchestrator/SwarmOrchestrator.d.ts.map +1 -0
- package/dist/orchestrator/SwarmOrchestrator.js +361 -0
- package/dist/orchestrator/SwarmOrchestrator.js.map +1 -0
- package/dist/orchestrator/SwarmOrchestrator.test.d.ts +5 -0
- package/dist/orchestrator/SwarmOrchestrator.test.d.ts.map +1 -0
- package/dist/orchestrator/SwarmOrchestrator.test.js +95 -0
- package/dist/orchestrator/SwarmOrchestrator.test.js.map +1 -0
- package/dist/orchestrator/index.d.ts +2 -0
- package/dist/orchestrator/index.d.ts.map +1 -1
- package/dist/orchestrator/index.js +2 -0
- package/dist/orchestrator/index.js.map +1 -1
- package/dist/orchestrator/parallelResearch.js +24 -24
- package/dist/tools/convention/analyzeComplexity.test.js +115 -115
- package/dist/tools/convention/validateCodeQuality.test.js +104 -104
- package/dist/tools/spec/prdParser.test.js +171 -171
- package/dist/tools/spec/specGenerator.js +169 -169
- package/dist/tools/spec/traceabilityMatrix.js +64 -64
- package/dist/tools/spec/traceabilityMatrix.test.js +28 -28
- package/hooks/hooks.json +222 -222
- package/hooks/scripts/code-check.js +22 -22
- package/hooks/scripts/code-review.js +22 -22
- package/hooks/scripts/complexity.js +22 -22
- package/hooks/scripts/compound.js +23 -23
- package/hooks/scripts/context-save.js +33 -33
- package/hooks/scripts/gemini-ui-gen.js +281 -281
- package/hooks/scripts/generate-brand-assets.js +474 -474
- package/hooks/scripts/hud-multiline.js +262 -262
- package/hooks/scripts/hud-status.js +291 -291
- package/hooks/scripts/keyword-detector.js +214 -214
- package/hooks/scripts/llm-orchestrate.js +171 -171
- package/hooks/scripts/post-edit.js +97 -97
- package/hooks/scripts/post-tool-verify.js +210 -210
- package/hooks/scripts/pre-tool-guard.js +125 -125
- package/hooks/scripts/recall.js +22 -22
- package/hooks/scripts/session-start.js +30 -30
- package/hooks/scripts/skill-injector.js +191 -191
- package/hooks/scripts/utils.js +97 -97
- package/languages/csharp-unity.md +515 -515
- package/languages/gdscript-godot.md +470 -470
- package/languages/ruby-rails.md +489 -489
- package/languages/typescript-angular.md +433 -433
- package/languages/typescript-astro.md +416 -416
- package/languages/typescript-electron.md +406 -406
- package/languages/typescript-nestjs.md +524 -524
- package/languages/typescript-svelte.md +407 -407
- package/languages/typescript-tauri.md +365 -365
- package/package.json +84 -84
- package/skills/brand-assets.md +141 -141
- package/skills/commerce-patterns.md +361 -361
- package/skills/context7-usage.md +102 -102
- package/skills/e2e-commerce.md +304 -304
- package/skills/frontend-design.md +92 -92
- package/skills/git-worktree.md +181 -181
- package/skills/parallel-research.md +77 -77
- package/skills/priority-todos.md +239 -239
- package/skills/seo-checklist.md +244 -244
- package/skills/tool-fallback.md +190 -190
- package/skills/vibe-capabilities.md +161 -161
- package/vibe/constitution.md +227 -227
- package/vibe/rules/core/communication-guide.md +98 -98
- package/vibe/rules/core/development-philosophy.md +52 -52
- package/vibe/rules/core/quick-start.md +102 -102
- package/vibe/rules/quality/bdd-contract-testing.md +393 -393
- package/vibe/rules/quality/checklist.md +276 -276
- package/vibe/rules/quality/testing-strategy.md +440 -440
- package/vibe/rules/standards/anti-patterns.md +541 -541
- package/vibe/rules/standards/code-structure.md +291 -291
- package/vibe/rules/standards/complexity-metrics.md +313 -313
- package/vibe/rules/standards/naming-conventions.md +198 -198
- package/vibe/setup.sh +31 -31
- package/vibe/templates/constitution-template.md +252 -252
- package/vibe/templates/contract-backend-template.md +526 -526
- package/vibe/templates/contract-frontend-template.md +599 -599
- package/vibe/templates/feature-template.md +96 -96
- package/vibe/templates/spec-template.md +221 -221
- package/dist/cli/mcp.d.ts +0 -49
- package/dist/cli/mcp.d.ts.map +0 -1
- package/dist/cli/mcp.js +0 -169
- package/dist/cli/mcp.js.map +0 -1
- package/dist/lib/gemini-mcp.d.ts +0 -10
- package/dist/lib/gemini-mcp.d.ts.map +0 -1
- package/dist/lib/gemini-mcp.js +0 -353
- package/dist/lib/gemini-mcp.js.map +0 -1
- package/dist/lib/gpt-mcp.d.ts +0 -10
- package/dist/lib/gpt-mcp.d.ts.map +0 -1
- package/dist/lib/gpt-mcp.js +0 -352
- package/dist/lib/gpt-mcp.js.map +0 -1
- package/dist/tools/analytics/getUsageAnalytics.d.ts +0 -10
- package/dist/tools/analytics/getUsageAnalytics.d.ts.map +0 -1
- package/dist/tools/analytics/getUsageAnalytics.js +0 -246
- package/dist/tools/analytics/getUsageAnalytics.js.map +0 -1
- package/dist/tools/analytics/index.d.ts +0 -5
- package/dist/tools/analytics/index.d.ts.map +0 -1
- package/dist/tools/analytics/index.js +0 -5
- package/dist/tools/analytics/index.js.map +0 -1
- package/dist/tools/convention/getCodingGuide.d.ts +0 -7
- package/dist/tools/convention/getCodingGuide.d.ts.map +0 -1
- package/dist/tools/convention/getCodingGuide.js +0 -69
- package/dist/tools/convention/getCodingGuide.js.map +0 -1
- package/dist/tools/planning/analyzeRequirements.d.ts +0 -9
- package/dist/tools/planning/analyzeRequirements.d.ts.map +0 -1
- package/dist/tools/planning/analyzeRequirements.js +0 -171
- package/dist/tools/planning/analyzeRequirements.js.map +0 -1
- package/dist/tools/planning/createUserStories.d.ts +0 -9
- package/dist/tools/planning/createUserStories.d.ts.map +0 -1
- package/dist/tools/planning/createUserStories.js +0 -124
- package/dist/tools/planning/createUserStories.js.map +0 -1
- package/dist/tools/planning/featureRoadmap.d.ts +0 -10
- package/dist/tools/planning/featureRoadmap.d.ts.map +0 -1
- package/dist/tools/planning/featureRoadmap.js +0 -207
- package/dist/tools/planning/featureRoadmap.js.map +0 -1
- package/dist/tools/planning/generatePrd.d.ts +0 -11
- package/dist/tools/planning/generatePrd.d.ts.map +0 -1
- package/dist/tools/planning/generatePrd.js +0 -161
- package/dist/tools/planning/generatePrd.js.map +0 -1
- package/dist/tools/planning/index.d.ts +0 -8
- package/dist/tools/planning/index.d.ts.map +0 -1
- package/dist/tools/planning/index.js +0 -8
- package/dist/tools/planning/index.js.map +0 -1
- package/dist/tools/prompt/analyzePrompt.d.ts +0 -7
- package/dist/tools/prompt/analyzePrompt.d.ts.map +0 -1
- package/dist/tools/prompt/analyzePrompt.js +0 -150
- package/dist/tools/prompt/analyzePrompt.js.map +0 -1
- package/dist/tools/prompt/enhancePrompt.d.ts +0 -8
- package/dist/tools/prompt/enhancePrompt.d.ts.map +0 -1
- package/dist/tools/prompt/enhancePrompt.js +0 -110
- package/dist/tools/prompt/enhancePrompt.js.map +0 -1
- package/dist/tools/prompt/enhancePromptGemini.d.ts +0 -8
- package/dist/tools/prompt/enhancePromptGemini.d.ts.map +0 -1
- package/dist/tools/prompt/enhancePromptGemini.js +0 -332
- package/dist/tools/prompt/enhancePromptGemini.js.map +0 -1
- package/dist/tools/prompt/index.d.ts +0 -7
- package/dist/tools/prompt/index.d.ts.map +0 -1
- package/dist/tools/prompt/index.js +0 -7
- package/dist/tools/prompt/index.js.map +0 -1
- package/dist/tools/reasoning/applyReasoningFramework.d.ts +0 -8
- package/dist/tools/reasoning/applyReasoningFramework.d.ts.map +0 -1
- package/dist/tools/reasoning/applyReasoningFramework.js +0 -266
- package/dist/tools/reasoning/applyReasoningFramework.js.map +0 -1
- package/dist/tools/reasoning/index.d.ts +0 -5
- package/dist/tools/reasoning/index.d.ts.map +0 -1
- package/dist/tools/reasoning/index.js +0 -5
- package/dist/tools/reasoning/index.js.map +0 -1
- package/dist/tools/thinking/analyzeProblem.d.ts +0 -7
- package/dist/tools/thinking/analyzeProblem.d.ts.map +0 -1
- package/dist/tools/thinking/analyzeProblem.js +0 -55
- package/dist/tools/thinking/analyzeProblem.js.map +0 -1
- package/dist/tools/thinking/breakDownProblem.d.ts +0 -8
- package/dist/tools/thinking/breakDownProblem.d.ts.map +0 -1
- package/dist/tools/thinking/breakDownProblem.js +0 -145
- package/dist/tools/thinking/breakDownProblem.js.map +0 -1
- package/dist/tools/thinking/createThinkingChain.d.ts +0 -7
- package/dist/tools/thinking/createThinkingChain.d.ts.map +0 -1
- package/dist/tools/thinking/createThinkingChain.js +0 -44
- package/dist/tools/thinking/createThinkingChain.js.map +0 -1
- package/dist/tools/thinking/formatAsPlan.d.ts +0 -9
- package/dist/tools/thinking/formatAsPlan.d.ts.map +0 -1
- package/dist/tools/thinking/formatAsPlan.js +0 -78
- package/dist/tools/thinking/formatAsPlan.js.map +0 -1
- package/dist/tools/thinking/index.d.ts +0 -10
- package/dist/tools/thinking/index.d.ts.map +0 -1
- package/dist/tools/thinking/index.js +0 -10
- package/dist/tools/thinking/index.js.map +0 -1
- package/dist/tools/thinking/stepByStepAnalysis.d.ts +0 -8
- package/dist/tools/thinking/stepByStepAnalysis.d.ts.map +0 -1
- package/dist/tools/thinking/stepByStepAnalysis.js +0 -63
- package/dist/tools/thinking/stepByStepAnalysis.js.map +0 -1
- package/dist/tools/thinking/thinkAloudProcess.d.ts +0 -8
- package/dist/tools/thinking/thinkAloudProcess.d.ts.map +0 -1
- package/dist/tools/thinking/thinkAloudProcess.js +0 -80
- package/dist/tools/thinking/thinkAloudProcess.js.map +0 -1
|
@@ -4,10 +4,10 @@ import { validateCodeQuality } from './validateCodeQuality.js';
|
|
|
4
4
|
describe('validateCodeQuality', () => {
|
|
5
5
|
describe('code validation', () => {
|
|
6
6
|
it('should validate simple clean code', async () => {
|
|
7
|
-
const code = `
|
|
8
|
-
function add(a: number, b: number): number {
|
|
9
|
-
return a + b;
|
|
10
|
-
}
|
|
7
|
+
const code = `
|
|
8
|
+
function add(a: number, b: number): number {
|
|
9
|
+
return a + b;
|
|
10
|
+
}
|
|
11
11
|
`;
|
|
12
12
|
const result = await validateCodeQuality({ code });
|
|
13
13
|
expect(result.content[0].type).toBe('text');
|
|
@@ -15,56 +15,56 @@ function add(a: number, b: number): number {
|
|
|
15
15
|
expect(result.content[0].text).toContain('Grade');
|
|
16
16
|
});
|
|
17
17
|
it('should detect high nesting depth', async () => {
|
|
18
|
-
const code = `
|
|
19
|
-
function nested() {
|
|
20
|
-
if (true) {
|
|
21
|
-
if (true) {
|
|
22
|
-
if (true) {
|
|
23
|
-
if (true) {
|
|
24
|
-
console.log('deep');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
18
|
+
const code = `
|
|
19
|
+
function nested() {
|
|
20
|
+
if (true) {
|
|
21
|
+
if (true) {
|
|
22
|
+
if (true) {
|
|
23
|
+
if (true) {
|
|
24
|
+
console.log('deep');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
30
|
`;
|
|
31
31
|
const result = await validateCodeQuality({ code });
|
|
32
32
|
expect(result.content[0].text).toContain('Nesting');
|
|
33
33
|
});
|
|
34
34
|
it('should detect any type usage', async () => {
|
|
35
|
-
const code = `
|
|
36
|
-
function process(data: any): any {
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
35
|
+
const code = `
|
|
36
|
+
function process(data: any): any {
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
39
|
`;
|
|
40
40
|
const result = await validateCodeQuality({ code });
|
|
41
41
|
expect(result.content[0].text).toContain('type');
|
|
42
42
|
});
|
|
43
43
|
it('should detect loose equality', async () => {
|
|
44
|
-
const code = `
|
|
45
|
-
function compare(a, b) {
|
|
46
|
-
return a == b;
|
|
47
|
-
}
|
|
44
|
+
const code = `
|
|
45
|
+
function compare(a, b) {
|
|
46
|
+
return a == b;
|
|
47
|
+
}
|
|
48
48
|
`;
|
|
49
49
|
const result = await validateCodeQuality({ code });
|
|
50
50
|
expect(result.content[0].text).toContain('Issues');
|
|
51
51
|
});
|
|
52
52
|
it('should detect var usage', async () => {
|
|
53
|
-
const code = `
|
|
54
|
-
function oldStyle() {
|
|
55
|
-
var x = 1;
|
|
56
|
-
var y = 2;
|
|
57
|
-
return x + y;
|
|
58
|
-
}
|
|
53
|
+
const code = `
|
|
54
|
+
function oldStyle() {
|
|
55
|
+
var x = 1;
|
|
56
|
+
var y = 2;
|
|
57
|
+
return x + y;
|
|
58
|
+
}
|
|
59
59
|
`;
|
|
60
60
|
const result = await validateCodeQuality({ code });
|
|
61
61
|
expect(result.content[0].text).toContain('Issues');
|
|
62
62
|
});
|
|
63
63
|
it('should detect magic numbers', async () => {
|
|
64
|
-
const code = `
|
|
65
|
-
function calculate(value) {
|
|
66
|
-
return value * 123 + 456;
|
|
67
|
-
}
|
|
64
|
+
const code = `
|
|
65
|
+
function calculate(value) {
|
|
66
|
+
return value * 123 + 456;
|
|
67
|
+
}
|
|
68
68
|
`;
|
|
69
69
|
const result = await validateCodeQuality({ code });
|
|
70
70
|
expect(result.content[0].text).toContain('Issues');
|
|
@@ -72,26 +72,26 @@ function calculate(value) {
|
|
|
72
72
|
});
|
|
73
73
|
describe('async code validation', () => {
|
|
74
74
|
it('should warn about missing error handling in async', async () => {
|
|
75
|
-
const code = `
|
|
76
|
-
async function fetchData() {
|
|
77
|
-
const response = await fetch('/api');
|
|
78
|
-
return response.json();
|
|
79
|
-
}
|
|
75
|
+
const code = `
|
|
76
|
+
async function fetchData() {
|
|
77
|
+
const response = await fetch('/api');
|
|
78
|
+
return response.json();
|
|
79
|
+
}
|
|
80
80
|
`;
|
|
81
81
|
const result = await validateCodeQuality({ code });
|
|
82
82
|
expect(result.content[0].text).toContain('Issues');
|
|
83
83
|
});
|
|
84
84
|
it('should not warn when error handling exists', async () => {
|
|
85
|
-
const code = `
|
|
86
|
-
async function fetchData() {
|
|
87
|
-
try {
|
|
88
|
-
const response = await fetch('/api');
|
|
89
|
-
return response.json();
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error(error);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
85
|
+
const code = `
|
|
86
|
+
async function fetchData() {
|
|
87
|
+
try {
|
|
88
|
+
const response = await fetch('/api');
|
|
89
|
+
return response.json();
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
95
|
`;
|
|
96
96
|
const result = await validateCodeQuality({ code });
|
|
97
97
|
// Should have fewer issues or no error handling issue
|
|
@@ -100,27 +100,27 @@ async function fetchData() {
|
|
|
100
100
|
});
|
|
101
101
|
describe('React component validation', () => {
|
|
102
102
|
it('should validate React component with type', async () => {
|
|
103
|
-
const code = `
|
|
104
|
-
import React from 'react';
|
|
105
|
-
|
|
106
|
-
function MyComponent({ name }) {
|
|
107
|
-
return <div>Hello, {name}!</div>;
|
|
108
|
-
}
|
|
103
|
+
const code = `
|
|
104
|
+
import React from 'react';
|
|
105
|
+
|
|
106
|
+
function MyComponent({ name }) {
|
|
107
|
+
return <div>Hello, {name}!</div>;
|
|
108
|
+
}
|
|
109
109
|
`;
|
|
110
110
|
const result = await validateCodeQuality({ code, type: 'component' });
|
|
111
111
|
expect(result.content[0].text).toContain('Type: component');
|
|
112
112
|
});
|
|
113
113
|
it('should suggest memo for React components', async () => {
|
|
114
|
-
const code = `
|
|
115
|
-
import React from 'react';
|
|
116
|
-
|
|
117
|
-
function ExpensiveComponent({ data }) {
|
|
118
|
-
return (
|
|
119
|
-
<div>
|
|
120
|
-
{data.map(item => <span key={item.id}>{item.name}</span>)}
|
|
121
|
-
</div>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
114
|
+
const code = `
|
|
115
|
+
import React from 'react';
|
|
116
|
+
|
|
117
|
+
function ExpensiveComponent({ data }) {
|
|
118
|
+
return (
|
|
119
|
+
<div>
|
|
120
|
+
{data.map(item => <span key={item.id}>{item.name}</span>)}
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
124
|
`;
|
|
125
125
|
const result = await validateCodeQuality({ code, type: 'component' });
|
|
126
126
|
// Should mention performance optimization
|
|
@@ -144,27 +144,27 @@ function ExpensiveComponent({ data }) {
|
|
|
144
144
|
});
|
|
145
145
|
describe('grading system', () => {
|
|
146
146
|
it('should give A grade for excellent code', async () => {
|
|
147
|
-
const code = `
|
|
148
|
-
const add = (a: number, b: number): number => a + b;
|
|
147
|
+
const code = `
|
|
148
|
+
const add = (a: number, b: number): number => a + b;
|
|
149
149
|
`;
|
|
150
150
|
const result = await validateCodeQuality({ code });
|
|
151
151
|
expect(result.content[0].text).toContain('Grade: A');
|
|
152
152
|
});
|
|
153
153
|
it('should give lower grade for problematic code', async () => {
|
|
154
|
-
const code = `
|
|
155
|
-
function badCode(data: any) {
|
|
156
|
-
var result;
|
|
157
|
-
if (data == null) {
|
|
158
|
-
if (true) {
|
|
159
|
-
if (true) {
|
|
160
|
-
if (true) {
|
|
161
|
-
result = data * 123456;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
154
|
+
const code = `
|
|
155
|
+
function badCode(data: any) {
|
|
156
|
+
var result;
|
|
157
|
+
if (data == null) {
|
|
158
|
+
if (true) {
|
|
159
|
+
if (true) {
|
|
160
|
+
if (true) {
|
|
161
|
+
result = data * 123456;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
168
|
`;
|
|
169
169
|
const result = await validateCodeQuality({ code });
|
|
170
170
|
// Should not be grade A
|
|
@@ -173,10 +173,10 @@ function badCode(data: any) {
|
|
|
173
173
|
});
|
|
174
174
|
describe('strict mode', () => {
|
|
175
175
|
it('should accept strict flag', async () => {
|
|
176
|
-
const code = `
|
|
177
|
-
function test() {
|
|
178
|
-
return 1;
|
|
179
|
-
}
|
|
176
|
+
const code = `
|
|
177
|
+
function test() {
|
|
178
|
+
return 1;
|
|
179
|
+
}
|
|
180
180
|
`;
|
|
181
181
|
const result = await validateCodeQuality({ code, strict: true });
|
|
182
182
|
expect(result.content[0].text).toContain('Score');
|
|
@@ -184,23 +184,23 @@ function test() {
|
|
|
184
184
|
});
|
|
185
185
|
describe('metrics option', () => {
|
|
186
186
|
it('should accept complexity metrics', async () => {
|
|
187
|
-
const code = `
|
|
188
|
-
function test() {
|
|
189
|
-
return 1;
|
|
190
|
-
}
|
|
187
|
+
const code = `
|
|
188
|
+
function test() {
|
|
189
|
+
return 1;
|
|
190
|
+
}
|
|
191
191
|
`;
|
|
192
192
|
const result = await validateCodeQuality({ code, metrics: 'complexity' });
|
|
193
193
|
expect(result.content[0].text).toContain('Complexity');
|
|
194
194
|
});
|
|
195
195
|
it('should accept all metrics', async () => {
|
|
196
|
-
const code = `
|
|
197
|
-
function test() {
|
|
198
|
-
if (true) {
|
|
199
|
-
for (let i = 0; i < 10; i++) {
|
|
200
|
-
console.log(i);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
196
|
+
const code = `
|
|
197
|
+
function test() {
|
|
198
|
+
if (true) {
|
|
199
|
+
for (let i = 0; i < 10; i++) {
|
|
200
|
+
console.log(i);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
204
|
`;
|
|
205
205
|
const result = await validateCodeQuality({ code, metrics: 'all' });
|
|
206
206
|
expect(result.content[0].text).toContain('Score');
|
|
@@ -208,18 +208,18 @@ function test() {
|
|
|
208
208
|
});
|
|
209
209
|
describe('deductions', () => {
|
|
210
210
|
it('should show deduction details', async () => {
|
|
211
|
-
const code = `
|
|
212
|
-
async function process(data: any) {
|
|
213
|
-
var x = data == null ? 0 : data;
|
|
214
|
-
return x * 12345;
|
|
215
|
-
}
|
|
211
|
+
const code = `
|
|
212
|
+
async function process(data: any) {
|
|
213
|
+
var x = data == null ? 0 : data;
|
|
214
|
+
return x * 12345;
|
|
215
|
+
}
|
|
216
216
|
`;
|
|
217
217
|
const result = await validateCodeQuality({ code });
|
|
218
218
|
expect(result.content[0].text).toContain('Deductions');
|
|
219
219
|
});
|
|
220
220
|
it('should calculate score correctly', async () => {
|
|
221
|
-
const code = `
|
|
222
|
-
const clean = (x: number): number => x + 1;
|
|
221
|
+
const code = `
|
|
222
|
+
const clean = (x: number): number => x + 1;
|
|
223
223
|
`;
|
|
224
224
|
const result = await validateCodeQuality({ code });
|
|
225
225
|
// Clean code should have high score (90+)
|