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

[SCM] Debian package checker branch, master, updated. 1.24.4-57-gcfdcbc8



The following commit has been merged in the master branch:
commit e15330223d73f312adaccc26a10d1e4a596a4235
Author: Jordà Polo <jorda@ettin.org>
Date:   Sun Aug 17 18:04:46 2008 +0200

    Allow a more fine-grained selection of tags
    
    A new --display-level option has been added to allow a more fine-grained
    selection of tags by Severity/Certainty levels.
    
    Severity serious, important, normal (possible and certain only), and minor
    (certain only) are selected by default. It is possible to adapt this selection
    adding, removing or setting the desired levels, specifying a severity, a
    certainty, or both. Examples:
    
    Check serious/certain tags only:
     $ lintian --display-level =serious/certain
    
    Remove all wild-guess tags and add minor/possible tags to the default set:
     $ lintian --display-level -wild-guess --display-level +minor/possible

diff --git a/frontend/lintian b/frontend/lintian
index 27b7a48..cc1de30 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -49,7 +49,6 @@ our $quiet = 0;			#flag for -q|--quiet switch
 my @debug;
 my $check_everything = 0;	#flag for -a|--all switch
 my $lintian_info = 0;		#flag for -i|--info switch
-our $display_infotags = 0;	#flag for -I|--display-info switch
 our $display_experimentaltags = 0; #flag for -E|--display-experimental switch
 my $unpack_level = undef;	#flag for -l|--unpack-level switch
 our $no_override = 0;		#flag for -o|--no-override switch
@@ -71,6 +70,10 @@ our $LINTIAN_ROOT;		#location of the lintian modules
 
 my $experimental_output_opts = undef;
 
+my @severities = qw(wishlist minor normal important serious);
+my @certainties = qw(wild-guess possible certain);
+my %display_level = ();
+
 my @packages;
 
 my $action;
@@ -144,6 +147,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)
+    -L, --display-level       display tags with the specified level
     -l X, --unpack-level X    set default unpack level to X
     -o, --no-override         ignore overrides
     --show-overrides          output tags that have been overriden
@@ -272,6 +276,33 @@ sub record_pkgmode {
     $pkg_mode = 'u' if $_[0] eq 'udeb';
 }
 
