Skip to content

[dmt] add statistic after linter run - #457

Merged
ldmonster merged 1 commit into
mainfrom
feat/lint-statistics
Aug 20, 2026
Merged

[dmt] add statistic after linter run#457
ldmonster merged 1 commit into
mainfrom
feat/lint-statistics

Conversation

@ldmonster

@ldmonster ldmonster commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What

Add an end-of-lint statistics summary that is printed after the regular lint
results. The summary is rendered as a single framed block styled to match the
deckhouse-cli mirror pull/push summaries, so the two tools feel like one family.

Running dmt lint now finishes with a compact overview of the run:

╔══ Lint summary ═══════════════════════════════════════
║ Modules:    3
║
║ Critical:   0
║ Errors:     5
║ Warnings:   12
║ Ignored:    2
║
║ By linter:
║   templates                      12
║   openapi                        3
║   no-cyrillic                    2
║
║ Total:      19 findings
║
║ Lint failed; 5 problem(s) must be fixed.
║ Elapsed: 1.2s
╚═══════════════════════════════════════════════════════

Why

Until now the output was a flat list of findings with no roll-up: on a large run
you had to scroll and count by hand to answer basic questions — how many modules
were scanned, how the findings break down by severity, which linters fired most,
and how long the run took. The summary puts that at the bottom of every run and
gives CI logs a single, scannable verdict line.

Details

  • internal/manager/statistics.go — new file with the collector and renderer:
    • collectStatistics() tallies all collected findings by severity
      (critical / errors / warnings / ignored) and by linter. Counts always cover
      every finding regardless of the --hide-warnings / --show-ignored display
      flags, so the summary reflects the full picture.
    • renderStatistics() formats the framed block. The title and state line adapt
      to the outcome:
      • errors/critical present → title Lint failed, red Lint failed; N problem(s) must be fixed.
      • warnings onlyCompleted with N warning(s).
      • clean run → green No problems found. (per-linter breakdown omitted)
    • The per-linter breakdown is sorted most-findings-first, ties broken by name.
    • Colours are semantic (red = failure, yellow = attention, green = clean, dim =
      zero/secondary) and go through fatih/color, which disables ANSI when stdout
      is not a TTY or NO_COLOR is set — so escape codes never leak into pipes or
      files. Colours are applied after width padding so they don't break columns.
  • internal/manager/manager.goManager gains a startedAt timestamp set
    in NewManager; the summary reports wall-clock elapsed since it.
  • cmd/dmt/main.gomng.PrintStatistics() is called right after
    mng.PrintResult() in runLint.

Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
@ldmonster ldmonster self-assigned this Aug 20, 2026
@ldmonster ldmonster added the enhancement New feature or request label Aug 20, 2026
@ldmonster
ldmonster merged commit 8b9878f into main Aug 20, 2026
9 of 10 checks passed
@ldmonster
ldmonster deleted the feat/lint-statistics branch August 20, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant