[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.2.13-33-g804bb7a



The following commit has been merged in the master branch:
commit 804bb7a67c34f5c0df919aa9d265f86514ec7bca
Author: Jordà Polo <jorda@ettin.org>
Date:   Sat Aug 8 23:02:09 2009 +0200

    Move tag statistics code to html_reports
    
    This is the first step to integrate graph generation into html_reports. Both
    tags.tmpl and tags-severity.tmpl included code to get tag-specific statistics
    (number of tags, overrides and packages). Even though it is simple, we need to
    do it again in html_reports anyway in order to keep the record of previous
    values. Removing the duplicate code altogether seems like a good idea.
    
    * reporting/html_reports:
      + [JP] Accumulate tag-specific statistics in a new variable, and pass it
        to the appropriate templates.
    * reporting/templates/tags{,-severity}.tmpl:
      + [JP] Remove duplicate code to calculate tag statistics.

diff --git a/debian/changelog b/debian/changelog
index 96cef6a..ebc5654 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -60,6 +60,12 @@ lintian (2.2.14) UNRELEASED; urgency=low
   * lib/Spelling.pm:
     + [RA] Add spelling correction for precedence.
 
+  * reporting/html_reports:
+    + [JP] Accumulate tag-specific statistics in a new variable, and pass it
+      to the appropriate templates.
+  * reporting/templates/tags{,-severity}.tmpl:
+    + [JP] Remove duplicate code to calculate tag statistics.
+
  -- Frank Lichtenheld <djpig@debian.org>  Sun, 12 Jul 2009 12:57:44 +0200
 
 lintian (2.2.13) unstable; urgency=low
diff --git a/reporting/html_reports b/reporting/html_reports
index beef445..30054b7 100755
--- a/reporting/html_reports
+++ b/reporting/html_reports
@@ -147,12 +147,17 @@ for my $image (qw/ico.png l.png logo-small.png/) {
         or die "cannot copy images/$image to $HTML_TMP_DIR: $!\n";
 }
 
-# This variable will accumulate statistics.  For tags: errors, warnings,
+# %statistics accumulates global statistics.  For tags: errors, warnings,
 # experimental, overridden, and info are the keys holding the count of tags of
 # that sort.  For packages: binary, udeb, and source are the number of
 # packages of each type with Lintian errors or warnings.  For maintainers:
 # maintainers is the number of maintainers with Lintian errors or warnings.
-my %statistics;
+#
+# %tag_statistics holds a hash of tag-specific statistics.  Each tag name is a
+# key, and its value is a hash with the following keys: count and overrides
+# (number of times the tag has been detected and overriden, respectively), and
+# packages (number of packages with at least one such tag).
+my (%statistics, %tag_statistics);
 
 # %by_maint holds a hash of maintainer names to packages and tags.  Each
 # maintainer is a key.  The value is a hash of package names to hashes.  Each
@@ -443,13 +448,19 @@ for my $tag (sort keys %by_tag) {
     } else {
         $description = "    <p>Can't find description of tag $tag.</p>";
     }
+    my ($count, $overrides) = (0, 0);
+    my %seen;
     my $code = 'O';
     foreach (@{$by_tag{$tag}}) {
         if ($_->{code} ne 'O') {
             $code = $_->{code};
-            last;
+            $count++;
+            $seen{$_->{xref}}++;
+        } else {
+            $overrides++;
         }
     }
+
     my %data = (
         description => $description,
         tag         => html_quote ($tag),
@@ -457,11 +468,16 @@ for my $tag (sort keys %by_tag) {
         tags        => $by_tag{$tag},
     );
     output_template ("tags/$tag.html", $templates{tag}, \%data);
+
+    $tag_statistics{$tag}{'count'} = $count;
+    $tag_statistics{$tag}{'overrides'} = $overrides;
+    $tag_statistics{$tag}{'packages'} = scalar keys %seen;
 }
 
 # Create the general tag indices.
 %data = (
     tags      => \%by_tag,
+    stats     => \%tag_statistics,
 );
 output_template ('tags.html', $templates{tags}, \%data);
 output_template ('tags-severity.html', $templates{'tags-severity'}, \%data);
diff --git a/reporting/templates/tags-severity.tmpl b/reporting/templates/tags-severity.tmpl
index d19415a..a4d45fc 100644
--- a/reporting/templates/tags-severity.tmpl
+++ b/reporting/templates/tags-severity.tmpl
@@ -16,23 +16,15 @@
                 my ($first) = @{ $tags{$tag} };
                 next unless $first->{severity} eq $severity;
                 next unless $first->{certainty} eq $certainty;
-                my ($count, $overrides) = (0, 0);
-                my %seen;
-                for my $info (@{ $tags{$tag} }) {
-                    if ($info->{code} eq 'O') {
-                        $overrides++;
-                    } else {
-                        $count++;
-                        $seen{$info->{xref}}++;
-                    }
-                }
-                my $packages = scalar keys %seen;
                 unless ($heading) {
                     $OUT .= "  <h2>Severity: $severity,";
                     $OUT .= " Certainty: $certainty</h2>\n\n";
                     $OUT .= "  <ul>\n";
                     $heading = 1;
                 }
+                my $packages = $stats{$tag}{'packages'};
+                my $count = $stats{$tag}{'count'};
+                my $overrides = $stats{$tag}{'overrides'};
                 $OUT .= qq(    <li><a href="tags/$tag.html">$tag</a>)
                     . " ($packages packages, $count tags, plus $overrides"
                     . " overrides)</li>\n";
diff --git a/reporting/templates/tags.tmpl b/reporting/templates/tags.tmpl
index af8fe7d..1472a77 100644
--- a/reporting/templates/tags.tmpl
+++ b/reporting/templates/tags.tmpl
@@ -9,18 +9,10 @@
 
   <ul>
 {
-    for my $tag (sort keys %tags) {
-        my ($count, $overrides) = (0, 0);
-        my %seen;
-        for my $info (@{ $tags{$tag} }) {
-            if ($info->{code} eq 'O') {
-                $overrides++;
-            } else {
-                $count++;
-                $seen{$info->{xref}}++;
-            }
-        }
-        my $packages = scalar keys %seen;
+    for my $tag (sort keys %stats) {
+        my $packages = $stats{$tag}{'packages'};
+        my $count = $stats{$tag}{'count'};
+        my $overrides = $stats{$tag}{'overrides'};
         $OUT .= qq(    <li><a href="tags/$tag.html">$tag</a>)
             . " ($packages packages, $count tags, plus $overrides overrides)"
             . "</li>\n";

-- 
Debian package checker


Reply to: