This is an automated email from the git hooks/post-receive script. broucaries-guest pushed a commit to branch master in repository lintian.
commit 9fe90f7050c7fda7ec28e4533521b1542061ce7b Author: Bastien ROUCARIÈS <roucaries.bastien+deb...@gmail.com> Date: Sun Jan 31 00:12:14 2016 +0100 Fix other false positive for source-is-missing Signed-off-by: Bastien ROUCARIÈS <roucaries.bastien+deb...@gmail.com> --- checks/cruft.pm | 57 ++++++++++++++++------ debian/changelog | 1 + .../debian/oldfalsepositives/longlicensetext.js | 30 ++++++++++++ t/tests/cruft-minified-js/tags | 1 + 4 files changed, 73 insertions(+), 16 deletions(-) diff --git a/checks/cruft.pm b/checks/cruft.pm index 1dcde65..d9d4b1e 100644 --- a/checks/cruft.pm +++ b/checks/cruft.pm @@ -1017,6 +1017,29 @@ sub _linelength_test_maxlength { return (0,'',$block); } +# strip C comment +# warning block is at more 8192 char in order to be too slow +# and in order to avoid regex recursion +sub _strip_c_comments { + my ($block) = @_; + # from perl faq strip comments + $block =~ s{ + # Strip /* */ comments + /\* [^*]*+ \*++ (?: [^/*][^*]*+\*++ ) */ + # Strip // comments (C++ style) + | // (?: [^\\] | [^\n][\n]? )*? (?=\n) + | ( + # Keep "/* */" (etc) as is + "(?: \\. | [^"\\]++)*" + # Keep '/**/' (etc) as is + | '(?: \\. | [^'\\]++)*' + # Keep anything else + | .[^/"'\\]*+ + ) + }{defined $1 ? $1 : ""}xgse; + return $block; +} + # try to detect non human source based on line length sub _linelength_test { my ($entry, $info, $name, $basename, $dirname, $block) = @_; @@ -1034,6 +1057,22 @@ sub _linelength_test { # clean up jslint craps line $block =~ s,^\s*/[*][^\n]*[*]/\s*$,,gm; $block =~ s,^\s*//[^\n]*$,,gm; + $block =~ s/^\s+//gm; + + # try to remove comments in first 8192 block (license...) + my $block8192 = substr($block,0,8192); + $block8192 = _strip_c_comments($block8192); + $block + = length($block) > 8192 + ? $block8192.substr($block,8192) + : $block8192; + + # strip empty line + $block =~ s/^\s*\n//mg; + # remove last \n + $block =~ s/\n\Z//m; + + # retry insane line length test now: if insane length likely minified ($linelength)= _linelength_test_maxlength($block,INSANE_LINE_LENGTH); if($linelength) { @@ -1046,22 +1085,8 @@ sub _linelength_test { # in order to avoid regexp recursion problems my $strip = substr($block,0,8192); # strip indention - $strip =~ s/^\s+//g; - # from perl faq strip comments - $strip =~ s{ - # Strip /* */ comments - /\* [^*]*+ \*++ (?: [^/*][^*]*+\*++ ) */ - # Strip // comments (C++ style) - | // (?: [^\\] | [^\n][\n]? )*? (?=\n) - | ( - # Keep "/* */" (etc) as is - "(?: \\. | [^"\\]++)*" - # Keep '/**/' (etc) as is - | '(?: \\. | [^'\\]++)*' - # Keep anything else - | .[^/"'\\]*+ - ) - }{defined $1 ? $1 : ""}xgse; + $strip =~ s/^\s+//mg; + $strip = _strip_c_comments($block); # strip empty line $strip =~ s/^\s*\n//mg; # remove last \n diff --git a/debian/changelog b/debian/changelog index 7b541d9..beb11da 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ lintian (2.5.41) UNRELEASED; urgency=medium + [BR] Filter some simple comments for long line in source-is-missing (Closes: #798900). + [BR] Detect pandoc docs avoiding source-is-missing warning. + + [BR] Fix other source-is-missing FP. (Closes: #813013). * checks/files.pm: + [JW] Treat packages without Multi-Arch field as if they had "Multi-Arch: no". Thanks to Bas Couwenberg for the bug report. diff --git a/t/tests/cruft-minified-js/debian/oldfalsepositives/longlicensetext.js b/t/tests/cruft-minified-js/debian/oldfalsepositives/longlicensetext.js new file mode 100644 index 0000000..66222ee --- /dev/null +++ b/t/tests/cruft-minified-js/debian/oldfalsepositives/longlicensetext.js @@ -0,0 +1,30 @@ +/* long line in fake license */ +/* + * LICENSE + * + * POCKET MARKS + * + * Notwithstanding the permitted uses of the Software (as defined below) pursuant to the license set forth below, "Pocket," "Read It Later" and the Pocket icon and logos (collectively, the “Pocket Marks”) are registered and common law trademarks of Read It Later, Inc. This means that, while you have considerable freedom to redistribute and modify the Software, there are tight restrictions on your ability to use the Pocket Marks. This license does not grant you any rights to use the Pocke [...] + * + * --- + * + * SOFTWARE + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ diff --git a/t/tests/cruft-minified-js/tags b/t/tests/cruft-minified-js/tags index 8c825b7..68f3714 100644 --- a/t/tests/cruft-minified-js/tags +++ b/t/tests/cruft-minified-js/tags @@ -2,6 +2,7 @@ E: cruft-minified-js source: source-is-missing deployJava/deployJava.js E: cruft-minified-js source: source-is-missing usr/share/javascript/jswithoutminextwithoutsource/jsonnotsourced.js line length is NUMBER characters (>CUTOFF) E: cruft-minified-js source: source-is-missing usr/share/javascript/minwithoutsource/notsourced.min.js P: cruft-minified-js source: insane-line-length-in-source-file oldfalsepositives/jslint.js line length is NUMBER characters (>CUTOFF) +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 oldfalsepositives/-debug.js/src/test-min.js -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git