[SCM] Debian package checker branch, master, updated. 1.24.4-57-gcfdcbc8
The following commit has been merged in the master branch:
commit f0d33d7c1a58c61fe00007cd91a5de68d28c2bf1
Author: Jordà Polo <jorda@ettin.org>
Date: Sun Aug 17 19:43:31 2008 +0200
Simplify Severity/Certainty mappings
Severity/Certainty values are now mapped as a hash instead of using a table.
Change suggested by Marc 'HE' Brockschmidt since the previous approach was a
bit complex.
diff --git a/lib/Tags.pm b/lib/Tags.pm
index d1f890f..ddf706b 100644
--- a/lib/Tags.pm
+++ b/lib/Tags.pm
@@ -78,18 +78,13 @@ my $current;
our @severity_list = qw(wishlist minor normal important serious);
our @certainty_list = qw(wild-guess possible certain);
-my %severity_level;
-@severity_level{@severity_list} = (0 .. $#severity_list);
-my %certainty_level;
-@certainty_level{@certainty_list} = (0 .. $#certainty_list);
-
# Map Severity/Certainty levels to E|W|I codes.
-my @codes = (
- [ 'I', 'I', 'I' ], # wishlist (wild-guess, possible, certain)
- [ 'I', 'I', 'W' ], # minor
- [ 'I', 'W', 'W' ], # normal
- [ 'W', 'E', 'E' ], # important
- [ 'E', 'E', 'E' ], # serious
+my %codes = (
+ 'wishlist' => { 'wild-guess' => 'I', 'possible' => 'I', 'certain' => 'I' },
+ 'minor' => { 'wild-guess' => 'I', 'possible' => 'I', 'certain' => 'W' },
+ 'normal' => { 'wild-guess' => 'I', 'possible' => 'W', 'certain' => 'W' },
+ 'important' => { 'wild-guess' => 'W', 'possible' => 'E', 'certain' => 'E' },
+ 'serious' => { 'wild-guess' => 'E', 'possible' => 'E', 'certain' => 'E' },
);
my %colors = ( 'E' => 'red' , 'W' => 'yellow' , 'I' => 'cyan' );
@@ -214,16 +209,8 @@ sub get_tag_info {
# Returns the E|W|I code for a given tag.
sub get_tag_code {
- my ( $tag_info ) = @_;
- return get_tag_value($tag_info, \@codes);
-}
-
-# Returns the value in a Severity/Certainty mapping for a given tag.
-sub get_tag_value {
my ( $tag_info, $map ) = @_;
- my $sev = $tag_info->{severity};
- my $cer = $tag_info->{certainty};
- return $map->[$severity_level{$sev}][$certainty_level{$cer}];
+ return $codes{$tag_info->{severity}}{$tag_info->{certainty}};
}
# check if a certain tag has a override for the 'current' package
diff --git a/lib/Tags/LetterQualifier.pm b/lib/Tags/LetterQualifier.pm
index f2cd852..874ffcb 100644
--- a/lib/Tags/LetterQualifier.pm
+++ b/lib/Tags/LetterQualifier.pm
@@ -24,20 +24,60 @@ use warnings;
use Term::ANSIColor;
use Tags;
-my @codes = (
- [ 'W?', 'W ', 'W!' ], # wishlist (wild-guess, possible, certain)
- [ 'M?', 'M ', 'M!' ], # minor
- [ 'N?', 'N ', 'N!' ], # normal
- [ 'I?', 'I ', 'I!' ], # important
- [ 'S?', 'S ', 'S!' ], # serious
+my %codes = (
+ 'wishlist' => {
+ 'wild-guess' => 'W?',
+ 'possible' => 'W ',
+ 'certain' => 'W!'
+ },
+ 'minor' => {
+ 'wild-guess' => 'M?',
+ 'possible' => 'M ',
+ 'certain' => 'M!'
+ },
+ 'normal' => {
+ 'wild-guess' => 'N?',
+ 'possible' => 'N ',
+ 'certain' => 'N!'
+ },
+ 'important' => {
+ 'wild-guess' => 'I?',
+ 'possible' => 'I ',
+ 'certain' => 'I!'
+ },
+ 'serious' => {
+ 'wild-guess' => 'S?',
+ 'possible' => 'S ',
+ 'certain' => 'S!'
+ },
);
-my @colors = (
- [ 'green', 'green', 'cyan' ],
- [ 'green', 'cyan', 'yellow' ],
- [ 'cyan', 'yellow', 'yellow' ],
- [ 'yellow', 'red', 'red' ],
- [ 'yellow', 'red', 'magenta' ]
+my %colors = (
+ 'wishlist' => {
+ 'wild-guess' => 'green',
+ 'possible' => 'green',
+ 'certain' => 'cyan'
+ },
+ 'minor' => {
+ 'wild-guess' => 'green',
+ 'possible' => 'cyan',
+ 'certain' => 'yellow'
+ },
+ 'normal' => {
+ 'wild-guess' => 'cyan',
+ 'possible' => 'yellow',
+ 'certain' => 'yellow'
+ },
+ 'important' => {
+ 'wild-guess' => 'yellow',
+ 'possible' => 'red',
+ 'certain' => 'red'
+ },
+ 'serious' => {
+ 'wild-guess' => 'yellow',
+ 'possible' => 'red',
+ 'certain' => 'magenta'
+ },
);
sub print_tag {
@@ -46,7 +86,10 @@ sub print_tag {
my $code = Tags::get_tag_code($tag_info);
$code = 'X' if exists $tag_info->{experimental};
$code = 'O' if $tag_info->{overridden}{override};
- my $lq = Tags::get_tag_value($tag_info, \@codes);
+
+ my $sev = $tag_info->{severity};
+ my $cer = $tag_info->{certainty};
+ my $lq = $codes{$sev}{$cer};
my $pkg = $pkg_info->{pkg};
my $type = ($pkg_info->{type} ne 'binary') ? " $pkg_info->{type}" : '';
@@ -57,7 +100,7 @@ sub print_tag {
$extra = '' if $extra eq ' ';
if ($Tags::color eq 'always' || ($Tags::color eq 'auto' && -t STDOUT)) {
- my $color = Tags::get_tag_value($tag_info, \@colors);
+ my $color = $colors{$sev}{$cer};
$lq = colored($lq, $color);
$tag = colored($tag, $color);
}
--
Debian package checker
Reply to: