Staattinen analyysi: tiedostojen väliset importit tarkistetaan

from db import get_db → tarkistaa onko get_db määritelty db.py:ssä
(def, class tai muuttuja). Löytää puuttuvat exportit ennen Docker-buildia.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 10:34:41 +03:00
parent f14eba1b49
commit 77c8d46e7b

View File

@@ -2542,6 +2542,26 @@ IMPORTANT: Keep the code SHORT. Max ~50 lines. No comments, no docstrings. Write
// Tarkista tyhjät funktiot
const emptyFuncs = code.match(/def \w+\([^)]*\):\s*\n\s*(pass|\.\.\.)/g);
if (emptyFuncs) staticIssues.push(`${name}: ${emptyFuncs.length} tyhjää funktiota`);
// Tarkista tiedostojen väliset importit (from db import get_db → onko get_db db.py:ssä?)
for (const imp of imports) {
const crossMatch = imp.match(/from\s+(\w+)\s+import\s+(.+)/);
if (crossMatch) {
const modName = crossMatch[1];
const importedNames = crossMatch[2].split(',').map(n => n.trim().split(' as ')[0].trim());
const targetFile = modName + '.py';
const targetCode = generatedFiles[targetFile];
if (targetCode) {
for (const sym of importedNames) {
// Tarkista onko symboli määritelty kohdetiedostossa (def, class, muuttuja)
const defined = targetCode.includes(`def ${sym}`) || targetCode.includes(`class ${sym}`) || targetCode.match(new RegExp(`^${sym}\\s*=`, 'm'));
if (!defined) {
staticIssues.push(`${name}: importtaa '${sym}' tiedostosta ${targetFile}, mutta sitä ei ole määritelty siellä`);
}
}
}
}
}
}
if (staticIssues.length > 0) {
termLog(` <span style="color:#d29922">Staattinen analyysi (${staticIssues.length} huomautusta):</span>`);