Delphi-RAG-Lint
Delphi tooling · legacy code

Lint Only What Your Change Added

A drag-lint baseline records the findings a Delphi project already has, so the next run reports only the findings your change added, on the command line and, since 1.57, in the IDE Structure form. The old findings are not hidden for good: they stay in the baseline file, and every one of them comes back the moment you edit its line.

Availability

The --baseline and --write-baseline options have been in the command line since 0.66 (2026-06-29). The new only box in the IDE Structure form is new in 1.57.0-alpha. Every output below is real output of drag-lint 1.58.0-alpha, released 2026-11-29, on the small unit in section 01 (paths shortened to ..., progress lines left out).

Point a linter at a unit that is ten years old and it answers with hundreds of findings. Most of them are true and none of them are yours, so nobody reads the list, and the one finding your change did add drowns in it. We hit this on Micronite, the quality and production-control software we build for manufacturers, whose older units carry a long tail of accepted findings. A baseline splits the list in two: what was there before, and what is new.

01 — The fixture

A unit with old findings nobody will fix today

Invoices.pas stands in for a legacy unit. It has five findings: an empty except (reported by two rules), a StrToCurr without a TFormatSettings, a with statement and an unused local.

function TInvoices.Total: Currency;
var
  I: Integer;
  Unused: Integer;
begin
  Result := 0;
  for I := 0 to FLines.Count - 1 do
    try
      Result := Result + StrToCurr(FLines[I]);
    except
    end;
end;

procedure TInvoices.Load(const pFileName: string);
begin
  with FLines do
  begin
    Clear;
    LoadFromFile(pFileName);
  end;
end;
02 — Record the baseline

Index, lint, write down what is already there

Step 1. Index the folder into a database of its own.

drag-lint index . --db fix.sqlite

Done. Files: 1, Symbols: 10, Refs: 32, 0.19s, parse-errors=0

Step 2. Lint the whole index. These are the five old findings.

drag-lint lint-all --db fix.sqlite

...\Invoices.pas:42:5  [warning] empty-except: Empty except block silently swallows every exception -- log it or re-raise.
...\Invoices.pas:41:26  [warning] locale-sensitive-conversion: Locale-sensitive conversion without a TFormatSettings -- behaves differently per regional settings; pass an explicit TFormatSettings.
...\Invoices.pas:48:3  [info] with-statement: 'with' statement makes symbol scope ambiguous
...\Invoices.pas:36:3  [hint] unused-local: H2164 Variable 'Unused' is declared but never used in 'TInvoices.Total'
...\Invoices.pas:42:5  [warning] try-except-swallowed: Exception silently swallowed -- add raise, logging, or Application.HandleException.
lint-all: 5 finding(s) -- 0 error(s), 3 warning(s), 1 info, 1 hint -- 1 file(s) scanned -- report: ...\lint-report-20261129.txt

Step 3. Record them as the baseline. The run writes the file and exits 0.

drag-lint lint-all --db fix.sqlite --write-baseline lint-baseline.json

baseline written: 5 fingerprint(s) -> lint-baseline.json

The file holds one fingerprint per finding, nothing you would want to edit by hand:

{
  "version": 1,
  "fingerprints": [
    "ddd29b1f904d98217131f636a7a548c543cad74735dd6d77c412e37a3ed5802a",
    ...
  ]
}

Step 4. Lint against the baseline. Nothing is new, so nothing is reported, and the exit code is 0.

drag-lint lint-all --db fix.sqlite --baseline lint-baseline.json

lint-all: 0 finding(s) -- 0 error(s), 0 warning(s), 0 info, 0 hint -- 1 file(s) scanned -- report: ...\lint-report-20261129.txt
03 — Make a change

New code above the old code, and one new mistake

The change adds a Save method above Total. That moves every old finding down by seven lines, and the new method has a mistake of its own: CurrToStr without a TFormatSettings, on line 30.

procedure TInvoices.Save(const pFileName: string);
begin
  FLines.Add(CurrToStr(Total));
  FLines.SaveToFile(pFileName);
end;

Step 5. Reindex (the lint reads the index), then lint against the same baseline.

drag-lint index . --db fix.sqlite

Done. Files: 1, Symbols: 12, Refs: 42, 0.26s, parse-errors=0

drag-lint lint-all --db fix.sqlite --baseline lint-baseline.json

...\Invoices.pas:30:14  [warning] locale-sensitive-conversion: Locale-sensitive conversion without a TFormatSettings -- behaves differently per regional settings; pass an explicit TFormatSettings.
lint-all: 1 finding(s) -- 0 error(s), 1 warning(s), 0 info, 0 hint -- 1 file(s) scanned -- report: ...\lint-report-20261129.txt

One finding, the new one, and exit code 1. The five old findings all sit on other line numbers now and none of them is reported: the baseline does not match by line number. A build step can fail on that exit code and stay green on the old code.

Step 6. Now touch an old line. The change also turns Unused: Integer; into Unused: Int64;.

drag-lint index . --db fix.sqlite
drag-lint lint-all --db fix.sqlite --baseline lint-baseline.json

...\Invoices.pas:30:14  [warning] locale-sensitive-conversion: Locale-sensitive conversion without a TFormatSettings -- behaves differently per regional settings; pass an explicit TFormatSettings.
...\Invoices.pas:43:3  [hint] unused-local: H2164 Variable 'Unused' is declared but never used in 'TInvoices.Total'
lint-all: 2 finding(s) -- 0 error(s), 1 warning(s), 0 info, 1 hint -- 1 file(s) scanned -- report: ...\lint-report-20261129.txt

The unused local is back. Its line changed, so it counts as part of your change: you touched it, you see it. That is the point of the design. A baseline is a list of findings you have not looked at yet, not a list of findings you have approved.

04 — How a finding is matched

Rule, file, line text, occurrence

A finding counts as old when the baseline holds one with the same rule id, the same file and the same line text with leading and trailing blanks trimmed. Two old findings of one rule on two identical lines are counted occurrence by occurrence, so a third copy of the line is new. From that follows:

  • Inserting or deleting lines elsewhere keeps a finding old (step 5).
  • Re-indenting a line keeps it old, because the text is trimmed (tried on the with line: still not reported).
  • Editing the line makes it new (step 6), even when the edit has nothing to do with the finding.
  • Fixing a finding simply removes it; the baseline keeps a fingerprint that matches nothing, which does no harm. Write the baseline again when you want the file to shrink.

The same options work on lint for one file: drag-lint lint ...\Invoices.pas --db fix.sqlite --baseline lint-baseline.json gives the same two findings as step 6.

05 — In the IDE

The new only box in the Structure form (1.57)

Open the Structure form (drag-lint > Show Structure) and tick new only in the filter row above the tree, beside regex. The Diagnostics node then shows only the findings of the current unit that the baseline does not hold, and its caption counts both, for example Diagnostics (2 new of 9). Untick the box to see every finding again.

The form reads the baseline from a fixed place, <project folder>\_D-RAG\lint-baseline.json, so write it there:

drag-lint lint-all --db <db> --write-baseline <project folder>\_D-RAG\lint-baseline.json

The plugin does not decide which findings are new; it asks the command line, so the IDE and a build step give the same answer. When the file is missing, the caption reads Diagnostics (9, no baseline) and every finding is shown.

06 — Why it is repeatable

A deterministic Delphi algorithm, not AI and not manual work

Every finding comes from the index drag-lint builds by parsing your source, and the baseline is a fixed function of rule, file and line text. No model is asked which findings matter and nobody sorts the list by hand: the same source, index and baseline give the same short list on every run and on every machine.

07 — Limits

What to know before you rely on it

  • On 1.58, write the baseline with lint-all. In 1.58.0-alpha the fingerprint keeps the file path as you typed it, so a baseline written by lint Invoices.pas --write-baseline ... with a relative path matches only later runs with the same relative path. Since 1.59.0-alpha the fingerprint uses one canonical path, and a baseline written either way matches lint-all, lint with any spelling of the path and the IDE; a relative-path baseline written by 1.58 should be written once more. See One Baseline, However You Type the Path.
  • The command line reads the line text from the saved file. Since 1.59 the IDE's new only box reads it from the editor, so a line you edit counts as new at once, before you save.
  • The IDE reads one baseline path; there is no setting for another one yet.
  • A baseline hides nothing from someone who looks: lint-all without --baseline still reports everything. To approve a single finding for good, with a reason, use a dl:ok marker on its line instead.

Output measured 2026-11-29 with drag-lint 1.58.0-alpha on a one-unit fixture. The IDE captions in section 05 come from the feature's documentation, not from this run. The first two Limits were updated the same day for drag-lint 1.59.0-alpha, from its release notes, the engine and plugin source, and the runs in One Baseline, However You Type the Path.