"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GoExtractor = void 0;
const GO_PATTERNS = [
    {
        name: 'naked_return',
        category: 'return_style',
        regex: /\bfunc\s+\w+.*\(.*\w+.*\)\s+\(?.*\w+.*\)?\s*\{[\s\S]*?\breturn\b(?!\s+\w)/g,
        description: 'Prefers explicit returns over naked returns',
    },
    {
        name: 'underscore_import',
        category: 'import_style',
        regex: /^\s*_ "[\w/]+"/gm,
        description: 'Side-effect imports should have documented reason',
    },
    {
        name: 'panic_error',
        category: 'error_handling',
        regex: /\bpanic\(/g,
        description: 'Prefers error returns over panic()',
    },
    {
        name: 'global_var',
        category: 'variable_scope',
        regex: /^\s*var\s+\w+\s+\w+\s*$/gm,
        description: 'Prefers local scope over package-level variables',
    },
    {
        name: 'goroutine_leak',
        category: 'concurrency',
        regex: /^\s*go\s+\w+/gm,
        description: 'Goroutine without sync.WaitGroup or channel',
    },
    {
        name: 'init_func',
        category: 'code_organization',
        regex: /^\s*func\s+init\(\)/gm,
        description: 'init() makes testing difficult',
    },
    {
        name: 'string_format',
        category: 'string_style',
        regex: /fmt\.Sprintf\(/g,
        description: 'Prefers string concatenation over fmt.Sprintf for simple cases',
    },
];
class GoExtractor {
    extract(code) {
        const results = [];
        for (const p of GO_PATTERNS) {
            const matches = code.match(p.regex);
            if (matches) {
                results.push({
                    category: p.category,
                    description: p.description,
                    from: p.name,
                    to: p.name.replace(/_/g, '_fixed'),
                    confidenceDelta: Math.min(0.15, matches.length * 0.05),
                    conditions: [],
                });
            }
        }
        return results;
    }
}
exports.GoExtractor = GoExtractor;
//# sourceMappingURL=go-extractor.js.map