diff --git a/network-poc/static/index.html b/network-poc/static/index.html index de17040..3273947 100644 --- a/network-poc/static/index.html +++ b/network-poc/static/index.html @@ -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(` Staattinen analyysi (${staticIssues.length} huomautusta):`);