Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright (c) 2026 Sebastian Pipping <sebastian@pipping.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see
# <http://www.gnu.org/licenses/>.
#
name: Enforce checkstyle-clean code

on:
pull_request:
push:
schedule:
- cron: '0 14 * * 5' # Every Friday 2pm
workflow_dispatch:

# Drop permissions to minimum for security
permissions:
contents: read

jobs:
checkstyle:
name: Enforce checkstyle-clean code
runs-on: ubuntu-24.04
steps:
- name: Install perltidy
run: |-
set -x
sudo apt-get update
sudo apt-get install --yes -V --no-install-recommends \
cpanminus

# NOTE: We install a pinned version to ensure robust CI
sudo cpanm --notest \
https://github.com/perltidy/perltidy/archive/refs/tags/20260705.01.tar.gz

- uses: actions/checkout@v7

- name: Enforce "make checkstyle"
run: |-
set -x
perltidy --version | grep -o 'v2.*'

MODE=full make checkstyle
4 changes: 2 additions & 2 deletions bin/fix.pl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ($)

if ($opt_fixinterp && defined($path) && $path ne "") {
$source =~ s/^#!.*perl.*\n/#!$path\n/
unless $source =~ @^#!/usr/bin/env perl$@;
unless $source =~ m{^#!/usr/bin/env perl$};
}

if ($opt_fixlibdir) {
Expand Down Expand Up @@ -135,7 +135,7 @@ ($)

if ($opt_fixinterp && defined($path) && $path ne "") {
$source =~ s/^#!.*python.*\n/#!$path\n/
unless $source =~ @^#!/usr/bin/env python3?$@;
unless $source =~ m{^#!/usr/bin/env python3?$};
}

return $source;
Expand Down
305 changes: 196 additions & 109 deletions bin/genhtml

Large diffs are not rendered by default.

50 changes: 27 additions & 23 deletions bin/geninfo
Original file line number Diff line number Diff line change
Expand Up @@ -884,15 +884,16 @@ sub add_worklist_entry
{
my ($self, $filename, $directory) = @_;
if (exists($self->[1]->{$filename})) {
lcovutil::ignorable_error($lcovutil::ERROR_USAGE,
"duplicate file $filename in both " .
$self->[1]->{$filename} .
" and $directory"
.
(lcovutil::is_ignored(
$lcovutil::ERROR_USAGE) ?
' (skip latter)' :
''));
lcovutil::ignorable_error(
$lcovutil::ERROR_USAGE,
"duplicate file $filename in both " .
$self->[1]->{$filename} .
" and $directory"
.
(
lcovutil::is_ignored($lcovutil::ERROR_USAGE)
? ' (skip latter)' :
''));
return;
}
$self->[1]->{$filename} = $directory;
Expand Down Expand Up @@ -1337,8 +1338,8 @@ sub gen_info(@)
@predicted =
sort({ $b->[1] <=> $a->[1] or $a->[2] cmp $b->[2] } @predicted);

lcovutil::info(scalar(@unknown) .
' (of ' . (scalar(@predicted) + scalar(@unknown)) .
lcovutil::info(scalar(@unknown) . ' (of ' .
(scalar(@predicted) + scalar(@unknown)) .
") files do not appear in \'--history\' profile.\n")
if (@unknown);
if (@predicted) {
Expand Down Expand Up @@ -1548,8 +1549,8 @@ sub gen_info(@)
$lcovutil::maxParallelism = 1;
if ($chunk->[0]) {
my $num = scalar(@{$chunk->[1]});
lcovutil::info(
"Processing $num file" . ($num == 1 ? '' : 's') .
lcovutil::info("Processing $num file" .
($num == 1 ? '' : 's') .
" from chunk 0 serially\n");
}
my $now = Time::HiRes::gettimeofday();
Expand Down Expand Up @@ -1663,8 +1664,9 @@ sub process_dafile($$$$)

# Try to find base directory automatically if requested by user
if ($lcovutil::rc_auto_base) {
$base_dir = find_base_from_source($base_dir,
[keys(%{$instr}), keys(%{$graph})]);
$base_dir =
find_base_from_source($base_dir,
[keys(%{$instr}), keys(%{$graph})]);
}

adjust_source_filenames($instr, $base_dir);
Expand Down Expand Up @@ -1767,8 +1769,9 @@ sub process_dafile($$$$)
# Skip files that are not mentioned in the graph file
if (!@matches) {
lcovutil::ignorable_error($lcovutil::ERROR_MISMATCH,
"cannot find an entry for " .
$gcov_file . " in $graph_file_extension file");
"cannot find an entry for " .
$gcov_file .
" in $graph_file_extension file");
unlink($gcov_file) unless $lcovutil::preserve_intermediates;
next;
}
Expand All @@ -1777,8 +1780,9 @@ sub process_dafile($$$$)
$source_filename = $matches[0];
} else {
# Try to solve the ambiguity
$source_filename = solve_ambiguous_match($gcov_file, \@matches,
\@gcov_content);
$source_filename =
solve_ambiguous_match($gcov_file, \@matches,
\@gcov_content);
}
$source_filename =
ReadCurrentSource::resolve_path($source_filename, 1);
Expand Down Expand Up @@ -2647,8 +2651,7 @@ sub intermediate_json_to_info($)
);
if ($lcovutil::opt_adjust_unexecuted_blocks) {
$count = 0;
} elsif (
lcovutil::warn_once("unexecuted block",
} elsif (lcovutil::warn_once("unexecuted block",
$ERROR_INCONSISTENT_DATA)
) {
lcovutil::ignorable_warning($ERROR_INCONSISTENT_DATA,
Expand Down Expand Up @@ -3180,8 +3183,9 @@ sub process_graphfile($$)

# Try to find base directory automatically if requested by user
if ($lcovutil::rc_auto_base) {
$base_dir = find_base_from_source($base_dir,
[keys(%{$instr}), keys(%{$graph})]);
$base_dir =
find_base_from_source($base_dir,
[keys(%{$instr}), keys(%{$graph})]);
}

adjust_source_filenames($instr, $base_dir);
Expand Down
29 changes: 17 additions & 12 deletions bin/lcov
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,14 @@ if (@ARGV &&
$reset)
) {
die("Extra parameter found: '" .
join(" ", @ARGV) .
"'\n" . "Use $tool_name --help to get usage information\n");
join(" ", @ARGV) . "'\n" .
"Use $tool_name --help to get usage information\n");
}

if (!@ARGV) {
if ($directory || $kernel_directory) {
die("--" . ($directory ? "directory" : "kernel-directory") .
die("--" .
($directory ? "directory" : "kernel-directory") .
" specified but no directories provided\n" .
"Use $tool_name --help to get usage information\n");
}
Expand All @@ -327,7 +328,8 @@ if (!@ARGV) {
[scalar(@intersect), '--intersect'],
[scalar(@difference), '--subtract'],
) {
die($d->[1] . " specified but no tracefiles provided\n" .
die($d->[1] .
" specified but no tracefiles provided\n" .
"Use $tool_name --help to get usage information\n")
if ($d->[0]);
}
Expand Down Expand Up @@ -404,7 +406,8 @@ eval {

info("Pruned result: retained " .
scalar(@$pruned) . " of " .
scalar(@$merged) . " files\n");
scalar(@$merged) .
" files\n");
my $file = InOutFile->out($output_filename);
my $hdl = $file->hdl();
print($hdl join("\n", @$pruned) . "\n");
Expand Down Expand Up @@ -595,7 +598,8 @@ sub check_options()
$i > 1) {
die("invalid command line:\n $0 " .
join(' ', @main::cmdArgs) .
"\nNeed " . ($i > 1 ? 'only ' : '') .
"\nNeed " .
($i > 1 ? 'only ' : '') .
"one of options -z, -c, -a, -e, -r, -l, --intersect, --subtract, or --summary\n"
. "Use $tool_name --help to get usage information\n");
}
Expand Down Expand Up @@ -894,8 +898,7 @@ sub lcov_geninfo(@)
}
push(@param, "--base-directory", $base_directory)
if $base_directory;
foreach (
split($lcovutil::split_char,
foreach (split($lcovutil::split_char,
join($lcovutil::split_char, @lcovutil::opt_ignore_errors))
) {
# pass only the 'ignore' options that geninfo understands
Expand Down Expand Up @@ -1605,14 +1608,15 @@ sub merge_traces($$)

my @data = AggregateTraces::find_from_glob(@ARGV);
info('.. found: ' .
scalar(@data) . " 'base' trace file" .
scalar(@data) .
" 'base' trace file" .
(1 == scalar(@data) ? '' : 's') . ".\n");
die("must specify at least one 'base' tracefile")
unless @data;
my @merge = AggregateTraces::find_from_glob(@$list);
info(' ' .
scalar(@merge) .
' file' . (1 == scalar(@merge) ? '' : 's') . ' to ' .
scalar(@merge) . ' file' .
(1 == scalar(@merge) ? '' : 's') . ' to ' .
($op == TraceInfo::INTERSECT ? 'intersect' : 'subtract') . ".\n");

my $srcReader = ReadCurrentSource->new();
Expand Down Expand Up @@ -2022,7 +2026,8 @@ sub setup_gkv()
# Check /proc
$dir = defined($gcov_dir) ? $gcov_dir : $proc_dir;
if (check_gkv_proc($dir)) {
info("Found " . $GKV_NAME[$GKV_PROC] .
info("Found " .
$GKV_NAME[$GKV_PROC] .
" gcov kernel support at $dir\n");
return ($GKV_PROC, $dir);
}
Expand Down
9 changes: 6 additions & 3 deletions bin/perl2lcov
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ foreach my $db_path (@ARGV) {
) {
next unless defined($c->[1]);
foreach my $line ($c->[1]->items) {
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
'found ' . $c->[0] .
lcovutil::ignorable_error(
$lcovutil::ERROR_INCONSISTENT_DATA,
'found ' .
$c->[0] .
" coverpoint on $line but no lineCov there"
) unless defined($stmts->location($line));
}
Expand Down Expand Up @@ -414,7 +416,8 @@ foreach my $db_path (@ARGV) {
--$last;
}
lcovutil::info(1,
"resetting " . $func->name() .
"resetting " .
$func->name() .
" end line to $last (from $end)\n");
$func->set_end_line($last);

Expand Down
Loading