+# Clears current display level information, disabling all severities and
+# certainties
+sub reset_display_level {
+    foreach my $s (@severities) {
+	foreach my $c (@certainties) {
+	    $display_level{$s}{$c} = 0;
+	}
+    }
+}
+
+# Parse input display level to enable (val 1) or disable (val 0) it
+# accordingly
+sub set_display_level {
+    my ($level, $val) = @_;
+    my $severity = join("|", @severities);
+    my $certainty = join("|", @certainties);
+    if ($level =~ m/^($severity)$/) {
+	map { $display_level{$1}{$_} = $val } @certainties;
+    } elsif ($level =~ m/^($certainty)$/) {
+	map { $display_level{$_}{$1} = $val } @severities;
+    } elsif ($level =~ m/^($severity)\/($certainty)$/) {
+	$display_level{$1}{$2} = $val;
+    } else {
+	die "invalid argument to --display-level: $level\n";
+    }
+}
+
 # Hash used to process commandline options
 my %opthash = (			# ------------------ actions
 	       "setup-lab|S" => \&record_action,
@@ -295,8 +326,9 @@ my %opthash = (			# ------------------ actions
 
 	       # ------------------ behaviour options
 	       "info|i" => \$lintian_info,
-	       "display-info|I" => \$display_infotags,
+	       "display-info|I" => \&display_infotags,
 	       "display-experimental|E" => \$display_experimentaltags,
+	       "display-level|L=s" => \&record_display_level,
 	       "unpack-level|l=i" => \$unpack_level,
 	       "no-override|o" => \$no_override,
 	       "show-overrides" => \$show_overrides,
@@ -330,6 +362,14 @@ my %opthash = (			# ------------------ actions
 	       "exp-output:s" => \$experimental_output_opts,
 	      );
 
+# init display level settings
+reset_display_level();
+set_display_level('serious', 1);
+set_display_level('important', 1);
+set_display_level('normal/certain', 1);
+set_display_level('normal/possible', 1);
+set_display_level('minor/certain', 1);
+
 # init commandline parser
 Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
 
@@ -372,6 +412,26 @@ if (($check_everything or $packages_file) and $#ARGV+1 > 0) {
     undef $packages_file;
 }
 
+sub record_display_level {
+    my $level = $_[1];
+    if ($level =~ m/^\+(.+)/) {
+	set_display_level($1, 1);
+    } elsif ($level =~ m/^\-(.+)/) {
+	set_display_level($1, 0);
+    } elsif ($level =~ m/^\=?(.+)/) {
+	reset_display_level();
+	set_display_level($1, 1);
+    } else {
+	die "invalid argument to --display-level: $level\n";
+    }
+}
+
+sub display_infotags {
+    foreach my $s (@severities) {
+	set_display_level($s, 1);
+    }
+}
+
 # check permitted values for --color
 if ($color and $color !~ /^(never|always|auto|html)$/) {
     die "invalid argument to --color: $color\n";
@@ -1021,9 +1081,9 @@ if (defined $experimental_output_opts) {
     }
 }
 
-$Tags::show_info = $display_infotags;
 $Tags::show_experimental = $display_experimentaltags;
 $Tags::show_overrides = $show_overrides;
+%Tags::display_level = %display_level;
 $Tags::color = $color;
 %Tags::only_issue_tags = map { $_ => 1 } (split(/,/, $check_tags))
     if defined $check_tags;
@@ -1150,8 +1210,7 @@ if ($action eq 'check') {
 		    || ($check_info{$c}->{'abbrev'}
 			&& $dont_check{$check_info{$c}->{'abbrev'}})) {
 		    #user requested not to run this check
-		} elsif ($Tags::experimental_class
-			 && $check_info{$c}->{'requested-tags'} == 0) {
+		} elsif ($check_info{$c}->{'requested-tags'} == 0) {
 		    #no need to run this check, no tags will be issued
 		} else {
 		    $checks{$c} = 1;
diff --git a/lib/Tags.pm b/lib/Tags.pm
index 6676252..7d58752 100644
--- a/lib/Tags.pm
+++ b/lib/Tags.pm
@@ -38,14 +38,11 @@ use Term::ANSIColor;
 # configuration variables and defaults
 our $verbose = $::verbose;
 our $debug = $::debug;
-our $show_info = 0;
 our $show_experimental = 0;
 our $show_overrides = 0;
-our $experimental_class = 0;
-our $min_severity = 'normal';
-our $min_certainty = 'possible';
 our $output_formatter = \&print_tag;
 our $color = 'never';
+our %display_level;
 our %only_issue_tags;
 
 # The master hash with all tag info. Key is the tag name, value another hash
@@ -309,26 +306,16 @@ sub print_tag {
 # of requested tags (returns 1) or not (returns 0).
 sub check_level {
     my ( $tag_info ) = @_;
-    my $sev = $severity_level{$tag_info->{severity}};
-    my $cert = $certainty_level{$tag_info->{certainty}};
-    my $min_sev = $severity_level{$min_severity};
-    my $min_cert = $certainty_level{$min_certainty};
-    return 0 if $sev < $min_sev || $cert < $min_cert;
-    return 1;
+    my $severity = $tag_info->{severity};
+    my $certainty = $tag_info->{certainty};
+    return $display_level{$severity}{$certainty};
 }
 
 sub skip_print {
     my ( $tag_info ) = @_;
-
     return 1 if exists $tag_info->{experimental} && !$show_experimental;
     return 1 if $tag_info->{overridden}{override} && !$show_overrides;
-
-    if ($experimental_class) {
-        return 1 if not check_level( $tag_info );
-    } else {
-        return 1 if $tag_info->{type} eq "info" && !$show_info;
-    }
-
+    return 1 if not check_level( $tag_info );
     return 0;
 }
 

-- 
Debian package checker


Reply to: