Re: [PATCH v3] checkpatch: add --json output mode

Joe Perches
2026-04-26T09:48:01Z

On Sat, 2026-04-25 at 16:04 -0400, Sasha Levin wrote:

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2403,6 +2426,24 @@ sub report_dump {
> our @report;
> }
>
> +sub json_print_result {
> + my ($filename, $total_errors, $total_warnings, $total_checks,
> + $total_lines, $issues, $used_types, $ignored_types) = @_;
> + my %result = (
> + filename => $filename,
> + total_errors => $total_errors,
> + total_warnings => $total_warnings,
> + total_checks => $total_checks,
> + total_lines => $total_lines,
> + issues => $issues,
> + );
> + $result{used_types} = $used_types if (defined $used_types);
> + $result{ignored_types} = $ignored_types if (defined $ignored_types);
> + my $json_encoder = JSON::PP->new->canonical->utf8;

Maybe canonical isn't great as it outputs keys in alphabetic order.
The output may be more sensible in the defined order.