Messages in this thread |  | | Subject | Re: [PATCH] checkpatch: add --json output mode | | From | Joe Perches <> | | Date | Mon, 06 Apr 2026 13:41:52 -0700 |
| |
On Mon, 2026-04-06 at 13:00 -0400, Sasha Levin wrote: > Add a --json flag to checkpatch.pl that emits structured JSON output, > making results machine-parseable for CI systems, IDE integrations, and > AI-assisted code review tools.
Seems a reasonable idea but perhaps can be improved
> @@ -1372,7 +1376,7 @@ for my $filename (@ARGV) { > $file = $oldfile if ($is_git_file); > } > > -if (!$quiet) { > +if (!$quiet && !$json) { > hash_show_words(\%use_type, "Used"); > hash_show_words(\%ignore_type, "Ignored");
Maybe keep but update?
> @@ -7791,18 +7836,33 @@ sub process { > # If we have no input at all, then there is nothing to report on > # so just keep quiet. > if ($#rawlines == -1) { > + if ($json) { > + print '{"filename":"' . json_escape($filename) . > + '","total_errors":0,"total_warnings":0,' .
poor formatting for that trailing ". please separate by content blocks.
> + '"total_checks":0,"total_lines":0,"issues":[]}' . "\n"; > + }
I'd prefer to keep the print() style used elsewhere and perhaps the JSON:PP module should be used here.
|  |