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

[SCM] Debian package checker branch, master, updated. 2.4.3-122-g38807d2



The following commit has been merged in the master branch:
commit 38807d2b6ce6d866465440ecfeabda83f4fe81ee
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Jan 9 23:34:04 2011 +0100

    Exclude package names from regular spell checks
    
    Lintian::Check::spell_check now accepts a hashref as the last
    argument.  Any key in this hashref will not be considered a
    spelling error.  All checks using it has been changed to pass
    the name of the current package as an exception.
    
    Note that these exceptions are ignored for multi word spell
    checks and the "picky" (case sensitive) spell checks.
    
    Lintian/Check.pm
        + [NT] Allow package names to be excluded from regular spelling
          checks.  They are still subject to multi word and case sensitive
          spelling checks.  Thanks to syq for the suggestion.
          (Closes: #576283)

diff --git a/checks/binaries b/checks/binaries
index 823cb5c..de894cb 100644
--- a/checks/binaries
+++ b/checks/binaries
@@ -246,7 +246,7 @@ foreach my $file (@{$info->sorted_file_info}) {
     }
 
     my $strings = slurp_entire_file("strings/$file");
-    check_spelling('spelling-error-in-binary', $strings, $file);
+    check_spelling('spelling-error-in-binary', $strings, $file, { $pkg => 1 });
 
     # stripped?
     if ($fileinfo =~ m,not stripped\s*$,o) {
diff --git a/checks/changelog-file b/checks/changelog-file
index 42f5a53..2c7ad24 100644
--- a/checks/changelog-file
+++ b/checks/changelog-file
@@ -160,7 +160,8 @@ if (-f 'NEWS.Debian') {
         if ($news->Distribution && $news->Distribution =~ /unreleased/i) {
             tag "debian-news-entry-has-strange-distribution", $news->Distribution;
         }
-        check_spelling('spelling-error-in-news-debian', $news->Changes);
+        check_spelling('spelling-error-in-news-debian', $news->Changes,
+		       undef, { $pkg => 1});
 	if ($news->Changes =~ /^\s*\*\s/) {
 	    tag 'debian-news-entry-uses-asterisk';
 	}
@@ -390,7 +391,7 @@ 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);
+    check_spelling('spelling-error-in-changelog', $changes, undef, { $pkg => 1});
 }
 
 # read the changelog itself
diff --git a/checks/copyright-file b/checks/copyright-file
index 267ed43..de6ffe0 100644
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -303,7 +303,7 @@ if ($found && !$linked && !/(?:Copyright|Copr\.|\302\251)(?:.*|[\(C\):\s]+)\b\d{
     tag 'copyright-without-copyright-notice';
 }
 
-check_spelling('spelling-error-in-copyright', $_);
+check_spelling('spelling-error-in-copyright', $_, undef, { $pkg => 1 });
 
 # 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 83482ca..6f882f4 100644
--- a/checks/debian-readme
+++ b/checks/debian-readme
@@ -52,7 +52,7 @@ if ($readme =~ m/$regex/io) {
     tag("readme-debian-contains-debmake-default-email-address");
 }
 
-check_spelling('spelling-error-in-readme-debian', $readme);
+check_spelling('spelling-error-in-readme-debian', $readme, undef, { $pkg => 1 });
 
 }
 
diff --git a/checks/description b/checks/description
index e113938..8d2f325 100644
--- a/checks/description
+++ b/checks/description
@@ -191,7 +191,8 @@ unless ($info->field('homepage') or $flagged_homepage) {
 }
 
 if ($description) {
-    check_spelling('spelling-error-in-description', $description);
+    check_spelling('spelling-error-in-description', $description,
+		   undef, {$pkg => 1});
     check_spelling_picky('capitalization-error-in-description', $description);
 }
 
diff --git a/checks/manpages b/checks/manpages
index 17912d2..c459aa8 100644
--- a/checks/manpages
+++ b/checks/manpages
@@ -319,7 +319,7 @@ 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)
+	    check_spelling("spelling-error-in-manpage", $line, $file, { $pkg => 1 })
 		if ($path =~ m,/man/man\d/,);
 	}
 	tag "hyphen-used-as-minus-sign", $file, ($hc - 10),
diff --git a/checks/menus b/checks/menus
index 5310a01..87a0b8d 100644
--- a/checks/menus
+++ b/checks/menus
@@ -409,7 +409,7 @@ sub check_doc_base_field {
     } elsif ($field eq 'title') {
         if (@$vals) {
             check_spelling("spelling-error-in-doc-base-title-field",
-                           join (' ', @$vals), "$dbfile:$line");
+                           join (' ', @$vals), "$dbfile:$line", { $pkg => 1});
             check_spelling_picky("spelling-error-in-doc-base-title-field",
                                  join (' ', @$vals), "$dbfile:$line");
         }
