feat: SARIF 2.1.0 and Checkstyle XML reports for check/fix
Some checks are pending
CI / lint (push) Waiting to run
CI / test (ubuntu-latest) (push) Waiting to run
CI / test (windows-latest) (push) Waiting to run
Some checks are pending
CI / lint (push) Waiting to run
CI / test (ubuntu-latest) (push) Waiting to run
CI / test (windows-latest) (push) Waiting to run
--report FILE on check and fix writes the findings a run already computed into CI-consumable formats chosen by extension: .sarif (single run, %SRCROOT%-relative URIs, properties.autoFixable, rule registry with descriptions) and .xml (Checkstyle, source=jmove.<rule>). Unknown suffixes fail fast with INVALID_ARGUMENT; stdout and exit codes are untouched, and clean runs write valid empty documents. The check handler moved into cli::report (its format siblings); fix emits the candidate list in dry-run and apply modes. Marketing angle from the plan: auto-fix for what Checkstyle only reports.
This commit is contained in:
parent
47395069cb
commit
ad1ad4f999
10 changed files with 726 additions and 56 deletions
|
|
@ -21,9 +21,7 @@ $ jmove mv lib/sum.ts utils/sum.ts --dry-run
|
|||
@@ -1,4 +1,4 @@
|
||||
-import { sum } from "./lib/sum";
|
||||
+import { sum } from "./utils/sum";
|
||||
|
||||
export function main(): number {
|
||||
return sum(1, 2);
|
||||
...
|
||||
move lib/sum.ts -> utils/sum.ts
|
||||
```
|
||||
|
||||
|
|
@ -57,8 +55,7 @@ $ echo $?
|
|||
|
||||
### Operating on another project
|
||||
|
||||
`--root` points jmove at a project other than the current directory; all
|
||||
path arguments stay relative to that root:
|
||||
`--root` points jmove at another project; path arguments stay relative to it:
|
||||
|
||||
```console
|
||||
$ jmove --root ~/code/frontend mv src/old.ts src/new.ts --dry-run
|
||||
|
|
@ -75,8 +72,8 @@ $ echo $?
|
|||
```
|
||||
|
||||
jmove never overwrites: free the destination (or pick another name) and
|
||||
retry. A missing source reports `SOURCE_NOT_FOUND` the same way, and a
|
||||
file nobody imports simply moves with zero rewrites.
|
||||
retry. A missing source reports `SOURCE_NOT_FOUND`; an unimported file
|
||||
simply moves with zero rewrites.
|
||||
|
||||
### Java: package + imports + move in one step
|
||||
|
||||
|
|
@ -87,7 +84,6 @@ is three coordinated edits — jmove makes all of them:
|
|||
$ jmove mv src/main/java/com/example/util/Text.java src/main/java/com/example/core/Text.java --dry-run
|
||||
--- src/main/java/com/example/app/App.java
|
||||
+++ src/main/java/com/example/app/App.java
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.example.app;
|
||||
|
||||
-import com.example.util.Text;
|
||||
|
|
@ -112,8 +108,6 @@ dry-run/atomic engine. Preview first, then apply:
|
|||
|
||||
```console
|
||||
$ cat src/main/java/com/example/app/App.java
|
||||
package com.example.app;
|
||||
|
||||
import com.example.Text;
|
||||
import com.example.unused.Ghost; // never referenced
|
||||
|
||||
|
|
@ -121,7 +115,6 @@ import com.example.unused.Ghost; // never referenced
|
|||
$ jmove fix --dry-run
|
||||
--- src/main/java/com/example/app/App.java
|
||||
+++ src/main/java/com/example/app/App.java
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.example.app;
|
||||
|
||||
import com.example.Text;
|
||||
|
|
@ -226,10 +219,18 @@ $ jmove check --json
|
|||
}
|
||||
```
|
||||
|
||||
Note: this response keeps `status: "ok"` (the command itself succeeded)
|
||||
while the process exits `2`; treat a non-zero `total` — or exit code `2` —
|
||||
as a failed refactor. A clean project returns `"broken_imports": [], "total": 0`
|
||||
and exit code `0`.
|
||||
Note: the response keeps `status: "ok"` while the process exits `2`; treat a
|
||||
non-zero `total` (or exit `2`) as a failed refactor; clean returns exit `0`.
|
||||
|
||||
### CI report (same findings, machine formats)
|
||||
|
||||
```console
|
||||
$ jmove check --report build/jmove.sarif # SARIF 2.1.0, GitHub/CodeQL
|
||||
$ jmove fix --report build/jmove.xml # Checkstyle XML, IDEs/Jenkins
|
||||
```
|
||||
|
||||
`--report` never changes stdout or the exit code; clean runs write valid
|
||||
empty documents. Rule ids match the `--json` ones.
|
||||
|
||||
### Error shape
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ Exit code never changes; surface the list to the user.
|
|||
### check — find broken imports and Java layout errors
|
||||
|
||||
```
|
||||
jmove check [--root DIR] [--json]
|
||||
jmove check [--root DIR] [--json] [--report FILE]
|
||||
```
|
||||
|
||||
Run after any move (or any edit) to validate project consistency. Reports
|
||||
|
|
@ -65,10 +65,22 @@ broken relative imports and Java files whose single public type is named
|
|||
differently from the file (each finding carries the exact `jmove mv` that
|
||||
renames it; exit code 2 covers both kinds).
|
||||
|
||||
### report files — SARIF and Checkstyle for CI/IDE
|
||||
|
||||
`check` and `fix` accept `--report FILE`; the format is chosen by the file
|
||||
name suffix: `.sarif` → SARIF 2.1.0 (single run, `%SRCROOT%`-relative
|
||||
artifact URIs, `properties.autoFixable`), `.xml` → Checkstyle XML
|
||||
(`source="jmove.<rule>"` with `/` mapped to `.`). Unknown suffixes fail
|
||||
before any work with `INVALID_ARGUMENT`. The report mirrors what the run
|
||||
already computed (fix: candidates with their applied/manual status; dry-run
|
||||
included), stdout and exit codes stay as without `--report`, and clean runs
|
||||
write valid *empty* documents. Rule ids: the four fix rules above, plus
|
||||
`broken-import` and `java/class-name-mismatch`.
|
||||
|
||||
### fix — auto-repair import problems
|
||||
|
||||
```
|
||||
jmove fix [--root DIR] [--rule ID] [--dry-run] [--json]
|
||||
jmove fix [--root DIR] [--rule ID] [--dry-run] [--json] [--report FILE]
|
||||
```
|
||||
|
||||
Runs the deterministic rules over the whole project and applies the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue