Run and report withResource nesting lint with Jython [reduced-it] - #15879
Run and report withResource nesting lint with Jython [reduced-it]#15879gerashegalov wants to merge 10 commits into
Conversation
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
|
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
|
build |
|
Here is the direct link to the report. @wjxiz1992 |
| if os.environ.get("GITHUB_ACTIONS") == "true": | ||
| emit_annotations(classified) | ||
|
|
||
| if scan.directive_errors: |
There was a problem hiding this comment.
scan.directive_errors is checked after the --print-baseline and --update-baseline early returns. As a result, a malformed exemption makes the normal lint exit 1, but both baseline modes exit 0; update mode can rewrite the baseline despite the invalid directive. This regresses the previous behavior and the stated unchanged exit-code contract. Could we move this validation before the baseline early returns and cover both modes with tests?
There was a problem hiding this comment.
Fixed in 761ca16. Directive errors are now checked immediately after scanning, before either baseline-mode early return. Added regression coverage for both --print-baseline and --update-baseline; the update test also verifies the existing baseline remains unchanged.
|
|
||
|
|
||
| def emit_annotations(classified): | ||
| for item in classified[:50]: |
There was a problem hiding this comment.
classified[:50] can spend all annotation slots on existing baselined warnings. The repository already has 59 baselined violations, so a new violation appearing later in source order can fail the job without any ::error annotation (I reproduced 50 warnings and 0 errors). Could we prioritize status == "new" entries, then fill the remaining slots with baselined warnings?
There was a problem hiding this comment.
Fixed in 761ca16. Annotation emission now prioritizes new violations while preserving source order within each status, then fills remaining slots with baselined warnings. The regression test covers 50 baselined violations followed by one new violation and verifies that the new violation receives the error annotation.
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
|
|
||
| - name: Report withResource nesting violations | ||
| run: | | ||
| mvn --batch-mode -N antrun:run@with-resource-nesting-audit \ |
There was a problem hiding this comment.
[P1] Because this runs the script through Maven/Ant, every workflow command is prefixed with [INFO] [java] in the current audit log. GitHub therefore does not parse the emitted ::warning/::error lines: check run 102566070742 reports annotations_count=1, and that lone annotation is only the runner's Node.js deprecation warning, even though 59 scopes produced 50 source-warning commands in the log. Could we emit these commands directly to the runner, or strip the Maven prefix while preserving pipefail, so new violations receive the promised source annotations?
| stale = stale_baseline_entries(scan.violations, baseline) | ||
| classified = classify_violations(scan.violations, baseline) | ||
| report_failed = False | ||
| if args.summary: |
There was a problem hiding this comment.
[P1] This report path is unreachable when the scan contains an invalid exemption because main returns immediately after scan_tree. On this head I reproduced exit code 1 with summary_exists=False and raw_report_exists=False, so the always() upload silently has no artifact and the invalid directive is absent from the promised report. Could we reject directive errors early only for --print-baseline/--update-baseline, while allowing normal mode to render its reports and then fail? Please also cover normal mode by asserting that directiveErrors is present in the JSON report.
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
|
build |
Related to #11713.
Description
The repository-wide withResource nesting lint currently requires a host Python 3 executable and is repeated by both generated Scala root builds. This change ports the lint and its unit tests to code compatible with Jython 2.7.3 while retaining Python 3 compatibility.
Maven now launches the tests and repository scan through its existing managed Jython dependency. A dedicated root execution runs only from the canonical Scala 2.12 reactor; the generated Scala 2.13 POM keeps its Scala-specific checks but does not repeat this repository-wide scan.
A new pull-request check publishes every detected deep scope in the GitHub job summary and a JSON artifact. It prioritizes new violations when annotating up to 50 source locations, while the complete set remains available in both reports. Baselined scopes are visible existing debt and do not fail the check. New violations, stale baseline entries, invalid exemptions, or report-generation errors remain failures.
The depth-four policy, exemption behavior, CLI flags, diagnostics, exit codes, baseline schema, and all 59 existing fingerprints remain unchanged. Ordered JSON serialization and normalized source traversal keep generated baselines byte-for-byte identical across Jython and Python 3.
This PR contains no deprecation-policy or deprecation-audit changes.
This change was developed with AI assistance and reviewed by the author.
Validation performed:
Performance testing is not required because this changes build-time lint tooling only and does not modify production runtime code.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance