@stackguide/mcp-server 3.0.0 → 3.2.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/dist/config/types.d.ts +51 -4
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/services/astAnalyzer.d.ts +21 -0
- package/dist/services/astAnalyzer.d.ts.map +1 -0
- package/dist/services/astAnalyzer.js +593 -0
- package/dist/services/astAnalyzer.js.map +1 -0
- package/dist/services/codeAnalyzer.d.ts +54 -14
- package/dist/services/codeAnalyzer.d.ts.map +1 -1
- package/dist/services/codeAnalyzer.js +209 -37
- package/dist/services/codeAnalyzer.js.map +1 -1
- package/dist/services/parsers/baseParser.d.ts +44 -0
- package/dist/services/parsers/baseParser.d.ts.map +1 -0
- package/dist/services/parsers/baseParser.js +177 -0
- package/dist/services/parsers/baseParser.js.map +1 -0
- package/dist/services/parsers/goParser.d.ts +28 -0
- package/dist/services/parsers/goParser.d.ts.map +1 -0
- package/dist/services/parsers/goParser.js +590 -0
- package/dist/services/parsers/goParser.js.map +1 -0
- package/dist/services/parsers/index.d.ts +62 -0
- package/dist/services/parsers/index.d.ts.map +1 -0
- package/dist/services/parsers/index.js +121 -0
- package/dist/services/parsers/index.js.map +1 -0
- package/dist/services/parsers/pythonParser.d.ts +28 -0
- package/dist/services/parsers/pythonParser.d.ts.map +1 -0
- package/dist/services/parsers/pythonParser.js +663 -0
- package/dist/services/parsers/pythonParser.js.map +1 -0
- package/dist/services/parsers/rustParser.d.ts +28 -0
- package/dist/services/parsers/rustParser.d.ts.map +1 -0
- package/dist/services/parsers/rustParser.js +654 -0
- package/dist/services/parsers/rustParser.js.map +1 -0
- package/dist/services/parsers/types.d.ts +241 -0
- package/dist/services/parsers/types.d.ts.map +1 -0
- package/dist/services/parsers/types.js +47 -0
- package/dist/services/parsers/types.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Language Parser
|
|
3
|
+
* Semantic analysis for Go code
|
|
4
|
+
* @version 3.2.0
|
|
5
|
+
*/
|
|
6
|
+
import { BaseLanguageParser } from './baseParser.js';
|
|
7
|
+
/**
|
|
8
|
+
* Go-specific parser with semantic rules
|
|
9
|
+
*/
|
|
10
|
+
export class GoParser extends BaseLanguageParser {
|
|
11
|
+
language = 'go';
|
|
12
|
+
extensions = ['.go'];
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.rules = GO_RULES;
|
|
16
|
+
}
|
|
17
|
+
parse(code, filePath) {
|
|
18
|
+
const startTime = Date.now();
|
|
19
|
+
const symbols = [];
|
|
20
|
+
const imports = [];
|
|
21
|
+
const functions = [];
|
|
22
|
+
const classes = []; // Go uses structs
|
|
23
|
+
const variables = [];
|
|
24
|
+
// Extract components
|
|
25
|
+
imports.push(...this.extractImports(code));
|
|
26
|
+
functions.push(...this.extractFunctions(code));
|
|
27
|
+
classes.push(...this.extractStructs(code));
|
|
28
|
+
variables.push(...this.extractVariables(code));
|
|
29
|
+
// Build symbol list
|
|
30
|
+
for (const imp of imports) {
|
|
31
|
+
symbols.push({
|
|
32
|
+
type: 'import',
|
|
33
|
+
name: imp.module,
|
|
34
|
+
line: imp.line,
|
|
35
|
+
column: 1
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
for (const func of functions) {
|
|
39
|
+
symbols.push({
|
|
40
|
+
type: 'function',
|
|
41
|
+
name: func.name,
|
|
42
|
+
line: func.line,
|
|
43
|
+
column: 1
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
for (const cls of classes) {
|
|
47
|
+
symbols.push({
|
|
48
|
+
type: 'struct',
|
|
49
|
+
name: cls.name,
|
|
50
|
+
line: cls.line,
|
|
51
|
+
column: 1
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// Extract interfaces
|
|
55
|
+
const interfaceMatches = code.matchAll(/type\s+(\w+)\s+interface\s*{/g);
|
|
56
|
+
for (const match of interfaceMatches) {
|
|
57
|
+
const beforeMatch = code.substring(0, match.index);
|
|
58
|
+
const line = beforeMatch.split('\n').length;
|
|
59
|
+
symbols.push({
|
|
60
|
+
type: 'interface',
|
|
61
|
+
name: match[1],
|
|
62
|
+
line,
|
|
63
|
+
column: 1
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const comments = this.extractComments(code, '//', '/*', '*/');
|
|
67
|
+
return {
|
|
68
|
+
language: 'go',
|
|
69
|
+
filePath,
|
|
70
|
+
symbols,
|
|
71
|
+
imports,
|
|
72
|
+
functions,
|
|
73
|
+
classes,
|
|
74
|
+
variables,
|
|
75
|
+
comments,
|
|
76
|
+
errors: [],
|
|
77
|
+
parseTime: Date.now() - startTime
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
extractImports(code) {
|
|
81
|
+
const imports = [];
|
|
82
|
+
// Single import: import "package"
|
|
83
|
+
const singleImportRegex = /import\s+"([^"]+)"/g;
|
|
84
|
+
let match;
|
|
85
|
+
while ((match = singleImportRegex.exec(code)) !== null) {
|
|
86
|
+
const beforeMatch = code.substring(0, match.index);
|
|
87
|
+
const line = beforeMatch.split('\n').length;
|
|
88
|
+
imports.push({
|
|
89
|
+
module: match[1],
|
|
90
|
+
items: [],
|
|
91
|
+
line
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// Import block: import ( ... )
|
|
95
|
+
const importBlockRegex = /import\s*\(\s*([\s\S]*?)\s*\)/g;
|
|
96
|
+
while ((match = importBlockRegex.exec(code)) !== null) {
|
|
97
|
+
const blockContent = match[1];
|
|
98
|
+
const blockStart = code.substring(0, match.index).split('\n').length;
|
|
99
|
+
const lines = blockContent.split('\n');
|
|
100
|
+
for (let i = 0; i < lines.length; i++) {
|
|
101
|
+
const line = lines[i].trim();
|
|
102
|
+
if (!line)
|
|
103
|
+
continue;
|
|
104
|
+
// alias "package" or just "package"
|
|
105
|
+
const pkgMatch = line.match(/^(?:(\w+)\s+)?"([^"]+)"$/);
|
|
106
|
+
if (pkgMatch) {
|
|
107
|
+
imports.push({
|
|
108
|
+
module: pkgMatch[2],
|
|
109
|
+
items: [],
|
|
110
|
+
alias: pkgMatch[1],
|
|
111
|
+
line: blockStart + i
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return imports;
|
|
117
|
+
}
|
|
118
|
+
extractFunctions(code) {
|
|
119
|
+
const functions = [];
|
|
120
|
+
const lines = code.split('\n');
|
|
121
|
+
// func name(params) returns { or func (receiver) name(params) returns {
|
|
122
|
+
const funcRegex = /func\s+(?:\(\s*\w+\s+\*?[\w.]+\s*\)\s+)?(\w+)\s*\(([^)]*)\)(?:\s*\(([^)]*)\)|\s*(\w+(?:\.\w+)?))?\s*{/g;
|
|
123
|
+
let match;
|
|
124
|
+
while ((match = funcRegex.exec(code)) !== null) {
|
|
125
|
+
const funcName = match[1];
|
|
126
|
+
const paramsStr = match[2] || '';
|
|
127
|
+
const returnTuple = match[3];
|
|
128
|
+
const returnType = match[4] || returnTuple;
|
|
129
|
+
const beforeMatch = code.substring(0, match.index);
|
|
130
|
+
const lineNum = beforeMatch.split('\n').length;
|
|
131
|
+
// Find function end by brace matching
|
|
132
|
+
let braceCount = 1;
|
|
133
|
+
let endLine = lineNum;
|
|
134
|
+
const funcStart = match.index + match[0].length;
|
|
135
|
+
for (let i = funcStart; i < code.length && braceCount > 0; i++) {
|
|
136
|
+
if (code[i] === '{')
|
|
137
|
+
braceCount++;
|
|
138
|
+
if (code[i] === '}')
|
|
139
|
+
braceCount--;
|
|
140
|
+
if (braceCount === 0) {
|
|
141
|
+
endLine = code.substring(0, i).split('\n').length;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Parse parameters
|
|
145
|
+
const parameters = this.parseGoParams(paramsStr);
|
|
146
|
+
// Calculate complexity
|
|
147
|
+
const bodyCode = lines.slice(lineNum, endLine).join('\n');
|
|
148
|
+
const complexity = this.calculateComplexity(bodyCode);
|
|
149
|
+
// Check if it's exported (starts with uppercase)
|
|
150
|
+
const isExported = funcName[0] === funcName[0].toUpperCase();
|
|
151
|
+
functions.push({
|
|
152
|
+
name: funcName,
|
|
153
|
+
line: lineNum,
|
|
154
|
+
endLine,
|
|
155
|
+
parameters,
|
|
156
|
+
returnType,
|
|
157
|
+
isExported,
|
|
158
|
+
complexity,
|
|
159
|
+
bodyLines: endLine - lineNum
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return functions;
|
|
163
|
+
}
|
|
164
|
+
parseGoParams(paramsStr) {
|
|
165
|
+
const params = [];
|
|
166
|
+
if (!paramsStr.trim())
|
|
167
|
+
return params;
|
|
168
|
+
// Split by comma, handling func types
|
|
169
|
+
const paramList = this.splitGoParams(paramsStr);
|
|
170
|
+
for (const param of paramList) {
|
|
171
|
+
const trimmed = param.trim();
|
|
172
|
+
if (!trimmed)
|
|
173
|
+
continue;
|
|
174
|
+
// name type or name1, name2 type
|
|
175
|
+
const parts = trimmed.split(/\s+/);
|
|
176
|
+
if (parts.length >= 2) {
|
|
177
|
+
const type = parts[parts.length - 1];
|
|
178
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
179
|
+
const name = parts[i].replace(',', '');
|
|
180
|
+
params.push({
|
|
181
|
+
name,
|
|
182
|
+
type,
|
|
183
|
+
isRest: type.startsWith('...')
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else if (parts.length === 1 && parts[0].includes(' ')) {
|
|
188
|
+
// Single param with type
|
|
189
|
+
const [name, type] = parts[0].split(' ');
|
|
190
|
+
params.push({ name, type });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return params;
|
|
194
|
+
}
|
|
195
|
+
splitGoParams(paramsStr) {
|
|
196
|
+
const params = [];
|
|
197
|
+
let current = '';
|
|
198
|
+
let depth = 0;
|
|
199
|
+
for (const char of paramsStr) {
|
|
200
|
+
if (char === '(' || char === '[' || char === '{')
|
|
201
|
+
depth++;
|
|
202
|
+
if (char === ')' || char === ']' || char === '}')
|
|
203
|
+
depth--;
|
|
204
|
+
if (char === ',' && depth === 0) {
|
|
205
|
+
params.push(current);
|
|
206
|
+
current = '';
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
current += char;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (current)
|
|
213
|
+
params.push(current);
|
|
214
|
+
return params;
|
|
215
|
+
}
|
|
216
|
+
extractStructs(code) {
|
|
217
|
+
const structs = [];
|
|
218
|
+
const lines = code.split('\n');
|
|
219
|
+
// type Name struct { ... }
|
|
220
|
+
const structRegex = /type\s+(\w+)\s+struct\s*{([^}]*)}/g;
|
|
221
|
+
let match;
|
|
222
|
+
while ((match = structRegex.exec(code)) !== null) {
|
|
223
|
+
const structName = match[1];
|
|
224
|
+
const bodyContent = match[2];
|
|
225
|
+
const beforeMatch = code.substring(0, match.index);
|
|
226
|
+
const lineNum = beforeMatch.split('\n').length;
|
|
227
|
+
const endLine = lineNum + bodyContent.split('\n').length;
|
|
228
|
+
// Parse fields
|
|
229
|
+
const members = [];
|
|
230
|
+
const fieldLines = bodyContent.split('\n');
|
|
231
|
+
for (let i = 0; i < fieldLines.length; i++) {
|
|
232
|
+
const fieldLine = fieldLines[i].trim();
|
|
233
|
+
if (!fieldLine || fieldLine.startsWith('//'))
|
|
234
|
+
continue;
|
|
235
|
+
// FieldName Type `tag`
|
|
236
|
+
const fieldMatch = fieldLine.match(/^(\w+)\s+([\w.*\[\]]+)/);
|
|
237
|
+
if (fieldMatch) {
|
|
238
|
+
const fieldName = fieldMatch[1];
|
|
239
|
+
members.push({
|
|
240
|
+
name: fieldName,
|
|
241
|
+
type: 'field',
|
|
242
|
+
dataType: fieldMatch[2],
|
|
243
|
+
visibility: fieldName[0] === fieldName[0].toUpperCase() ? 'public' : 'private',
|
|
244
|
+
line: lineNum + i + 1
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
structs.push({
|
|
249
|
+
name: structName,
|
|
250
|
+
line: lineNum,
|
|
251
|
+
endLine,
|
|
252
|
+
members,
|
|
253
|
+
isExported: structName[0] === structName[0].toUpperCase()
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return structs;
|
|
257
|
+
}
|
|
258
|
+
extractVariables(code) {
|
|
259
|
+
const variables = [];
|
|
260
|
+
const lines = code.split('\n');
|
|
261
|
+
// Package-level: var name Type = value or const name = value
|
|
262
|
+
for (let i = 0; i < lines.length; i++) {
|
|
263
|
+
const line = lines[i].trim();
|
|
264
|
+
// const or var declaration
|
|
265
|
+
const varMatch = line.match(/^(const|var)\s+(\w+)(?:\s+(\w+))?\s*=\s*(.+)$/);
|
|
266
|
+
if (varMatch) {
|
|
267
|
+
variables.push({
|
|
268
|
+
name: varMatch[2],
|
|
269
|
+
line: i + 1,
|
|
270
|
+
type: varMatch[3],
|
|
271
|
+
isConst: varMatch[1] === 'const',
|
|
272
|
+
scope: 'module',
|
|
273
|
+
value: varMatch[4],
|
|
274
|
+
isExported: varMatch[2][0] === varMatch[2][0].toUpperCase()
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return variables;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Go-specific semantic rules
|
|
283
|
+
*/
|
|
284
|
+
const GO_RULES = [
|
|
285
|
+
{
|
|
286
|
+
id: 'GO001',
|
|
287
|
+
name: 'unchecked-error',
|
|
288
|
+
description: 'Error return value should be checked',
|
|
289
|
+
language: 'go',
|
|
290
|
+
severity: 'error',
|
|
291
|
+
category: 'error-handling',
|
|
292
|
+
enabled: true,
|
|
293
|
+
priority: 95,
|
|
294
|
+
check: (ctx) => {
|
|
295
|
+
// Look for function calls that return error but discard it
|
|
296
|
+
const matches = ctx.findPatternMatches(/\w+\s*\(\s*[^)]*\s*\)\s*$/m);
|
|
297
|
+
// Check for common patterns that ignore errors
|
|
298
|
+
const ignorePatterns = ctx.findPatternMatches(/[^,]\s*:?=\s*\w+\([^)]*\)(?!\s*;\s*if)/);
|
|
299
|
+
// More specific: look for _ = to ignore error
|
|
300
|
+
const discardError = ctx.findPatternMatches(/_\s*=\s*\w+\([^)]*\)/);
|
|
301
|
+
if (discardError.length > 0) {
|
|
302
|
+
return {
|
|
303
|
+
hasIssue: true,
|
|
304
|
+
message: 'Error value explicitly discarded',
|
|
305
|
+
line: discardError[0].line,
|
|
306
|
+
suggestion: 'Handle the error instead of discarding it'
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
id: 'GO002',
|
|
314
|
+
name: 'missing-defer-close',
|
|
315
|
+
description: 'Opened resource should have defer Close()',
|
|
316
|
+
language: 'go',
|
|
317
|
+
severity: 'warning',
|
|
318
|
+
category: 'resource-management',
|
|
319
|
+
enabled: true,
|
|
320
|
+
priority: 85,
|
|
321
|
+
check: (ctx) => {
|
|
322
|
+
// Look for Open/Create calls
|
|
323
|
+
const openCalls = ctx.findPatternMatches(/os\.(Open|Create)\s*\(/);
|
|
324
|
+
const httpBodies = ctx.findPatternMatches(/\.Body\b/);
|
|
325
|
+
// Check for corresponding defer close
|
|
326
|
+
const deferClose = ctx.findPatternMatches(/defer\s+\w+\.Close\(\)/);
|
|
327
|
+
if ((openCalls.length > 0 || httpBodies.length > 0) && deferClose.length === 0) {
|
|
328
|
+
const line = openCalls[0]?.line || httpBodies[0]?.line;
|
|
329
|
+
return {
|
|
330
|
+
hasIssue: true,
|
|
331
|
+
message: 'Opened file/resource without defer Close()',
|
|
332
|
+
line,
|
|
333
|
+
suggestion: 'Add defer file.Close() after opening'
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
id: 'GO003',
|
|
341
|
+
name: 'context-first-param',
|
|
342
|
+
description: 'Context should be first parameter',
|
|
343
|
+
language: 'go',
|
|
344
|
+
severity: 'info',
|
|
345
|
+
category: 'best-practices',
|
|
346
|
+
enabled: true,
|
|
347
|
+
priority: 50,
|
|
348
|
+
check: (ctx) => {
|
|
349
|
+
for (const func of ctx.functions) {
|
|
350
|
+
const hasContext = func.parameters.some(p => p.type === 'context.Context' || p.type?.includes('Context'));
|
|
351
|
+
if (hasContext && func.parameters[0]?.type !== 'context.Context') {
|
|
352
|
+
return {
|
|
353
|
+
hasIssue: true,
|
|
354
|
+
message: `Context parameter not first in '${func.name}'`,
|
|
355
|
+
line: func.line,
|
|
356
|
+
suggestion: 'Move context.Context to be the first parameter'
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
id: 'GO004',
|
|
365
|
+
name: 'naked-return',
|
|
366
|
+
description: 'Avoid naked returns in long functions',
|
|
367
|
+
language: 'go',
|
|
368
|
+
severity: 'warning',
|
|
369
|
+
category: 'readability',
|
|
370
|
+
enabled: true,
|
|
371
|
+
priority: 60,
|
|
372
|
+
check: (ctx) => {
|
|
373
|
+
for (const func of ctx.functions) {
|
|
374
|
+
if (func.bodyLines && func.bodyLines > 10) {
|
|
375
|
+
// Check for naked return
|
|
376
|
+
const startLine = func.line;
|
|
377
|
+
const endLine = func.endLine || startLine + 10;
|
|
378
|
+
const funcBody = ctx.getLines(startLine, endLine).join('\n');
|
|
379
|
+
if (/\breturn\s*$/.test(funcBody) && func.returnType) {
|
|
380
|
+
return {
|
|
381
|
+
hasIssue: true,
|
|
382
|
+
message: `Naked return in function '${func.name}' (${func.bodyLines} lines)`,
|
|
383
|
+
line: func.line,
|
|
384
|
+
suggestion: 'Use explicit return values for clarity in longer functions'
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
id: 'GO005',
|
|
394
|
+
name: 'empty-interface',
|
|
395
|
+
description: 'Avoid interface{} (use any or specific types)',
|
|
396
|
+
language: 'go',
|
|
397
|
+
severity: 'info',
|
|
398
|
+
category: 'type-safety',
|
|
399
|
+
enabled: true,
|
|
400
|
+
priority: 50,
|
|
401
|
+
check: (ctx) => {
|
|
402
|
+
const matches = ctx.findPatternMatches(/\binterface\s*\{\s*\}/);
|
|
403
|
+
if (matches.length > 0) {
|
|
404
|
+
return {
|
|
405
|
+
hasIssue: true,
|
|
406
|
+
message: `Found ${matches.length} uses of interface{} - consider using 'any' or specific types`,
|
|
407
|
+
line: matches[0].line,
|
|
408
|
+
suggestion: 'Use type parameters or the any keyword (Go 1.18+)'
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
id: 'GO006',
|
|
416
|
+
name: 'unused-goroutine-result',
|
|
417
|
+
description: 'Goroutine result might be lost',
|
|
418
|
+
language: 'go',
|
|
419
|
+
severity: 'warning',
|
|
420
|
+
category: 'concurrency',
|
|
421
|
+
enabled: true,
|
|
422
|
+
priority: 80,
|
|
423
|
+
check: (ctx) => {
|
|
424
|
+
// Look for go statements
|
|
425
|
+
const goStatements = ctx.findPatternMatches(/\bgo\s+\w+\s*\(/);
|
|
426
|
+
const channels = ctx.findPatternMatches(/\bmake\s*\(\s*chan\b/);
|
|
427
|
+
const waitGroups = ctx.findPatternMatches(/sync\.WaitGroup/);
|
|
428
|
+
if (goStatements.length > 0 && channels.length === 0 && waitGroups.length === 0) {
|
|
429
|
+
return {
|
|
430
|
+
hasIssue: true,
|
|
431
|
+
message: 'Goroutine started without channel or WaitGroup for result',
|
|
432
|
+
line: goStatements[0].line,
|
|
433
|
+
suggestion: 'Use channels or sync.WaitGroup to collect goroutine results'
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
id: 'GO007',
|
|
441
|
+
name: 'race-condition-risk',
|
|
442
|
+
description: 'Potential race condition with shared variable',
|
|
443
|
+
language: 'go',
|
|
444
|
+
severity: 'warning',
|
|
445
|
+
category: 'concurrency',
|
|
446
|
+
enabled: true,
|
|
447
|
+
priority: 85,
|
|
448
|
+
check: (ctx) => {
|
|
449
|
+
// Detect goroutines accessing non-local variables
|
|
450
|
+
const goBlocks = ctx.findPatternMatches(/go\s+func\s*\([^)]*\)\s*{[^}]+}/);
|
|
451
|
+
const mutex = ctx.findPatternMatches(/sync\.(Mutex|RWMutex)/);
|
|
452
|
+
if (goBlocks.length > 1 && mutex.length === 0) {
|
|
453
|
+
return {
|
|
454
|
+
hasIssue: true,
|
|
455
|
+
message: 'Multiple goroutines without mutex protection',
|
|
456
|
+
line: goBlocks[0].line,
|
|
457
|
+
suggestion: 'Consider using sync.Mutex or channels for safe concurrent access'
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
id: 'GO008',
|
|
465
|
+
name: 'init-function',
|
|
466
|
+
description: 'Avoid complex init() functions',
|
|
467
|
+
language: 'go',
|
|
468
|
+
severity: 'info',
|
|
469
|
+
category: 'best-practices',
|
|
470
|
+
enabled: true,
|
|
471
|
+
priority: 40,
|
|
472
|
+
check: (ctx) => {
|
|
473
|
+
for (const func of ctx.functions) {
|
|
474
|
+
if (func.name === 'init' && func.bodyLines && func.bodyLines > 20) {
|
|
475
|
+
return {
|
|
476
|
+
hasIssue: true,
|
|
477
|
+
message: `init() function is ${func.bodyLines} lines - too complex`,
|
|
478
|
+
line: func.line,
|
|
479
|
+
suggestion: 'Keep init() simple, move logic to explicit setup functions'
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
id: 'GO009',
|
|
488
|
+
name: 'public-struct-private-fields',
|
|
489
|
+
description: 'Exported struct has all private fields',
|
|
490
|
+
language: 'go',
|
|
491
|
+
severity: 'info',
|
|
492
|
+
category: 'api-design',
|
|
493
|
+
enabled: true,
|
|
494
|
+
priority: 40,
|
|
495
|
+
check: (ctx) => {
|
|
496
|
+
for (const cls of ctx.classes) {
|
|
497
|
+
if (cls.isExported) {
|
|
498
|
+
const publicFields = cls.members.filter(m => m.visibility === 'public');
|
|
499
|
+
if (publicFields.length === 0 && cls.members.length > 0) {
|
|
500
|
+
return {
|
|
501
|
+
hasIssue: true,
|
|
502
|
+
message: `Exported struct '${cls.name}' has only private fields`,
|
|
503
|
+
line: cls.line,
|
|
504
|
+
suggestion: 'Consider adding constructor function or public fields'
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
id: 'GO010',
|
|
514
|
+
name: 'fmt-printf-verbs',
|
|
515
|
+
description: 'Check Printf format verbs match arguments',
|
|
516
|
+
language: 'go',
|
|
517
|
+
severity: 'warning',
|
|
518
|
+
category: 'bugs',
|
|
519
|
+
enabled: true,
|
|
520
|
+
priority: 75,
|
|
521
|
+
check: (ctx) => {
|
|
522
|
+
// Simple check for Printf with %v and wrong arg count
|
|
523
|
+
const printfCalls = ctx.findPatternMatches(/fmt\.(Printf|Sprintf|Errorf)\s*\(\s*"([^"]+)"/);
|
|
524
|
+
for (const call of printfCalls) {
|
|
525
|
+
const format = call.groups?.['2'] || call.match;
|
|
526
|
+
const verbCount = (format.match(/%[vdsqxXbcdefgpstTw]/g) || []).length;
|
|
527
|
+
// Count arguments after format string (rough estimate)
|
|
528
|
+
const lineContent = ctx.getLine(call.line);
|
|
529
|
+
const argCount = (lineContent.split(',').length - 1);
|
|
530
|
+
if (verbCount > argCount) {
|
|
531
|
+
return {
|
|
532
|
+
hasIssue: true,
|
|
533
|
+
message: 'Printf format has more verbs than arguments',
|
|
534
|
+
line: call.line,
|
|
535
|
+
suggestion: 'Check format string arguments match verb count'
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
id: 'GO011',
|
|
544
|
+
name: 'sync-pool-new',
|
|
545
|
+
description: 'sync.Pool should have New function',
|
|
546
|
+
language: 'go',
|
|
547
|
+
severity: 'warning',
|
|
548
|
+
category: 'performance',
|
|
549
|
+
enabled: true,
|
|
550
|
+
priority: 60,
|
|
551
|
+
check: (ctx) => {
|
|
552
|
+
const poolDecl = ctx.findPatternMatches(/sync\.Pool\s*{/);
|
|
553
|
+
const poolNew = ctx.findPatternMatches(/sync\.Pool\s*{\s*New:/);
|
|
554
|
+
if (poolDecl.length > poolNew.length) {
|
|
555
|
+
return {
|
|
556
|
+
hasIssue: true,
|
|
557
|
+
message: 'sync.Pool without New function',
|
|
558
|
+
line: poolDecl[0].line,
|
|
559
|
+
suggestion: 'Add New: func() interface{} {...} to initialize pool objects'
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
id: 'GO012',
|
|
567
|
+
name: 'panic-recover',
|
|
568
|
+
description: 'Check for panic without recover',
|
|
569
|
+
language: 'go',
|
|
570
|
+
severity: 'warning',
|
|
571
|
+
category: 'error-handling',
|
|
572
|
+
enabled: true,
|
|
573
|
+
priority: 70,
|
|
574
|
+
check: (ctx) => {
|
|
575
|
+
const panics = ctx.findPatternMatches(/\bpanic\s*\(/);
|
|
576
|
+
const recovers = ctx.findPatternMatches(/\brecover\s*\(/);
|
|
577
|
+
if (panics.length > 0 && recovers.length === 0) {
|
|
578
|
+
return {
|
|
579
|
+
hasIssue: true,
|
|
580
|
+
message: `${panics.length} panic() calls without recover()`,
|
|
581
|
+
line: panics[0].line,
|
|
582
|
+
suggestion: 'Consider using recover() or returning errors instead of panic'
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
];
|
|
589
|
+
export { GO_RULES };
|
|
590
|
+
//# sourceMappingURL=goParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goParser.js","sourceRoot":"","sources":["../../../src/services/parsers/goParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAerD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,kBAAkB;IACrC,QAAQ,GAAG,IAAa,CAAC;IACzB,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC;IAE9B;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,IAAY,EAAE,QAAgB;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,MAAM,OAAO,GAAmB,EAAE,CAAC;QACnC,MAAM,OAAO,GAAiB,EAAE,CAAC;QACjC,MAAM,SAAS,GAAmB,EAAE,CAAC;QACrC,MAAM,OAAO,GAAgB,EAAE,CAAC,CAAC,kBAAkB;QACnD,MAAM,SAAS,GAAmB,EAAE,CAAC;QAErC,qBAAqB;QACrB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3C,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QAE/C,oBAAoB;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,MAAM,EAAE,CAAC;gBACrC,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,gCAAgC;oBACzC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;oBACtB,UAAU,EAAE,8DAA8D;iBAC3E,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF;IACD;QACE,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,iCAAiC;QAC9C,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,gBAAgB;QAC1B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,CAAC,GAAiB,EAAE,EAAE;YAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;YACtD,MAAM,QAAQ,GAAG,GAAG,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;YAE1D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/C,OAAO;oBACL,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,kCAAkC;oBAC3D,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;oBACpB,UAAU,EAAE,+DAA+D;iBAC5E,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF;CACF,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser Registry
|
|
3
|
+
* Centralized management of language-specific parsers
|
|
4
|
+
* @version 3.2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { CodeIssue } from '../../config/types.js';
|
|
7
|
+
import type { LanguageParser, SupportedLanguage, ParserFactory } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Registry for language parsers
|
|
10
|
+
*/
|
|
11
|
+
declare class ParserRegistry {
|
|
12
|
+
private parsers;
|
|
13
|
+
private factories;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Register a parser factory for lazy instantiation
|
|
17
|
+
*/
|
|
18
|
+
registerFactory(language: SupportedLanguage, factory: ParserFactory): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get parser for a specific language (lazy instantiation)
|
|
21
|
+
*/
|
|
22
|
+
getParser(language: SupportedLanguage): LanguageParser | null;
|
|
23
|
+
/**
|
|
24
|
+
* Get parser for a file path
|
|
25
|
+
*/
|
|
26
|
+
getParserForFile(filePath: string): LanguageParser | null;
|
|
27
|
+
/**
|
|
28
|
+
* Analyze code using appropriate language parser
|
|
29
|
+
*/
|
|
30
|
+
analyze(filePath: string, code: string): CodeIssue[];
|
|
31
|
+
/**
|
|
32
|
+
* Check if a language is supported
|
|
33
|
+
*/
|
|
34
|
+
isSupported(language: SupportedLanguage): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if a file is supported
|
|
37
|
+
*/
|
|
38
|
+
isFileSupported(filePath: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Get all supported languages
|
|
41
|
+
*/
|
|
42
|
+
getSupportedLanguages(): SupportedLanguage[];
|
|
43
|
+
/**
|
|
44
|
+
* Get total rule count across all parsers
|
|
45
|
+
*/
|
|
46
|
+
getTotalRuleCount(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Get rules by language
|
|
49
|
+
*/
|
|
50
|
+
getRulesByLanguage(language: SupportedLanguage): import("./types.js").LanguageRule[];
|
|
51
|
+
/**
|
|
52
|
+
* Clear all instantiated parsers (for memory management)
|
|
53
|
+
*/
|
|
54
|
+
clearParsers(): void;
|
|
55
|
+
}
|
|
56
|
+
export declare const parserRegistry: ParserRegistry;
|
|
57
|
+
export * from './types.js';
|
|
58
|
+
export { PythonParser, PYTHON_RULES } from './pythonParser.js';
|
|
59
|
+
export { GoParser, GO_RULES } from './goParser.js';
|
|
60
|
+
export { RustParser, RUST_RULES } from './rustParser.js';
|
|
61
|
+
export { BaseLanguageParser } from './baseParser.js';
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|