Rules that know the whole project.
Most linters read one file at a time. DL lints against its index, so a rule can ask who calls a routine, what a form file binds, which table column a field maps to, or whether anything in the project assigns a field at all. And when a rule can fix what it finds, the compiler checks the fix before you keep it.
From bug patterns to security
The rules fall into 22 categories. The full list, with every rule’s default and whether it can fix the code, is in the rules reference; drag-lint explain <rule> tells you about one rule in plain words.
| Category | What it looks for | Rules |
|---|---|---|
bug-patterns | Code that compiles but misbehaves: Format arguments that do not match, raise inside a destructor, Exit in a finally block, UI calls from a thread. | 195 |
complexity | Routines too long, too deep or too branched: cyclomatic and cognitive complexity, nesting, duplicated blocks. | 15 |
concurrency | Waits whose outcome nobody checks: a WaitFor with a timeout whose result is thrown away, so a timeout looks like success. | 1 |
data-flow | Values on the wrong path: a variable used before assignment, a Result or out parameter not set on every path, a double free. | 13 |
dead-code | Code nothing needs: unused locals and parameters, identical branches, event handlers no form binds. | 23 |
dependency-injection | Spring4D container mistakes: a Resolve of an interface nothing registers, an interface registered twice, a class registered for an interface it does not implement, registrations nothing runs, a singleton that holds a short-lived dependency, a Resolve inside a paint or timer handler. | 11 |
documentation | DocInsight comments missing on public declarations, left as placeholders, or drifted from the code. | 8 |
field-repo | Forms and code that disagree with the Field Repository: lookup and key fields that differ, generators, enums, display formats and visibility that drifted, fields and handlers nothing uses. Silent without a repository. | 11 |
firedac | FireDAC misuse: ParamByName of a parameter the SQL lacks, FieldByName in a loop, a query run once per iteration. | 5 |
metrics | Class design measures: coupling, cohesion, inheritance depth, response set. Beside the rules, drag-lint metrics --halstead reports Halstead counts and a 0..100 maintainability index per routine, rolled up to unit and folder. | 8 |
modernize | Older idioms with a newer form: digit separators, if-expressions, is not, for..in loops. | 6 |
naming | Names that break your conventions: prefixes, casing, a name spelled differently from its declaration. | 14 |
other | Unfinished or leftover work: TODO markers, debug output, safety directives switched off, strings built up in a loop. | 17 |
platform | Win64 and portability: pointers cast to 32-bit integers, asm without a 64-bit variant, GetTickCount wrap-around, fixed pixel sizes. | 16 |
policy | Your own project rules: a required file header, disallowed types, identifiers, calls or form properties. | 6 |
project-wide | Rules that need the whole project: a field nothing assigns, a used unit that resolves nowhere, an INSERT that leaves out a required column. | 69 |
refactoring | Simplifications with a known shape: a parameter that can be const, nested ifs that collapse, a literal that wants a name. | 36 |
resource-lifetime | Objects and memory: use after Free, GetMem without release, a field freed outside the destructor. | 24 |
review-markers | Your own dl:ok reviews: markers that no longer match, name no rule, or carry no review date. | 6 |
security | SQL injection, path traversal, weak or broken ciphers, cleartext transport, secrets in string literals, untrusted data reaching a process launch. Across all categories, 267 rules carry a CWE id. | 34 |
structure | Scope and encapsulation: with statements, public fields, goto, components still named as the designer named them. | 21 |
ui | Form code that fails at run time: SetFocus in the handler the form file binds as OnCreate, before the form is visible. | 1 |
Fixes the compiler checks
136 rules can fix the code for you. lint --fix --apply --project goes through the compile gate by default: DL builds the project after the edit, and a compiler error stops the fix or rolls it back. New warnings and hints are reported, so you see anything a fix stirred up.
In RAD Studio a finding in the Structure window has Fix it on its right-click menu, next to Fix all in unit and Fix all in project. An unused unit is removed, or moved to the implementation section, only after a compile proves it can go.
Lint --fix through the compile gate · Fix it · Fix all in project
On by default, and how to quiet a rule
413 rules are on out of the box; the rest are there when you want them, such as the magic-literal, commented-out-code and opaque-to-analysis checks. When a finding is right but you keep the code, record a dl:ok review on the line, with the reason and a date, and it stops being reported. A rule can also be switched off for one unit or the whole project. The review-marker rules keep those reviews honest: a marker whose finding has gone away is reported too.
267 rules carry a CWE id, and some also a CERT or MISRA id; --labels prints them and rules --standard filters by standard. The taint rules follow data from where it enters the program to an SQL text, a process launch or a file path.
explain · allow (dl:ok) · Disable a rule · Compliance labels · Taint analysis
One file, or the whole project
lint checks one file; lint-all checks the whole project and adds the project-wide rules that only make sense across units. In RAD Studio, Code Quality > Run Lint All (Full Report) does the same, findings are refreshed when you save, and you can lint an editor buffer before you save it. In VS Code and other editors the language server reports findings as problems.
With a Field Repository, schema rules also check MAXLEN constants, string lengths and SQL columns against the columns of your database.
Every rule here has run on the source of HTR Micronite, our own large Delphi application, before it reached you.