@@ -477,7 +477,7 @@ sub check_doc_base_field {
         # Check spelling.
         if (@$vals) {
             check_spelling("spelling-error-in-doc-base-abstract-field",
-                           join (' ', @$vals), "$dbfile:$line");
+                           join (' ', @$vals), "$dbfile:$line", { $pkg => 1 });
             check_spelling_picky("spelling-error-in-doc-base-abstract-field",
                                  join (' ', @$vals), "$dbfile:$line");
         }
diff --git a/debian/changelog b/debian/changelog
index 5d2254e..c92fc49 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -117,6 +117,10 @@ lintian (2.4.4) UNRELEASED; urgency=low
   * lib/Lintian/Check.pm:
     + [NT] Use Email::Valid to validate email addreses.
       (Closes: #602655)
+    + [NT] Allow package names to be excluded from regular spelling
+      checks.  They are still subject to multi word and case sensitive
+      spelling checks.  Thanks to syq for the suggestion.
+      (Closes: #576283)
   * lib/Lintian/Collect/Binary.pm:
     + [NT] Pre-sort file index and file info to avoid sorting it
       repeatedly in the checks.  (Closes: #605844)
diff --git a/lib/Lintian/Check.pm b/lib/Lintian/Check.pm
index af13b6c..a0e3219 100644
--- a/lib/Lintian/Check.pm
+++ b/lib/Lintian/Check.pm
@@ -185,18 +185,23 @@ sub _tag {
     tag(@args);
 }
 
-=item check_spelling(TAG, TEXT, FILENAME)
+=item check_spelling(TAG, TEXT, FILENAME, EXCEPTION)
 
 Performs a spelling check of TEXT, reporting TAG if any errors are found.
 
 If FILENAME is given, it will be used as the first argument to TAG.
 
+If EXCEPTION is given, it will be used as a hash ref of exceptions.
+Any lowercase word appearing as a key of this hash ref will never be
+considered a spelling mistake (exception being if it is a part of a
+multiword misspelling).
+
 Returns the number of spelling mistakes found in TEXT.
 
 =cut
 
 sub check_spelling {
-    my ($tag, $text, $filename) = @_;
+    my ($tag, $text, $filename, $exceptions) = @_;
     return unless $text;
 
     my $counter = 0;
@@ -207,11 +212,14 @@ sub check_spelling {
     $text =~ s/[()\[\]]//g;
     $text =~ s/(\w-)\s*\n\s*/$1/;
 
+    $exceptions = {} unless (defined($exceptions));
+
     for my $word (split(/\s+/, $text)) {
         $word =~ s/[.,;:?!]+$//;
         next if ($word =~ /^[A-Z]{1,5}\z/);
         my $lcword = lc $word;
-        if ($corrections->known($lcword)) {
+        if ($corrections->known($lcword) &&
+                not exists ($exceptions->{$lcword})) {
             $counter++;
             my $correction = $corrections->value($lcword);
             if ($word =~ /^[A-Z]+$/) {
diff --git a/t/tests/files-objects-inv/debian/debian/control.in b/t/tests/spelling-package-name/debian/debian/control.in
similarity index 74%
copy from t/tests/files-objects-inv/debian/debian/control.in
copy to t/tests/spelling-package-name/debian/debian/control.in
index 79a6d1c..d42604a 100644
--- a/t/tests/files-objects-inv/debian/debian/control.in
+++ b/t/tests/spelling-package-name/debian/debian/control.in
@@ -1,14 +1,17 @@
 Source: {$srcpkg}
 Priority: extra
-Section: python
+Section: devel
 Maintainer: {$author}
 Standards-Version: {$standards_version}
 Build-Depends: debhelper (>= 7.0.50~)
 
-Package: python-kinterbasdb
+Package: nam
 Architecture: all
 Depends: $\{misc:Depends\},
 Description: {$description}
+ This is a test to see if the spell checker realizes that nam is
+ not a spelling mistake, but the name of the package.
+ .
  This is a test package designed to exercise some feature or tag of
  Lintian.  It is part of the Lintian test suite and may do very odd
  things.  It should not be installed like a regular package.  It may
diff --git a/t/tests/spelling-package-name/desc b/t/tests/spelling-package-name/desc
new file mode 100644
index 0000000..19caaed
--- /dev/null
+++ b/t/tests/spelling-package-name/desc
@@ -0,0 +1,6 @@
+Testname: spelling-package-name
+Sequence: 6000
+Version: 1.0
+Description: Spell check test for excluding package name
+Test-Against:
+ spelling-error-in-description
diff --git a/t/debs/deb-format-record-size/tags b/t/tests/spelling-package-name/tags
similarity index 100%
copy from t/debs/deb-format-record-size/tags
copy to t/tests/spelling-package-name/tags

-- 
Debian package checker


Reply to: