Add jetc --lint-sql to find <sql> that pastes values (phase 2)

Implements phase 2 of docs/design-sql-bound-parameters.md. jetc --lint-sql
[--strict] <file|dir>... lists each <sql> whose statement contains a $[...]
or #[...] reference instead of a <bind>, with file:line and where each value
comes from. Row values ($[.col], $[session.col], $[?N], $[#]) are only
reported with --strict. References in <bind>, <if>, <set> and the other
attribute-only tags, <comment> and |> <| are skipped. A custom tag defined
as <sql><container></sql> (barant.com's <showtable>) is checked at each use.
Exit status is 0 for none found, 1 for findings, 2 for an unreadable path.

- jetc/JetLint.*: the scanner; jetc.cpp: the option
- build scripts and runbindtests.sh: link JetLint.cpp
- tests/runlinttests.sh and tests/lintsql/: fixtures and expected output
- docs: worklist for the local copies of both sites, design doc status,
  manual note on the lint

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-11-20 20:29:28 -08:00
1 parent fd81bb877f
commit 2847ce5fa7
22 files changed
+667 -10

No files matched your search

+15 -4
View File
@@ -1,5 +1,6 @@
#include "JetParser.h"
#include "JetCodegen.h"
#include "JetLint.h"
#include <fstream>
#include <sstream>
#include <iostream>
@@ -26,17 +27,27 @@ namespace {
int main(int argc, char **argv) {
bool shared = false;
bool lintSql = false;
bool strict = false;
std::vector<std::string> pos;
for (int i = 1; i < argc; ++i) {
std::string a = argv[i];
if (a == "--shared") shared = true;
else if (a == "--lint-sql") lintSql = true;
else if (a == "--strict") strict = true;
else pos.push_back(a);
}
if (pos.size() < 2) {
if (lintSql && !pos.empty())
return jetc::lintSql(pos, strict, std::cout, std::cerr);
if (pos.size() < 2 || lintSql || strict) {
std::cerr << "usage: jetc [--shared] <input.jet> <output.cpp>" << std::endl;
std::cerr << " --shared emit a dlsym()-able entry point (see build-shared.sh)" << std::endl;
std::cerr << " instead of a standalone main()." << std::endl;
return 1;
std::cerr << " jetc --lint-sql [--strict] <file|directory>..." << std::endl;
std::cerr << " --shared emit a dlsym()-able entry point (see build-shared.sh)" << std::endl;
std::cerr << " instead of a standalone main()." << std::endl;
std::cerr << " --lint-sql list every <sql> that pastes a variable into the statement" << std::endl;
std::cerr << " instead of using <bind> (exit 1 if any, 0 if none)." << std::endl;
std::cerr << " --strict with --lint-sql, also report row values ($[.column] etc.)." << std::endl;
return lintSql ? 2 : 1;
}
const std::string &inputPath = pos[0];
const std::string &outputPath = pos[1];