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

[SCM] Debian package checker branch, master, updated. 2.5.10-142-g8dda42d



The following commit has been merged in the master branch:
commit 8dda42d2799bea70ac8f77f7b3d905a961cd3b1b
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Sep 14 10:22:30 2012 +0200

    c/*: Be better at avoiding F-P spelling errors with pkg refs
    
    Instead of just using the package name, collect all package names in
    the group.  On top of this, also split the names on "-" and ignore the
    individual parts.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/binaries b/checks/binaries
index 28edbd7..2c0158c 100644
--- a/checks/binaries
+++ b/checks/binaries
@@ -85,7 +85,7 @@ our $HARDENING = Lintian::Data->new ('binaries/hardening-tags', qr/\s*\|\|\s*/o,
 
 sub run {
 
-my ($pkg, $type, $info, $proc) = @_;
+my ($pkg, $type, $info, $proc, $group) = @_;
 
 my $arch;
 my $multiarch;
@@ -261,7 +261,8 @@ foreach my $file ($info->sorted_index) {
     }
 
     my $strings = slurp_entire_file ($info->strings ($file));
-    check_spelling('spelling-error-in-binary', $strings, $file, { $pkg => 1 });
+    check_spelling('spelling-error-in-binary', $strings, $file,
+                   $group->info->spelling_exceptions);
 
     # stripped?
     if ($fileinfo =~ m,not stripped\s*$,o) {
diff --git a/checks/changelog-file b/checks/changelog-file
index 4c087d8..8bcab22 100644
--- a/checks/changelog-file
+++ b/checks/changelog-file
@@ -32,7 +32,7 @@ use Parse::DebianChangelog;
 
 sub run {
 
-my ($pkg, $type, $info) = @_;
+my ($pkg, $type, $info, undef, $group) = @_;
 
 my $found_html=0;
 my $found_text=0;
@@ -138,7 +138,7 @@ if (-f $dnews) {
             tag 'debian-news-entry-has-strange-distribution', $news->Distribution;
         }
         check_spelling('spelling-error-in-news-debian', $news->Changes,
-                       undef, { $pkg => 1});
+                       undef, $group->info->spelling_exceptions);
         if ($news->Changes =~ /^\s*\*\s/) {
             tag 'debian-news-entry-uses-asterisk';
         }
@@ -374,7 +374,8 @@ if (@entries) {
     # Strip out all lines that contain the word spelling to avoid false
     # positives on changelog entries for spelling fixes.
     $changes =~ s/^.*spelling.*\n//gm;
-    check_spelling('spelling-error-in-changelog', $changes, undef, { $pkg => 1});
+    check_spelling('spelling-error-in-changelog', $changes, undef,
+                   $group->info->spelling_exceptions);
 }
 
 }
diff --git a/checks/copyright-file b/checks/copyright-file
index c4bdd11..9c6a66b 100644
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -271,7 +271,8 @@ if ($found && !$linked && !/(?:Copyright|Copr\.|\302\251)(?:.*|[\(C\):\s]+)\b\d{
     tag 'copyright-without-copyright-notice';
 }
 
-check_spelling('spelling-error-in-copyright', $_, undef, { $pkg => 1 });
+check_spelling('spelling-error-in-copyright', $_, undef,
+               $group->info->spelling_exceptions);
 
 # Now, check for linking against libssl if the package is covered by the GPL.
 # (This check was requested by ftp-master.)  First, see if the package is
diff --git a/checks/debian-readme b/checks/debian-readme
index db23a6a..e3d14ed 100644
--- a/checks/debian-readme
+++ b/checks/debian-readme
@@ -27,7 +27,7 @@ use Lintian::Tags qw(tag);
 
 sub run {
 
-my ($pkg, undef, $info) = @_;
+my ($pkg, undef, $info, undef, $group) = @_;
 
 my $readme = '';
 
@@ -53,7 +53,8 @@ if ($readme =~ m/$regex/io) {
     tag 'readme-debian-contains-invalid-email-address', $1;
 }
 
-check_spelling('spelling-error-in-readme-debian', $readme, undef, { $pkg => 1 });
+check_spelling('spelling-error-in-readme-debian', $readme, undef,
+               $group->info->spelling_exceptions);
 
 }
 
diff --git a/checks/description b/checks/description
index e93e7a8..3dc0ad9 100644
--- a/checks/description
+++ b/checks/description
@@ -29,7 +29,7 @@ use Lintian::Tags qw(tag);
 
 sub run {
 
-my ($pkg, $type, $info) = @_;
+my ($pkg, $type, $info, undef, $group) = @_;
 
 my $tabs = 0;
 my $lines = 0;
@@ -194,7 +194,7 @@ unless ($info->field('homepage') or $flagged_homepage) {
 
 if ($description) {
     check_spelling('spelling-error-in-description', $description,
-                   undef, {$pkg => 1});
+                   undef, $group->info->spelling_exceptions);
     check_spelling_picky('capitalization-error-in-description', $description);
 }
 
diff --git a/checks/manpages b/checks/manpages
index 4421857..ee08301 100644
--- a/checks/manpages
+++ b/checks/manpages
@@ -336,7 +336,8 @@ foreach my $file ($info->sorted_index) {
                 tag 'manpage-has-errors-from-pod2man', "$file:$lc";
             }
             # Check for spelling errors if the manpage is English
-            check_spelling('spelling-error-in-manpage', $line, $file, { $pkg => 1 })
+            check_spelling('spelling-error-in-manpage', $line, $file,
+                           $ginfo->spelling_exceptions)
                 if ($path =~ m,/man/man\d/,);
         }
         tag 'hyphen-used-as-minus-sign', $file, ($hc - 10),
diff --git a/checks/menus b/checks/menus
index c391592..6e4c6ef 100644
--- a/checks/menus
+++ b/checks/menus
@@ -52,7 +52,7 @@ our $SECTIONS = Lintian::Data->new ('doc-base/sections');
 
 sub run {
 
-my ($pkg, $type, $info) = @_;
+my ($pkg, $type, $info, undef, $group) = @_;
 
 my %all_files = ();
 my %all_links = ();
@@ -190,7 +190,8 @@ if ($docbase_file) {
         my $dbpath = $info->lab_data_path ("doc-base/$dbfile");
         # don't try to parse executables, plus we already warned about it
         next if -x $dbfile;
-        check_doc_base_file ($dbfile, $dbpath, $pkg, $type, \%all_files, \%all_links);
+        check_doc_base_file ($dbfile, $dbpath, $pkg, $type, \%all_files, \%all_links,
+                             $group);
     }
     closedir DOCBASEDIR;
 } elsif ($documentation) {
@@ -234,7 +235,7 @@ if ($anymenu_file) {
 # -----------------------------------
 
 sub check_doc_base_file {
-    my ($dbfile, $dbpath, $pkg, $type, $all_files, $all_links) = @_;
+    my ($dbfile, $dbpath, $pkg, $type, $all_files, $all_links, $group) = @_;
 
     my $line = file_is_encoded_in_non_utf8 ($dbpath, $type, $pkg);
     if ($line) {
@@ -259,7 +260,7 @@ sub check_doc_base_file {
             if ($field) {
                 check_doc_base_field($pkg, $dbfile, $line, $field, \@vals,
                                      \%sawfields, \%sawformats, $knownfields,
-                                     $all_files, $all_links);
+                                     $all_files, $all_links, $group);
             }
             $field = lc $new[0];
             @vals  = ($new[1]);
@@ -282,7 +283,7 @@ sub check_doc_base_file {
             # Check previously defined field and section.
             check_doc_base_field($pkg, $dbfile, $line, $field, \@vals,
                                  \%sawfields, \%sawformats, $knownfields,
-                                 $all_files, $all_links);
+                                 $all_files, $all_links, $group);
             check_doc_base_file_section($dbfile, $line + 1, \%sawfields,
                                         \%sawformats, $knownfields);
 
@@ -305,7 +306,7 @@ sub check_doc_base_file {
     if ($field) {
         check_doc_base_field($pkg, $dbfile, $line, $field, \@vals, \%sawfields,
                              \%sawformats, $knownfields, $all_files,
-                             $all_links);
+                             $all_links, $group);
         check_doc_base_file_section($dbfile, $line, \%sawfields, \%sawformats,
                                     $knownfields);
     }
@@ -320,7 +321,7 @@ sub check_doc_base_file {
 # all lines of the field.  Modifies $sawfields and $sawformats.
 sub check_doc_base_field {
     my ($pkg, $dbfile, $line, $field, $vals, $sawfields, $sawformats,
-        $knownfields, $all_files, $all_links) = @_;
+        $knownfields, $all_files, $all_links, $group) = @_;
 
     tag 'doc-base-file-unknown-field', "$dbfile:$line", $field
         unless defined $knownfields->{$field};
@@ -397,7 +398,8 @@ sub check_doc_base_field {
     } elsif ($field eq 'title') {
         if (@$vals) {
             check_spelling('spelling-error-in-doc-base-title-field',
-                           join (' ', @$vals), "$dbfile:$line", { $pkg => 1});
+                           join (' ', @$vals), "$dbfile:$line",
+                           $group->info->spelling_exceptions);
             check_spelling_picky('spelling-error-in-doc-base-title-field',
                                  join (' ', @$vals), "$dbfile:$line");
         }
@@ -464,7 +466,8 @@ sub check_doc_base_field {
         # Check spelling.
         if (@$vals) {
             check_spelling('spelling-error-in-doc-base-abstract-field',
-                           join (' ', @$vals), "$dbfile:$line", { $pkg => 1 });
+                           join (' ', @$vals), "$dbfile:$line",
+                           $group->info->spelling_exceptions);
             check_spelling_picky('spelling-error-in-doc-base-abstract-field',
                                  join (' ', @$vals), "$dbfile:$line");
         }
diff --git a/debian/changelog b/debian/changelog
index a1a9754..83515df 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,10 @@ lintian (2.5.11) UNRELEASED; urgency=low
   * checks/*:
     + [NT] Remove assumption that lintian will chdir into the
       the lab before calling the check.
+    + [NT] Be better at avoiding false-positive spelling errors
+      for references to packages that also happen to be common
+      spelling mistake.  Thanks to Paul Tagliamonte for the
+      report.  (Closes: #687464)
   * checks/binaries{,.desc}:
     + [NT] Merge apparently-truncated-elf-binary into
       apparently-corrupted-elf-binary.
diff --git a/lib/Lintian/Collect/Group.pm b/lib/Lintian/Collect/Group.pm
index 717f9a5..13d43c2 100644
--- a/lib/Lintian/Collect/Group.pm
+++ b/lib/Lintian/Collect/Group.pm
@@ -123,6 +123,33 @@ sub type {
     return 'group';
 }
 
+=item spelling_exceptions
+
+Returns a hashref of words, which the spell checker should ignore.
+These words are generally based on the package names in the group to
+avoid false-positive "spelling error" when packages have "fun" names.
+
+Example: Package alot-doc (#687464)
+
+=cut
+
+# sub spelling_exceptions Needs-Info <>
+sub spelling_exceptions {
+    my ($self) = @_;
+    return $self->{'spelling_exceptions'}
+        if exists $self->{'spelling_exceptions'};
+    my %except = ();
+    my $group = $self->{'group'};
+    foreach my $proc ($group->get_processables ('binary')) {
+        foreach my $name ($proc->pkg_name, $proc->pkg_src) {
+            $except{$name} = 1;
+            $except{$_} = 1 for split m/-/, $name;
+        }
+    }
+    $self->{'seplling_exceptions'} = \%except;
+    return \%except;
+}
+
 =back
 
 =head1 AUTHOR

-- 
Debian package checker


Reply to: