Re: [PATCH 1/1] scripts: add a graph generator based on checkpatch reports
> On 23 November 2014 at 21:27 Joe Perches wrote: > > > On Sat, 2014-11-22 at 21:56 +0100, Fabian Frederick wrote: > > This script generates a graph based on errors/warnings/checks detected > > by checkpatch -f recursively on each files of a directory. > > Results are grouped by subfolders and pushed in gnuplot datasets. > > Why is this useful? > > Ingo's badly named script does something similar: > http://people.redhat.com/mingo/x86.git/code-quality > > just without the plots. > > btw: this line: > > $files = `find $statdir -name "*.c"`; > > should probably be > > $files = `git ls-files -- "$statdir/*.[ch]"`; > This script was meant for reporting so it's just useful because of the graphs and the fact it can do all in one operation. Most of all, when someone does a talk and shows up some graph, it would be both easier and valid to tell it's using scripts/checkstat on kernel x.y rather than sparse operations someone won't easily reproduce. I don't think using directly git operations would be a good thing. This script could be used directly downloading tar.gz without it. (Of course Git could be bring nice options in future versions :)). Regards, Fabian -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/1] scripts: add a graph generator based on checkpatch reports
On 23 November 2014 at 21:27 Joe Perches j...@perches.com wrote: On Sat, 2014-11-22 at 21:56 +0100, Fabian Frederick wrote: This script generates a graph based on errors/warnings/checks detected by checkpatch -f recursively on each files of a directory. Results are grouped by subfolders and pushed in gnuplot datasets. Why is this useful? Ingo's badly named script does something similar: http://people.redhat.com/mingo/x86.git/code-quality just without the plots. btw: this line: $files = `find $statdir -name *.c`; should probably be $files = `git ls-files -- $statdir/*.[ch]`; This script was meant for reporting so it's just useful because of the graphs and the fact it can do all in one operation. Most of all, when someone does a talk and shows up some graph, it would be both easier and valid to tell it's using scripts/checkstat on kernel x.y rather than sparse operations someone won't easily reproduce. I don't think using directly git operations would be a good thing. This script could be used directly downloading tar.gz without it. (Of course Git could be bring nice options in future versions :)). Regards, Fabian -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/1] scripts: add a graph generator based on checkpatch reports
On Sat, 2014-11-22 at 21:56 +0100, Fabian Frederick wrote: > This script generates a graph based on errors/warnings/checks detected > by checkpatch -f recursively on each files of a directory. > Results are grouped by subfolders and pushed in gnuplot datasets. Why is this useful? Ingo's badly named script does something similar: http://people.redhat.com/mingo/x86.git/code-quality just without the plots. btw: this line: $files = `find $statdir -name "*.c"`; should probably be $files = `git ls-files -- "$statdir/*.[ch]"`; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/1] scripts: add a graph generator based on checkpatch reports
On Sat, 2014-11-22 at 21:56 +0100, Fabian Frederick wrote: This script generates a graph based on errors/warnings/checks detected by checkpatch -f recursively on each files of a directory. Results are grouped by subfolders and pushed in gnuplot datasets. Why is this useful? Ingo's badly named script does something similar: http://people.redhat.com/mingo/x86.git/code-quality just without the plots. btw: this line: $files = `find $statdir -name *.c`; should probably be $files = `git ls-files -- $statdir/*.[ch]`; -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] scripts: add a graph generator based on checkpatch reports
This script generates a graph based on errors/warnings/checks detected by checkpatch -f recursively on each files of a directory. Results are grouped by subfolders and pushed in gnuplot datasets. By default checkstat.png is generated with an histogram. This script should always be called from kernel source root. eg scripts/checkstat.pl fs Cc: Joe Perches Cc: Linus Torvalds Cc: Andrew Morton Signed-off-by: Fabian Frederick --- scripts/checkstat.pl | 120 +++ 1 file changed, 120 insertions(+) create mode 100755 scripts/checkstat.pl diff --git a/scripts/checkstat.pl b/scripts/checkstat.pl new file mode 100755 index 000..8b7d451 --- /dev/null +++ b/scripts/checkstat.pl @@ -0,0 +1,120 @@ +#!/usr/bin/perl +# (c) 2014, Fabian Frederick (f...@skynet.be) +# +# Based on scripts/checkpatch.pl +# +# This script generates a graph based on errors/warnings/checks detected +# by checkpatch -f recursively on each files of a directory. +# Results are grouped by subfolders. +# + +use strict; +use Getopt::Long; +use File::Basename; +use Chart::Gnuplot; + +my $P = $0; +my $statdir = '.'; +my $files; +my @cfiles = (); +my %stat; +my %stats; +my $report; +my $currentdir = ''; + +my $checkpatch = "scripts/checkpatch.pl"; +my $output = "checkstat.png"; +my @dontcheck = qw/fs\/nls/; + +sub help { + my $text = << "EOM"; +Usage: $P [OPTION] [DIRECTORY] + +This script should always be called from kernel source root. + +Options: + --outputname of generated png graph. +EOM + my $std=shift; + if ($std == 1) { + print STDERR $text; + } else { + print $text; + } + exit; +} + +GetOptions( + 'h|help'=> \, + 'output=s' => \$output +); + +if ($#ARGV >= 0) { + $statdir = @ARGV[0]; +} + +my $graphreport = Chart::Gnuplot->new( + output => $output, + yrange => [0, '*'], + imagesize => '3, 2', + xtics => { + rotate => '90 right', + }, + bmargin => 15, + title => 'Linux Kernel: checkstat - Date: `date`' +); + +$files = `find $statdir -name "*.c"`; +@cfiles = split('\n', $files); + +#Execute checkpatch on each file and store results +foreach my $file (@cfiles) { + print "checkpatch: $file: "; + $currentdir = dirname($file); + + if (not grep(/^$currentdir$/, @dontcheck)){ + $report = `$checkpatch -f --terse $file | tail -n 1`; + + if ($currentdir ne $statdir) { + $currentdir =~ s/$statdir\///; + $currentdir =~ s/\/(.*)//; + $currentdir = $statdir."/".$currentdir; + } + print "adding to ".$currentdir." stats\n"; + my $i = 0; + + foreach my $stat_type ("errors", "warnings", "checks") { + $report =~ m/(\d+)\s$stat_type/; + $stat{$currentdir}[$i++] += $1; + $stats{$stat_type}{$currentdir} += $1; + } + } else { + print "File in dontcheck list ...\n"; + } +} + +my @columns=(); +my %colors=( + errors => 'red', + warnings => 'orange', + checks => 'green' +); + +#Reorder and push data in datasets. +foreach my $stat_type (keys %stats) { + my @xdir=(); + + foreach my $dir (sort keys %{$stats{$stat_type}}){ + push @xdir, [$dir, $stats{$stat_type}{$dir}]; + } + push @columns, Chart::Gnuplot::DataSet->new( + points => \@xdir, + title => $stat_type, + color => $colors{$stat_type}, + fill => {density => 1}, + style => "histograms", + ); +} + +$graphreport->plot2d(@columns); +print("graph generated: $output\n"); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/1] scripts: add a graph generator based on checkpatch reports
This script generates a graph based on errors/warnings/checks detected by checkpatch -f recursively on each files of a directory. Results are grouped by subfolders and pushed in gnuplot datasets. By default checkstat.png is generated with an histogram. This script should always be called from kernel source root. eg scripts/checkstat.pl fs Cc: Joe Perches j...@perches.com Cc: Linus Torvalds torva...@linux-foundation.org Cc: Andrew Morton a...@linux-foundation.org Signed-off-by: Fabian Frederick f...@skynet.be --- scripts/checkstat.pl | 120 +++ 1 file changed, 120 insertions(+) create mode 100755 scripts/checkstat.pl diff --git a/scripts/checkstat.pl b/scripts/checkstat.pl new file mode 100755 index 000..8b7d451 --- /dev/null +++ b/scripts/checkstat.pl @@ -0,0 +1,120 @@ +#!/usr/bin/perl +# (c) 2014, Fabian Frederick (f...@skynet.be) +# +# Based on scripts/checkpatch.pl +# +# This script generates a graph based on errors/warnings/checks detected +# by checkpatch -f recursively on each files of a directory. +# Results are grouped by subfolders. +# + +use strict; +use Getopt::Long; +use File::Basename; +use Chart::Gnuplot; + +my $P = $0; +my $statdir = '.'; +my $files; +my @cfiles = (); +my %stat; +my %stats; +my $report; +my $currentdir = ''; + +my $checkpatch = scripts/checkpatch.pl; +my $output = checkstat.png; +my @dontcheck = qw/fs\/nls/; + +sub help { + my $text = EOM; +Usage: $P [OPTION] [DIRECTORY] + +This script should always be called from kernel source root. + +Options: + --outputname of generated png graph. +EOM + my $std=shift; + if ($std == 1) { + print STDERR $text; + } else { + print $text; + } + exit; +} + +GetOptions( + 'h|help'= \help, + 'output=s' = \$output +); + +if ($#ARGV = 0) { + $statdir = @ARGV[0]; +} + +my $graphreport = Chart::Gnuplot-new( + output = $output, + yrange = [0, '*'], + imagesize = '3, 2', + xtics = { + rotate = '90 right', + }, + bmargin = 15, + title = 'Linux Kernel: checkstat - Date: `date`' +); + +$files = `find $statdir -name *.c`; +@cfiles = split('\n', $files); + +#Execute checkpatch on each file and store results +foreach my $file (@cfiles) { + print checkpatch: $file: ; + $currentdir = dirname($file); + + if (not grep(/^$currentdir$/, @dontcheck)){ + $report = `$checkpatch -f --terse $file | tail -n 1`; + + if ($currentdir ne $statdir) { + $currentdir =~ s/$statdir\///; + $currentdir =~ s/\/(.*)//; + $currentdir = $statdir./.$currentdir; + } + print adding to .$currentdir. stats\n; + my $i = 0; + + foreach my $stat_type (errors, warnings, checks) { + $report =~ m/(\d+)\s$stat_type/; + $stat{$currentdir}[$i++] += $1; + $stats{$stat_type}{$currentdir} += $1; + } + } else { + print File in dontcheck list ...\n; + } +} + +my @columns=(); +my %colors=( + errors = 'red', + warnings = 'orange', + checks = 'green' +); + +#Reorder and push data in datasets. +foreach my $stat_type (keys %stats) { + my @xdir=(); + + foreach my $dir (sort keys %{$stats{$stat_type}}){ + push @xdir, [$dir, $stats{$stat_type}{$dir}]; + } + push @columns, Chart::Gnuplot::DataSet-new( + points = \@xdir, + title = $stat_type, + color = $colors{$stat_type}, + fill = {density = 1}, + style = histograms, + ); +} + +$graphreport-plot2d(@columns); +print(graph generated: $output\n); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/