[lintian] 01/01: When looking for the source of "subdir/foo/bar.min.js", also check "src/foo/bar.js" (etc). (Closes: #832027)
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository lintian.
commit 1b6e37f23ba1b6ffccaf60a30444f581c45e64fd
Author: Chris Lamb <lamby@debian.org>
Date: Sat Jan 27 20:11:50 2018 +1100
When looking for the source of "subdir/foo/bar.min.js", also check "src/foo/bar.js" (etc). (Closes: #832027)
---
checks/cruft.pm | 4 ++++
data/cruft/missing-dir-search-path | 2 ++
debian/changelog | 4 ++++
t/tests/cruft-minified-js/pre_build | 5 +++++
t/tests/cruft-minified-js/tags | 1 +
5 files changed, 16 insertions(+)
diff --git a/checks/cruft.pm b/checks/cruft.pm
index 706a31e..0beda52 100644
--- a/checks/cruft.pm
+++ b/checks/cruft.pm
@@ -39,6 +39,8 @@ use constant BLOCKSIZE => 16_384;
use constant INSANE_LINE_LENGTH => 512;
use constant SAFE_LINE_LENGTH => 256;
+use File::Basename qw(basename);
+
use Lintian::Data;
use Lintian::Relation ();
use Lintian::Tags qw(tag);
@@ -819,6 +821,7 @@ sub check_missing_source {
my ($file, $info, $name, $basename, $dirname,$replacementspairref,
$extratext)
= @_;
+ my $basename_of_dirname = basename($dirname);
$extratext //= '';
# do not check missing source for non free
@@ -857,6 +860,7 @@ sub check_missing_source {
my $newpath;
# first replace dir name
$path =~ s/\$dirname/$dirname/g;
+ $path =~ s/\$basename_of_dirname/$basename_of_dirname/g;
# absolute path
if(substr($path,0,1) eq '/') {
$path =~ s,^/+,,g;
diff --git a/data/cruft/missing-dir-search-path b/data/cruft/missing-dir-search-path
index 5c3488f..a5ca09d 100644
--- a/data/cruft/missing-dir-search-path
+++ b/data/cruft/missing-dir-search-path
@@ -1,5 +1,6 @@
# where we could find missing source leading / means relative to root package
# $dirname will be replaced by path of current
+# $basename_of_dirname will be replaced by basename($dirname)
# likely in current dir
./
@@ -9,6 +10,7 @@
./src/
# maybe in ../src subdir
../src/
+../../src/$basename_of_dirname/
# libtool
/.libs/
/.libs/$dirname/
diff --git a/debian/changelog b/debian/changelog
index 4807a78..f4e54fd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,10 @@ lintian (2.5.73) UNRELEASED; urgency=medium
XXX: generate tag summary
+ * checks/cruft.pm:
+ + [CL] When looking for the source of "build/foo/bar.min.js", also check
+ "src/foo/bar.js". (Closes: #832027)
+
* data/files/python-generic-modules:
+ [CL] Detect "backports" (and "backport") as overly generic Python
module names. (Closes: #888559)
diff --git a/t/tests/cruft-minified-js/pre_build b/t/tests/cruft-minified-js/pre_build
index 0af7e22..3e111b7 100755
--- a/t/tests/cruft-minified-js/pre_build
+++ b/t/tests/cruft-minified-js/pre_build
@@ -17,6 +17,8 @@ mkdir -p "$jsdir/json"
mkdir -p "$jsdir/sourced"
mkdir -p "$jsdir/sourced_variant"
mkdir -p "$jsdir/jswithoutminextwithoutsource/"
+mkdir -p "$srcdir/src/js"
+mkdir -p "$srcdir/build/js"
# create a js file
uglifyjs -o "$uglyjson" "$json"
@@ -32,6 +34,9 @@ cp "$uglyjson" "$jsdir/sourced/sourced.min.js"
cp "$json" "$jsdir/sourced/sourced.js"
cp "$uglyjson" "$jsdir/sourced_variant/sourced.min.js"
cp "$json" "$jsdir/sourced_variant/sourced_orig.js"
+# sourced in parent's parent
+cp "$uglyjson" "$srcdir/build/js/foo.min.js"
+cp "$json" "$srcdir/src/js/foo.js"
diff --git a/t/tests/cruft-minified-js/tags b/t/tests/cruft-minified-js/tags
index 38424ce..e905899 100644
--- a/t/tests/cruft-minified-js/tags
+++ b/t/tests/cruft-minified-js/tags
@@ -5,6 +5,7 @@ P: cruft-minified-js source: insane-line-length-in-source-file oldfalsepositives
P: cruft-minified-js source: insane-line-length-in-source-file oldfalsepositives/longlicensetext.js line length is NUMBER characters (>CUTOFF)
P: cruft-minified-js source: insane-line-length-in-source-file usr/share/javascript/jswithoutminext/json.js line length is NUMBER characters (>CUTOFF)
P: cruft-minified-js source: insane-line-length-in-source-file usr/share/javascript/jswithoutminextwithoutsource/jsonnotsourced.js line length is NUMBER characters (>CUTOFF)
+P: cruft-minified-js source: source-contains-prebuilt-javascript-object build/js/foo.min.js
P: cruft-minified-js source: source-contains-prebuilt-javascript-object oldfalsepositives/-debug.js/src/test-min.js
P: cruft-minified-js source: source-contains-prebuilt-javascript-object oldfalsepositives/-nc.js/test-yc.js
P: cruft-minified-js source: source-contains-prebuilt-javascript-object oldfalsepositives/debug.js/testdebug.js line length is NUMBER characters (>CUTOFF)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: