#!/usr/bin/perl

use strict;
use warnings;
use JSON;
use File::Slurp;
my $json = JSON->new;
my $file = read_file('coveralls.json', { binmode => ':utf8' });
my $rv = $json->decode($file);
my $sources = $rv->{'source_files'};
print STDERR join ", ", keys %{$rv}, "\n";
foreach my $source (sort {
	$a->{'name'} cmp $b->{'name'}
} @{$sources})
{
	my $sum = 0;
	my $undefs = 0;
	my $coverages = $source->{'coverage'};
	foreach my $coverage (@{$coverages})
	{
		if (defined $coverage)
		{ $sum += $coverage }
		else { $undefs ++; }
	}
	if ($sum > 0)
	{
		print STDERR $source->{'name'};
		print STDERR " [sum: $sum]";
		print STDERR " [undefs: $undefs]";
		print STDERR "\n";
	}
}
