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

Bug#798900: lintian: false positive: source-is-missing for non-minified JS files



Hi,

good question… One might think of whitespace-to-filesize ratio? With indentation and line breaks human-readable code is expected to have vastly a different ratio than a minified version. Example for jQuery:

$ ruby -e 'puts (f=ARGF.read).scan(/\s/).size/f.size.to_f' < jquery-2.1.4.js
0.24018465490292693
$ ruby -e 'puts (f=ARGF.read).scan(/\s/).size/f.size.to_f' < jquery-2.1.4.min.js
0.015472167881913568

The non-minified version is 1/4 whitespace! In contrast, the minifies version has just 1.5%.
It’s difficult… if you have a JS parser ready you can also compute the ratio of one-letter variables/functions vs. total number. These will be off by a lot as well.

Cheers
Sascha

> On 14 Sep 2015, at 19:55, Bastien ROUCARIES <roucaries.bastien@gmail.com> wrote:
> 
> On Mon, Sep 14, 2015 at 6:58 PM, Mattia Rizzolo <mattia@mapreri.org> wrote:
>> control: affects -1 inkscape
>> 
>> On Sun, Sep 13, 2015 at 09:46:37PM +0000, Sascha Steinbiss wrote:
>>> I noticed today that there were two new Lintian errors on DDPO for my 'aegean'
>>> package (https://lintian.debian.org/maintainer/sascha@steinbiss.name.html#aegean).
>>> These seem to be fairly recent, and I took a look to see what could be wrong.
>>> 
>>> Looks like the JQuery DataTables libraries included are flagged as minified
>>> without source on the basis that they have lines longer than 1024 characters:
>>> $ lintian -V
>>> Lintian v2.5.37
>>> $ lintian --info --display-info --display-experimental --pedantic --show-overrides aegean_0.13.0+dfsg-1.dsc
>>> P: aegean source: source-contains-prebuilt-javascript-object data/share/vendor/jquery.dataTables.js line length is 1397 characters (>1024)
>>> [...]
>>> E: aegean source: source-is-missing data/share/vendor/jquery.dataTables.js
>>> [...]
>>> 
>>> But this file is not minified, it's there as full source code -- there is only one
>>> line (l.24) which is quite long (>1300 chars). I think this is a false positive
>>> (that has been recently introduced?) and looking at the line length alone is
>>> probably not sufficient to reliably identify minified JS.
>>> Any comments?
>> 
>> Same thing for inkscape, though my line is 266 characters (>256) (I
>> argue 256 is a really low number for such a check, and I wonder why
>> Sascha report says another number).
> 
> It is really over 80 cols. Do you have other idea in order to check ?
> Maybe entropy of the line but I do not know how to compute it in
> javascript, and where to put the level
> 
> Bastien
> 
>> --
>> regards,
>>                        Mattia Rizzolo
>> 
>> GPG Key: 66AE 2B4A FCCF 3F52 DA18  4D18 4B04 3FCD B944 4540      .''`.
>> more about me:  http://mapreri.org                              : :'  :
>> Launchpad user: https://launchpad.net/~mapreri                  `. `'`
>> Debian QA page: https://qa.debian.org/developer.php?login=mattia  `-


Reply to: