| Lintian::Tags(3) | Debian Package Checker | Lintian::Tags(3) |
Lintian::Tags - Manipulate and output Lintian tags
my $tags = Lintian::Tags->new;
my $proc = Lintian::Processable::Package->new ('/path/to/file');
$tags->file_start ($proc);
$tags->file_overrides ('/path/to/an/overrides-file');
$tags->tag ('lintian-tag', 'extra tag information');
tag ('other-lintian-tag', 'with some extra data');
tag ('third-lintian-tag'); # with no extra).
my %overrides = $tags->overrides ($proc);
my %stats = $tags->statistics;
if ($tags->displayed ('lintian-tag')) {
# do something if that tag would be displayed...
}
This module stores metadata about Lintian tags, stores configuration about which tags should be displayed, handles displaying tags if appropriate, and stores cumulative statistics about what tags have been seen. It also accepts override information and determines whether a tag has been overridden, keeping override statistics. Finally, it supports answering metadata questions about Lintian tags, such as what references Lintian has for that tag.
Each Lintian::Tags object has its own tag list, file list, and associated statistics. Separate Lintian::Tags objects can be maintained and used independently. However, as a convenience for Lintian's most typical use case and for backward compatibility, the first created Lintian::Tags object is maintained as a global default. The tag() method can be called as a global function instead of a method, in which case it will act on that global default Lintian::Tags object.
This method can be called either as a class method (which is exported by the Lintian::Tags module) or as an instance method. If called as a class method, it uses the first-constructed Lintian::Tags object as its underlying object.
This method throws an exception if it is called without file_start() being called first or if an attempt is made to issue an unknown tag.
$tags->display('=', '>=', 'important');
turns off display of all tags and then enables display of any tag (with any certainty) of severity important or higher.
$tags->display('+', '>', 'normal', 'possible');
adds to the current configuration display of all tags with a severity higher than normal and a certainty higher than possible (so important/certain and serious/certain).
$tags->display('-', '=', 'minor', 'possible');
turns off display of tags of severity minor and certainty possible.
This method throws an exception on errors, such as an unknown severity or certainty or an impossible constraint (like "> serious").
This method throws an exception if the file being added was already added earlier.
file_start() must be called before this method. This method throws an exception if there is no current file and calls fail() if the override file cannot be opened.
This does two things. First it emits "unused-override" tags for all unused overrides. Secondly, it calls Lintian::Output::print_end_pkg to mark the end of the package.
Note that this method is called by file_start if it detects another entry is already active.
my $overrides = $tags->overrides('/some/file');
print "$overrides->{'some-tag'}{''}\n";
will print out the number of tags that matched a general override for the tag some-tag, regardless of what extra data was associated with it.
The per-file statistics has a set of hashes of keys to times seen in tags: tag names (the "tags" key), severities (the "severity" key), certainties (the "certainty" key), and tag codes (the "types" key). It also has an "overrides" key which has as its value another hash with those same four keys, which keeps statistics on overridden tags (not included in the regular counts).
Originally written by Russ Allbery <rra@debian.org> for Lintian.
| 2019-05-26 | Lintian v2.15.0 |