Delphi-RAG-Lint

drag-lint help

Fix all in unit

Since: 0.1.0-alpha

Applies autofixes for every fixable finding in the current unit, starting from the Structure form.

Read this when one unit has several auto-fixable findings and you want them all fixed at once. In the Structure form right-click the Diagnostics root or a finding and choose Fix all in unit; the caption shows how many fixes are available, and the item is disabled when there are none.

How to run it

Full flag list: lint in the CLI reference.

Flags

FlagArgumentMeaningDefault
--rule<id>
--disable
--rules-dir<dir>
--json
--labels
--no-preprocess
--library-db<lib.sqlite>
--db<index.sqlite>
--project-rules
--stand-in-for<realpath>

Where to click

  • Right-click in the Structure form: Fix all in unit
    1. Open the Structure form (drag-lint > Show Structure)
    2. Right-click a node
    3. Choose Fix all in unit; its caption shows how many fixes are available

Details

Applies autofixes for every fixable finding in the current unit, starting from the Structure form. Reach for it when a unit has several fixable findings and you want them all resolved in one action.

What you see while it runs

  • The item is ENABLED only when at least one finding in the unit has a registered fix, and its caption says how many: "Fix all in unit (3)". It is offered from the Diagnostics root and from any Diagnostics row.

  • param-name-prefix is ON by default since 1.52.2 (accepted prefixes naming.param_prefixes, default p, A; a parameter wearing the field prefix F is always reported; a typed Hungarian prefix is accepted while naming.param_hungarian is allowed; Sender, single-letter names and the names in naming.param_exempt (default Value, Source, Owner) are exempt). Its fix is OPT-IN (owner 2026-11-20): it runs only when the run names the rule (--rule, --enable or --fix-rule param-name-prefix), never in a blanket Fix all / --fix --apply. It adds naming.param_prefix (default p; FName becomes pName) at the declaration, the implementation header and every body use, and DECLINES -- a note, nothing written -- for a virtual / override / dynamic / abstract / message method, a method of an interface type, and a non-private method of a class that implements an interface: that parameter list is shared with partners the fix does not rename.

  • The seven NAMING fixes (const-casing, type-name-prefix, method-pascalcase, local-var-casing, field-name-prefix, param-name-prefix, local-field-prefix) ARE counted when the project has an index (they rename a symbol everywhere it is used, so they need it). With any naming finding in the unit, Fix all in unit runs a PREVIEW first and ALWAYS asks before renaming: Rename N identifier(s) in <project>? for a unit one project compiles, or the multi-project confirmation listing every owning project for a shared unit (see Multi-Project-Rename). Both default to No, and No writes nothing. Renames that cannot be done safely are dropped and listed; the rest are applied.

  • It runs in the BACKGROUND on the drag-lint job queue -- the IDE stays usable, and the dock's status strip shows the job while it works.

  • When it finishes, the engine's own summary is shown ON THE DIAGNOSTICS ROOT ROW of the panel (with the time), in the status strip and in the IDE Messages pane, e.g. drag-lint: Fix all in unit -- Unit1.pas: applied 2 edit(s) across 1 file(s) (.bak written) or ... no fixable findings (of 13 finding(s)).

  • When edits were applied, the editor buffer is reloaded from disk, the project is reindexed and the unit is re-linted, so the fixed findings drop off the panel on their own.

  • A unit with UNSAVED changes is refused ("save the unit first"): the fix rewrites the file on disk and reloads the editor from it.

"Fix it" on a single finding works the same way. unused-unit-in-uses findings are not counted here -- they are fixed one at a time by Fix it, which compiles to decide between removing and moving.

Running it from the CLI

The menu item runs lint with the autofix flags, unscoped -- no --fix-line/--fix-rule, so every fixable finding in the file is applied:

drag-lint lint --in <path.pas> --fix --apply [--db <project.sqlite>]

The IDE passes the project's --db: the naming fixes need the index to find every use. Every fix is on by default (since 1.37.0). With a naming finding in the unit it also passes --fix-naming (a no-op the engine still accepts, and the reason it prints rename-local: <N>) -- on the preview AND on the apply; only the apply waits for your confirm:

drag-lint lint --in <path.pas> --fix --fix-naming --db <project.sqlite>           (preview)
drag-lint lint --in <path.pas> --fix --fix-naming --apply --db <project.sqlite>   (after Yes)

To withhold a rule, list it in "autofix_off": [...] in drag-lint-lint.json (the retired "autofix": [...] key is ignored). A rename the engine cannot prove complete is skipped and counted (skipped (dfm-referenced): N, skipped (dfm-unindexed): N -- a text form names it in a row the index holds no reference for, e.g. AfterScroll = Handler or another form's OnClick, skipped (with-block): N) -- nothing is written for it. A with removal (with-statement, nested-with, with-hides-outer-symbol) is re-indexed into a copy of the DB first and declined, with a declined -- rebind-after note, when any name would bind to something else (1.52.2; see unwith).

Without --apply the command is a DRY RUN: it reports what it would fix and writes no source file and no index. With --apply, naming fixes may first reindex stale owning project indexes. Always dry-run first.

Only rules marked fixable are applied; 147 of the 557 rules are fixable (drag-lint rules --json reports a fixable field per rule).

What it needs

No index required -- lint --in works on a single file.

Example

Dry run:

drag-lint lint --in C:\Projects\MyApp\Unit1.pas --fix

Typical output when nothing is fixable:

autofix: no fixable findings (of 13 finding(s))

Apply for real:

drag-lint lint --in C:\Projects\MyApp\Unit1.pas --fix --apply

All features | CLI reference | IDE menus