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

Bug#576283: lintian generates spell-check warning which is the package name



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

tags 576283 + patch
thanks

Hi

Proposing a patch for this bug.  The patch only fixes the description
spell check and will not apply to A) Multi word corrections nor B)
"picky" (case) spell checks.  I was not sure if we really want to
include the package name in all spell checks.  Let me know if I should
exclude some of the spell checks listed in [1].

~Niels

[1]
Trimmed output for readability:
$ grep check_spelling checks/* | grep -v -e picky -e use
c/binaries:  check_spelling('spelling-error-in-binary'
c/changelog-file:  check_spelling('spelling-error-in-news-debian'
c/changelog-file:  check_spelling('spelling-error-in-changelog'
c/copyright-file:  check_spelling('spelling-error-in-copyright', $_);
c/debian-readme:  check_spelling('spelling-error-in-readme-debian'
c/description:  check_spelling('spelling-error-in-description'
c/manpages:  check_spelling("spelling-error-in-manpage"
c/menus:  check_spelling("spelling-error-in-doc-base-title-field",
c/menus:  check_spelling("spelling-error-in-doc-base-abstract-field",

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJNKjy3AAoJEAVLu599gGRCRDwP/3uZZBPVTbBG4qyqQyWdr1TG
wX5vUph7ItkauJixNrQsHLwYuqJnnqSKVH4Et4iPWMj7/ndvxe9WLACUQfIFlcQW
HFDaIr5f4tA42FtfC+4KwgQ3n+HuooJdI80v0erxqrD5pDmd1UeJWlcT9T3B44j9
sxUvD6D55WysJKlvqy2L4kmi9M/wiN4BwaDqJtbXRmbiFbulZH8m3+zEJmXxhPhC
wXs2XMsWSBfGn0KyVLAwl7m5tkFEOUZTKIBYwBDOT18uT9e9j8Eww+/2jqju+xFY
cedWIVzBTv9ZXHcIavJqQ9+29XDEOcVEbjNJNaAT1PPmZ43CFJZAT1wfw6950Yca
Y1VIJOueJrlgu6cPb5Aud3BRFLpGLmbZT4O5ToNnPpKGHeeuWa10Irct2N30hYrl
zIzKSEhoSV6yUOmYF0JvBI/XZRwApniXXOp31PG1xDk55uFlMl7PzkVLfWr/YaG7
DVdQ9TJfHq1ckH78pwSbok5j1+HQYr2xgaXadJdlPxGReTjsUbcWHWElrBHX4sGM
llP9DLK5v20HmH4jOUZTYiX5xrWDYIYXoaA3ane7eThQx9M8zC8xv8kW1r4eLvku
a9u14LMxlJgPzbX2xU9URZroohgO4hj6ietJmmGFCNpboTfhNMZyFfz8rZvpMyJt
qgximBlf7SH1VDU1kBaf
=sLkT
-----END PGP SIGNATURE-----
>From dc78d3a49ad800349153973ed5dd84e1952edc18 Mon Sep 17 00:00:00 2001
From: Niels Thykier <niels@thykier.net>
Date: Sun, 9 Jan 2011 23:34:04 +0100
Subject: [PATCH] Possible solution to #576283

---
 checks/description                                 |    3 ++-
 lib/Lintian/Check.pm                               |   17 ++++++++++++++---
 .../spelling-package-name/debian/debian/control.in |   19 +++++++++++++++++++
 t/tests/spelling-package-name/desc                 |    6 ++++++
 4 files changed, 41 insertions(+), 4 deletions(-)
 create mode 100644 t/tests/spelling-package-name/debian/debian/control.in
 create mode 100644 t/tests/spelling-package-name/desc
 create mode 100644 t/tests/spelling-package-name/tags

diff --git a/checks/description b/checks/description
index e113938..84e54f6 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);
+    my %exc = ( corrections => { $pkg => 1 });
+    check_spelling('spelling-error-in-description', $description, undef, \%exc);
     check_spelling_picky('capitalization-error-in-description', $description);
 }
 
diff --git a/lib/Lintian/Check.pm b/lib/Lintian/Check.pm
index af13b6c..3e58988 100644
--- a/lib/Lintian/Check.pm
+++ b/lib/Lintian/Check.pm
@@ -185,33 +185,44 @@ 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, then EXCEPTION->{corrections} 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;
     my $corrections = Lintian::Data->new('spelling/corrections', '\|\|');
     my $corrections_multiword =
         Lintian::Data->new('spelling/corrections-multiword', '\|\|');
+    my $exc;
 
     $text =~ s/[()\[\]]//g;
     $text =~ s/(\w-)\s*\n\s*/$1/;
 
+    if (defined($exceptions)){
+        $exc = $exceptions->{corrections};
+    }
+    $exc = {} unless (defined($exc));
+
     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 ($exc->{$lcword})) {
             $counter++;
             my $correction = $corrections->value($lcword);
             if ($word =~ /^[A-Z]+$/) {
diff --git a/t/tests/spelling-package-name/debian/debian/control.in b/t/tests/spelling-package-name/debian/debian/control.in
new file mode 100644
index 0000000..d42604a
--- /dev/null
+++ b/t/tests/spelling-package-name/debian/debian/control.in
@@ -0,0 +1,19 @@
+Source: {$srcpkg}
+Priority: extra
+Section: devel
+Maintainer: {$author}
+Standards-Version: {$standards_version}
+Build-Depends: debhelper (>= 7.0.50~)
+
+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
+ be an empty package.
+
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/tests/spelling-package-name/tags b/t/tests/spelling-package-name/tags
new file mode 100644
index 0000000..e69de29
-- 
1.7.2.3

Attachment: 0001-Possible-solution-to-576283.patch.sig
Description: Binary data


Reply to: