Repository navigation
Linting projects and code
clif lint runs CFLint itself: a native build, so no Java is involved. It applies the same rules,
the same .cflintrc files (folder overrides, inheritParent and parameters included) and the same
@CFLintIgnore comments. What it changes is how CFLint is invoked: one command for people, hooks, CI and
agents, with a meaningful exit status on every platform.
clif cflint is an alias for clif lint; both names work everywhere.
clif lint [options] <path> [...]
clif lint --staged | --changed <ref> [options] [<path> ...]
| With CFLint | With clif |
|---|---|
java -jar cflint.jar -file a.cfm,b.cfc -text -stdout |
clif lint --format text a.cfm b.cfc |
java -jar cflint.jar -folder src -json -stdout |
clif lint --format json src |
cflint --version |
clif --version |
grep the text for Total issues:([1-9])
|
The exit status: 0 clean, 1 findings, 2 the run can't be trusted |
| a hook script per machine |
clif hook install, committed in .githooks/ (see Using the GIT Hooks) |
| lint every file in a commit |
--staged, --changed <ref>, --changed-lines
|
| a minimum severity |
--min-severity <level>, or --strict for every level |
| (no equivalent) |
--format sarif, --baseline <file>, clif suppressions --baseline <file>
|
Differences worth knowing: CFLint wants -file a,b comma-separated and silently does nothing with
-file a -file b; clif takes plain arguments. A .cflintrc CFLint can't parse makes CFLint fall back to
default rules silently; clif stops with exit 2.
| Option | Description |
|---|---|
<path> ... |
Files and directories. Naming the config's own directory lints the workspacePaths folders beneath it; folders outside it are there for resolution only and are never linted |
--staged |
The staged .cfm/.cfc files as staged (the index content, through CFLint's -stdin), so an unstaged edit neither hides nor adds a finding |
--changed <ref> |
The .cfm/.cfc files git diff <ref>...HEAD lists, from the working tree |
--changed-lines |
With --staged or --changed: report only findings on lines the change adds or alters |
With --staged or --changed, paths narrow the files to those under them; with none, the whole git
repository holding the working directory is used.
| Option | Description |
|---|---|
--format report |
Default. A known-issues report, one issue per line, paths relative to the .clif.json above the first path |
--format text |
CFLint's -text report, ending in Total issues:N
|
--format json |
CFLint's -json report: issues under issues, with counts recomputed over the whole run |
--format sarif |
SARIF 2.1.0, CFLint codes as rule ids, for CI servers and code-quality tools |
--out <file> |
Write to this file instead of stdout. A report's paths are relative to the file's directory, which must hold every path linted |
--write |
Write the report files the config's knownIssues entries with "generate": "lint" name (report format only). Default file: .clif-cflint.txt beside .clif.json
|
-q, --quiet
|
No progress on stderr |
| Option | Description |
|---|---|
--min-severity <level> |
Report, and fail on, CFLint levels at or above <level>: FATAL, CRITICAL, ERROR, WARNING, CAUTION, INFO, COSMETIC. Overrides linting.minSeverity
|
--strict |
Report and fail on every level, whatever the config says |
--baseline <file> |
Report, and fail on, only findings the file does not list. The file is a known-issues report as --out writes. A finding matches by file, rule and message, not line. Entries no longer found are listed on stderr |
| Code | Meaning |
|---|---|
0 |
No findings, or a known-issues report was written (--write, or --out in report format) |
1 |
Findings |
2 |
The run cannot be trusted: a missing path, an unparseable .cflintrc, CFLint unavailable or failing, not a git repository for --staged/--changed, or a usage error |
clif lint --format json path/to/file.cfcExample output (CFLint's own -json schema, abridged; values are illustrative):
{
"version": "",
"timestamp": 0,
"issues": [
{
"severity": "WARNING",
"id": "MISSING_VAR",
"message": "MISSING_VAR",
"category": "CFLINT",
"abbrev": "MV",
"locations": [
{
"file": "path/to/file.cfc",
"fileName": "file.cfc",
"function": "load",
"column": 8,
"line": 12,
"message": "Variable x is not declared with a var statement.",
"variable": "x",
"expression": "x = 1"
}
]
}
],
"counts": { "totalFiles": 1, "totalLines": 0, "countByCode": [ { "code": "MISSING_VAR", "count": 1 } ], "countBySeverity": [ { "severity": "WARNING", "count": 1 } ] }
}Exit status 1 means findings. Add --min-severity ERROR to block only on serious ones.
clif lint src/src/page.cfm:12:5: [warning MISSING_VAR] Variable x is not declared with a var statement.
src/index.cfm:14:7: [warning CFQUERYPARAM_REQ] <cfquery> should use <cfqueryparam/>
clif lint --format text a.cfm b.cfcCFLint's text report, abridged; the last line is always the total:
Issue
Severity:WARNING
File:a.cfm
Line:12
Column:5
...
Total issues:2
clif lint --staged --strict --format text # pre-commit: staged content, every level fails
clif lint --changed origin/main --strict --format sarif --out cflint.sarif # each CI build
clif lint --strict --format sarif --out cflint.sarif . # nightly: everything--changed needs the merge base of HEAD and the ref, and CI checkouts are often shallow. Fetch the base
first (git fetch --unshallow origin main, or a checkout depth of 0); otherwise clif exits 2 rather than
passing a build it never linted.
// Jenkinsfile: the same command on a Linux or a Windows agent
stage('CFLint') {
steps {
script {
def cmd = 'clif lint --changed origin/main --strict --format sarif --out cflint.sarif'
if (isUnix()) { sh cmd } else { bat cmd }
}
}
}# Makefile
lint:
clif lint --strict --format text .# scripts\lint.ps1
clif lint --strict --format text .
exit $LASTEXITCODEclif lint --write myapp # regenerates myapp/.clif-cflint.txt
clif lint --out myapp/.clif-cflint.txt myapp # explicit location--write refuses to rewrite a report whose directory holds more than was linted, since that would drop the
entries for everything else. The editor publishes these entries as diagnostics labelled cflint, and hides
a file's entries once CFLint runs on it live. See Linter Options.
Two ratchets let a project turn a rule on without fixing everything first, and stop the debt growing:
clif lint --out cflint-baseline.txt . # once: record today's findings
clif lint --baseline cflint-baseline.txt --format text . # fail only on new findings
clif suppressions --baseline suppressions.json --update-baseline . # once
clif suppressions --baseline suppressions.json . # fail if @CFLintIgnore counts roseclif suppressions [--format text|json] [--baseline <file> [--update-baseline]] [-q] <path> [...]
Counts @CFLintIgnore tags and // cflint ignore: comments by rule. A code list ends at the first space,
as CFLint reads it, so @CFLintIgnore A, B counts (and suppresses) A only.
| Option | Description |
|---|---|
--format text / json
|
Output format (default text) |
--baseline <file> |
Compare with a committed baseline and fail (exit 1) if the total or any rule's count rose |
--update-baseline |
Write the current counts to the --baseline file |
-q, --quiet
|
With --baseline, print only what rose |
clif suppressions src/37 suppressions in 21 files
MISSING_VAR 18
CFQUERYPARAM_REQ 11
ARG_HINT_MISSING 8
Against a baseline:
rose MISSING_VAR 18 -> 20 (+2)
fell CFQUERYPARAM_REQ 11 -> 9 (-2)
Suppressions rose against suppressions.json. Fix the findings instead, or accept them with: clif suppressions --baseline suppressions.json --update-baseline <path>
| Exit | Meaning |
|---|---|
0 |
Counted; with --baseline, nothing rose |
1 |
With --baseline, the total or a rule's count rose |
2 |
A path or the baseline does not exist or cannot be read, or a usage error |
| Source | Order |
|---|---|
CLIF_CFLINT environment variable |
1. Used first; an error if it names no executable file |
cflint on PATH
|
2. |
The copy embedded in a released clif
|
3. Unpacked into the user cache (or CLIF_CFLINT_DIR) on first use |
| Download of the pinned version | 4. Builds without an embedded copy only; refused unless the checksum compiled into clif matches |
See Linter Options for enabling CFLint diagnostics in the editor.