PMM-7 add a Groovy lint gate for the pmm/ pipelines - #4366
Open
travagliad wants to merge 2 commits into
Open
Conversation
Scoped to pmm/ throughout. No other product directory is linted, gated or
reported on, root vars/ included.
Measured first: npm-groovy-lint 18.0.0 over the 62 .groovy files under pmm/
with the stock "recommended" ruleset reports 5,557 violations (7 error, 1,902
warning, 3,648 info) across 54 rules, with every file offending. A gate over
all of pmm/ is red on arrival, so the workflow diffs the PR against its base
and lints only the pmm/ .groovy files the PR adds or changes.
pmm/.groovylintrc.json extends CodeNarc's recommended-jenkinsfile profile and
turns off the rules Jenkins pipeline DSL structurally violates (repeated string
literals, GString quoting, indentation, UPPER_CASE parameter names, block size),
raises LineLength to 200, and promotes a short list of real defects to error.
That brings the pmm/ backlog to 384 violations, all advisory. No file under
pmm/ fails to parse.
UnnecessarySelfAssignment is off rather than promoted: `env.X = env.X` is the
documented way to persist an environment{} var onto the build so that
`build job:` callers can read it back out of buildVariables, and pmm3-ha-eks
and pmm3-ha-rosa both rely on it.
Only error severity fails a PR; warning and info are advisory. Errors are
annotated on the diff, the rest goes to the step log and job summary.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XcEM8jZrmdWWDJH65wxA2D
Every UnusedVariable the new gate reports under pmm/, so it starts clean
instead of blocking the next person to touch one of these files. Each was
checked against its file first; nothing that has an effect was removed.
- openshift_cluster_destroy: resourceCount is parsed out of DESTROY_RESULT and
never used - the build description next to it reads ocpVersion only.
- pmm3-package-testing-{amd64,arm64}: `curl -s ifconfig.me` into a PUBLIC_IP
that is never read; the block below uses VM_IP throughout, including the echo
on the following line.
- pmm3-release-candidate: keeps the `build job: 'pmm3-rewind-submodules-fb'`
call, drops only the unused binding it was assigned to.
- pmm3-upgrade-ami-test-runner, pmm3-upgrade-ami-tests, pmm3-upgrade-test-runner:
pure list expressions assigned and never read.
No behaviour changes: 6 discarded values and one wasted network call.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XcEM8jZrmdWWDJH65wxA2D
travagliad
requested review from
a team,
ademidoff and
talhabinrizwan
as code owners
August 21, 2026 22:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Groovy lint check for PMM's Jenkins pipelines, and clears the backlog it would otherwise start red on.
Scoped to
pmm/throughout. No other product directory is linted, gated or reported on, and neither is the repo-rootvars/shared library, since that one is loaded by every product's builds. The workflow file has to live in.github/workflows/— GitHub's rule — so it is named for PMM and filtered topmm/**twice: once by itspaths:trigger, so it never appears on another product's PR, and once in the file list it builds, so a PR touching bothpmm/and another directory is still only judged on itspmm/files.Measured before deciding anything
npm-groovy-lint18.0.0 (CodeNarc 3.7.0 / Groovy 3.0.9) over the 62.groovyfiles underpmm/:recommendedEvery file offends under the stock ruleset, so a gate over all of
pmm/would be red on arrival and ignored within a week. Two things fix that:pmm/.groovyfiles withgit diff --diff-filter=ACMR base.sha HEADand lints just those. The rest of the backlog is paid down as files get touched, by whoever already has the file open.pmm/.groovylintrc.jsonextends CodeNarc's ownrecommended-jenkinsfileprofile and switches off the rules pipeline DSL structurally violates — repeated string literals (1,002 hits: pipelines repeat branch names, agent labels, credential ids),UnnecessaryGString(486),SpaceAroundOperator(667, fromKEY=credentials('id')inenvironmentblocks),Indentation(210, both 2- and 4-space styles are established here),ParameterName(268, Jenkins params are UPPER_CASE), and block-size rules.LineLengthgoes to 200 rather than off (661 hits → 82). Every rule that is off or promoted carries its reason and its measured count in a comment, so this is arguable rather than mysterious.Only
errorseverity fails a check;warningandinfoare advisory. Errors are annotated on the diff, everything else goes to the step log and the job summary.Second commit: the 7 dead assignments
So the gate starts clean instead of blocking the next person to touch one of these files. Each was checked against its file first, and nothing that has an effect was removed:
openshift_cluster_destroy—resourceCountis parsed out ofDESTROY_RESULTand never used; the build description beside it readsocpVersiononly.pmm3-package-testing-{amd64,arm64}—curl -s ifconfig.meinto aPUBLIC_IPthat is never read. The block below usesVM_IPthroughout, including theechoon the very next line.pmm3-release-candidate— keeps thebuild job: 'pmm3-rewind-submodules-fb'call, drops only the unused binding it was assigned to.pmm3-upgrade-ami-test-runner,pmm3-upgrade-ami-tests,pmm3-upgrade-test-runner— pure list expressions assigned and never read.Net: 6 discarded values and one wasted network call. No behaviour changes.
One rule that measurement talked me out of
UnnecessarySelfAssignmentis off, not promoted to error. Its two hits areenv.CLUSTER_NAME = env.CLUSTER_NAMEinpmm3-ha-eksandpmm3-ha-rosa, which is the documented way to persist anenvironment{}var onto the build sobuild job:callers can read it back out ofbuildVariables— deliberate, and commented as such in both files. CodeNarc has no way to know that.Notes for review
pmm/fails to parse.--noserveris deliberate: the default CodeNarc daemon mode times out after 120s on a long file list and returns nothing at all.npm-groovy-lint@18.0.0) and actions are pinned to commit SHAs, matchingppg-ami-factory.yml.workflow_dispatchwithscope=allre-measures the wholepmm/backlog without gating anything.pmm/AGENTS.md(+ a shortCLAUDE.mdpointer), which opens with the scope rule — stay insidepmm/, use rootvars/but do not change it,pmm/v3/vars/is PMM's own library — and covers how pmm-qa and pmm-submodules connect topmm/v3/.Verified locally end to end (lint → annotations → job summary → exit code) on the full 62-file set and on single-file runs.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XcEM8jZrmdWWDJH65wxA2D
Generated by Claude Code