[lintian] 01/01: Check spelling of patch headers. (Closes: #756130)
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository lintian.
commit 4cd9425875a25bb7ad1a29ab27e0b66b080eab37
Author: Chris Lamb <lamby@debian.org>
Date: Wed Feb 7 22:29:56 2018 +0000
Check spelling of patch headers. (Closes: #756130)
---
checks/patch-systems.desc | 7 +++++
checks/patch-systems.pm | 33 ++++++++++++----------
debian/changelog | 3 +-
.../debian/debian/patches/add-readme | 6 ++++
.../spelling-general/debian/debian/patches/series | 1 +
.../spelling-general/debian/debian/source/format | 1 +
t/tests/spelling-general/desc | 4 ++-
t/tests/spelling-general/tags | 1 +
8 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/checks/patch-systems.desc b/checks/patch-systems.desc
index e8f9b6f..0f5b682 100644
--- a/checks/patch-systems.desc
+++ b/checks/patch-systems.desc
@@ -218,3 +218,10 @@ Info: The dpatch patch system has been deprecated and superceded by the
Please migrate the patches in the <tt>debian/patches</tt> directory and
the <tt>00list</tt> file to use this source format.
Ref: dpatch(1), dpkg-source(1)
+
+Tag: spelling-error-in-patch-description
+Severity: minor
+Certainty: certain
+Info: Lintian found a spelling or capitalization error in the description
+ for this patch. Lintian has a list of common misspellings that it looks
+ for. It does not have a dictionary like a spelling checker does.
diff --git a/checks/patch-systems.pm b/checks/patch-systems.pm
index 2c49714..0b74d59 100644
--- a/checks/patch-systems.pm
+++ b/checks/patch-systems.pm
@@ -27,11 +27,12 @@ use autodie;
use constant PATCH_DESC_TEMPLATE => 'TODO: Put a short summary on'
. ' the line above and replace this paragraph';
+use Lintian::Check qw(check_spelling spelling_tag_emitter);
use Lintian::Tags qw(tag);
use Lintian::Util qw(internal_error strip);
sub run {
- my (undef, undef, $info) = @_;
+ my (undef, undef, $info, undef, $group) = @_;
# Some (cruft) checks are valid for every patch system, so we need
# to record that:
@@ -114,24 +115,24 @@ sub run {
}
next unless $patch_file->is_open_ok;
- my $has_comment = 0;
+ my $description = '';
my $fd = $patch_file->open;
while (<$fd>) {
# stop if something looking like a patch
# starts:
last if /^---/;
# note comment if we find a proper one
- $has_comment = 1
+ $description .= $1
if (/^\#+\s*DP:\s*(\S.*)$/
&& $1 !~ /^no description\.?$/i);
- $has_comment = 1
- if (/^\# (?:Description|Subject)/);
+ $description .= $1
+ if (/^\# (?:Description|Subject): (.*)/);
}
close($fd);
- unless ($has_comment) {
+ unless ($description) {
tag 'dpatch-missing-description', $patch_name;
}
- check_patch($patch_file);
+ check_patch($group, $patch_file, $description);
}
}
}
@@ -176,7 +177,7 @@ sub run {
next;
}
next if not $patch->is_open_ok;
- my $has_description = 0;
+ my $description = '';
my $has_template_description = 0;
my $patch_fd = $patch->open;
while (<$patch_fd>) {
@@ -184,20 +185,20 @@ sub run {
last if /^---/;
next if /^\s*$/;
# Skip common "lead-in" lines
- $has_description = 1
+ $description .= $_
unless m{^(?:Index: |=+$|diff .+|index )};
$has_template_description = 1
if index($_, PATCH_DESC_TEMPLATE) != -1;
}
close($patch_fd);
- unless ($has_description) {
+ unless ($description) {
tag 'quilt-patch-missing-description', $patch_filename;
}
if ($has_template_description) {
tag 'quilt-patch-using-template-description',
$patch_filename;
}
- check_patch($patch);
+ check_patch($group, $patch, $description);
}
}
if ($quilt_format) { # 3.0 (quilt) specific checks
@@ -277,10 +278,12 @@ sub run {
# Checks on patches common to all build systems.
sub check_patch {
- my ($patch_file) = @_;
-
- return if not $patch_file->is_open_ok;
-
+ my ($group, $patch_file, $description) = @_;
+ my $tag_emitter
+ = spelling_tag_emitter('spelling-error-in-patch-description',
+ $patch_file);
+ check_spelling($description, $group->info->spelling_exceptions,
+ $tag_emitter);
# Use --strip=1 to strip off the first layer of directory in case
# the parent directory in which the patches were generated was
# named "debian". This will produce false negatives for --strip=0
diff --git a/debian/changelog b/debian/changelog
index 863d2e0..4c2b696 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -37,10 +37,11 @@ lintian (2.5.74) UNRELEASED; urgency=medium
* checks/init.d.{desc,pm}:
+ [CL] Warn about packages that use ENABLED="true" (etc.) in
/etc/default files.
- * checks/patch-systems.pm:
+ * checks/patch-systems.{desc,pm}:
+ [CL] Avoid emitting "Can't use an undefined value as an ARRAY
reference" warnings when debian/patches is a file, not a directory.
(Closes: #889535)
+ + [CL] Check spelling of patch headers. (Closes: #756130)
* checks/rules.{desc,pm}:
+ [CL] Fix a number of false-positives when checking the
"override_dh_auto_test-does-not-check-DEB_BUILD_PROFILES" tag
diff --git a/t/tests/spelling-general/debian/debian/patches/add-readme b/t/tests/spelling-general/debian/debian/patches/add-readme
new file mode 100644
index 0000000..78eb203
--- /dev/null
+++ b/t/tests/spelling-general/debian/debian/patches/add-readme
@@ -0,0 +1,6 @@
+This is a deliberate speling error.
+
+--- upstream.orig/README
++++ upstream/README
+@@ -0,0 +1 @@
++Added by patch system.
diff --git a/t/tests/spelling-general/debian/debian/patches/series b/t/tests/spelling-general/debian/debian/patches/series
new file mode 100644
index 0000000..2804b8f
--- /dev/null
+++ b/t/tests/spelling-general/debian/debian/patches/series
@@ -0,0 +1 @@
+add-readme
diff --git a/t/tests/spelling-general/debian/debian/source/format b/t/tests/spelling-general/debian/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/t/tests/spelling-general/debian/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/t/tests/spelling-general/desc b/t/tests/spelling-general/desc
index 7f52caa..f585be0 100644
--- a/t/tests/spelling-general/desc
+++ b/t/tests/spelling-general/desc
@@ -1,8 +1,10 @@
Testname: spelling-general
-Version: 1.0
+Version: 1.0-1
+Type: non-native
Description: General checks for spelling errors
Test-For:
spelling-error-in-changelog
spelling-error-in-copyright
spelling-error-in-doc-base-abstract-field
spelling-error-in-doc-base-title-field
+ spelling-error-in-patch-description
diff --git a/t/tests/spelling-general/tags b/t/tests/spelling-general/tags
index bf3b6c2..7f8e27c 100644
--- a/t/tests/spelling-general/tags
+++ b/t/tests/spelling-general/tags
@@ -1,4 +1,5 @@
I: spelling-general: spelling-error-in-copyright deafult default
+W: spelling-general source: spelling-error-in-patch-description debian/patches/add-readme speling spelling
W: spelling-general: spelling-error-in-changelog speling spelling
W: spelling-general: spelling-error-in-doc-base-abstract-field spelling-general:5 meta-package metapackage
W: spelling-general: spelling-error-in-doc-base-abstract-field spelling-general:5 speling spelling
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: