From 77c8d46e7b8d12b385b8f4b76005d3b5a44ce526 Mon Sep 17 00:00:00 2001 From: jaakko Date: Tue, 7 Apr 2026 10:34:41 +0300 Subject: [PATCH] =?UTF-8?q?Staattinen=20analyysi:=20tiedostojen=20v=C3=A4l?= =?UTF-8?q?iset=20importit=20tarkistetaan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- network-poc/static/index.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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):`);