Subject: [PATCH] Initial support for --pedantic tags

From: Raphael Geissert <[email-masked]>
Date: Sat, 10 Jan 2009 17:35:32 -0600

Signed-off-by: Raphael Geissert <[email-masked]>
---
 frontend/lintian |    4 ++++
 lib/Tags.pm      |    8 +++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/frontend/lintian b/frontend/lintian
index ea4bc34..cb26a18 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -47,6 +47,7 @@ my @debug;
 my $check_everything = 0;	#flag for -a|--all switch
 my $lintian_info = 0;		#flag for -i|--info switch
 our $display_experimentaltags = 0; #flag for -E|--display-experimental switch
+our $display_pedantictags = 0;	#flag for --pedantic switch
 my $unpack_level = undef;	#flag for -l|--unpack-level switch
 our $no_override = 0;		#flag for -o|--no-override switch
 our $show_overrides = 0;	#flag for --show-overrides switch
@@ -145,6 +146,7 @@ Behaviour options:
     -i, --info                give detailed info about tags
     -I, --display-info        display "I:" tags (normally suppressed)
     -E, --display-experimental display "X:" tags (normally suppressed)
+    --pedantic                display "P:" tags (normally suppressed)
     -L, --display-level       display tags with the specified level
     --display-source X        restrict displayed tags by source
     -l X, --unpack-level X    set default unpack level to X
@@ -415,6 +417,7 @@ my %opthash = (			# ------------------ actions
 	       "info|i" => \$lintian_info,
 	       "display-info|I" => \&display_infotags,
 	       "display-experimental|E" => \$display_experimentaltags,
+	       "pedantic" => \$display_pedantictags,
 	       "display-level|L=s" => \&record_display_level,
 	       "display-source=s" => \&record_display_source,
 	       "unpack-level|l=i" => \$unpack_level,
@@ -680,6 +683,7 @@ shift(@l_secs);
 map { $_->{'script'} = 'lintian'; Tags::add_tag($_) } @l_secs;
 
 $Tags::show_experimental = $display_experimentaltags;
+$Tags::show_pedantic = $display_pedantictags;
 $Tags::show_overrides = $show_overrides;
 %Tags::display_level = %display_level;
 %Tags::display_source = %display_source;
diff --git a/lib/Tags.pm b/lib/Tags.pm
index 51f30c3..9b054c3 100644
--- a/lib/Tags.pm
+++ b/lib/Tags.pm
@@ -31,6 +31,7 @@ our @EXPORT = qw(tag);
 use Lintian::Output;
 
 # configuration variables and defaults
+our $show_pedantic = 0;
 our $show_experimental = 0;
 our $show_overrides = 0;
 our %display_level;
@@ -65,11 +66,12 @@ my %info;
 my $current;
 
 # Possible Severity: and Certainty: values, sorted from lowest to highest.
-our @severity_list = qw(wishlist minor normal important serious);
+our @severity_list = qw(pedantic wishlist minor normal important serious);
 our @certainty_list = qw(wild-guess possible certain);
 
 # Map Severity/Certainty levels to E|W|I codes.
 my %codes = (
+    'pedantic'  => { 'wild-guess' => 'P', 'possible' => 'P', 'certain' => 'P' },
     'wishlist'  => { 'wild-guess' => 'I', 'possible' => 'I', 'certain' => 'I' },
     'minor'     => { 'wild-guess' => 'I', 'possible' => 'I', 'certain' => 'W' },
     'normal'    => { 'wild-guess' => 'I', 'possible' => 'W', 'certain' => 'W' },
@@ -294,6 +296,9 @@ sub display_tag {
     my $certainty = $tag_info->{'certainty'};
     my $level = $display_level{$severity}{$certainty};
 
+    # Pedantic is just a pseudo severity, skip level checks
+    $level = 1 if ($severity eq 'pedantic' and $show_pedantic);
+
     $tag_info->{'display'} = $level;
     return $level if not keys %display_source;
 
@@ -307,6 +312,7 @@ sub display_tag {
 sub skip_print {
     my ( $tag_info ) = @_;
     return 1 if exists $tag_info->{experimental} && !$show_experimental;
+    return 1 if $tag_info->{severity} eq 'pedantic' && !$show_pedantic;
     return 1 if $tag_info->{overridden}{override} && !$show_overrides;
     return 1 if not display_tag( $tag_info );
     return 0;