Lintian checking ARB packages

Bhavani Shankar R bhavi at ubuntu.com
Mon Dec 31 14:27:26 UTC 2012


On Mon, Dec 31, 2012 at 7:28 PM, Niels Thykier <niels at thykier.net> wrote:
> On 2012-12-31 14:19, Bhavani Shankar R wrote:
>> On Thu, Dec 27, 2012 at 4:05 PM, Niels Thykier <niels at thykier.net> wrote:
>>> [...]
>>
>>>  * test_has_maintainer_scripts
>>>    - checks/debhelper might be useful as an example.
>>
>> Yes checks/debhelper has the required functionality I believe when I
>> checked for maintainer scripts. and Indeed it has some dh_ checks.
>> Thanks Niels!
>>
>>>  * test_is_lightweight_app
>>>    - checks/cruft might be useful as an example (e.g. File::Find
>>>      and $info->unpacked)
>>
>> Looked at $info->unpacked, but as ARB, I think we define lightweight
>> app in terms of code if m not wrong, (If you have a look at the
>> snippet below:
>>
>>  @requires('source_files')
>>     def test_is_lightweight_app(self):
>>         source_file_extensions = [ ".py", ".rb", ".vala", ".c", ".h", ".cpp",
>>                 ".cc", ".hh", ".pm", ".java", ".js", ".pl" ]
>>         number_of_max_source_files = 30
>>         number_of_max_lines_of_code = 15000
>>         source_code_files = filter(lambda a: os.path.splitext(a)[1] in
>> source_file_extensions,
>>                                    self.source_files)
>>         loc = sum(map(lambda a: len(open(a).readlines()), source_code_files))
>>         if len(source_code_files) >= number_of_max_source_files or \
>>            loc >= number_of_max_lines_of_code:
>>
>> indicates the same)
>>
>> Wanted your inputs on whether this type of check is feasible in lintian.
>>
>
> I believe it is feasible to do.  In its basics it would look something like:
>
>   use Lintian::Util qw(fail);
>
>   [...]
>
>   my $no_files = 0;
>   my $no_lines = 0;
>   foreach my $filename ($info->sorted_index) {
>       next unless $info->index ($filename)->is_file;
>       next unless $filename =~ m/\.(?:py|rb|vala|...)$/;
>       my $fpath = $info->unpacked ($filename);
>       $no_files++;
>       last if $no_files > 30;
>       open my $fd, '<', $fpath or fail "open $fpath: $!";
>       foreach my $line (<$fd>) {
>           $no_files++;
>       }
>       close $fd;
>       last if $no_lines > 15000;
>   }
>   if ($no_files > 30) {
>       tag 'too-many-files', $no_files, '> 30';
>   }
>
>   if ($no_lines > 30) {
>       tag 'too-many-lines-of-source', $no_lines, '> 15 000';
>   }
>
> Of course, it is probably possible to replace some of the loop with
> stuff like grep and map (though I am not sure it makes it more readable
> or concise for that matter).
>

Thanks Niels for the uber quick response. I will have a look at the
same and improvise (if anything possible)

>>> [...]
>>
>>
>> Thanks Niels for your everlasting patience and reviews :)
>>
>> Regards,
>
> You are more than welcome.  On a related note, I have devised a short
> POD tutorial in commit 0b7b5d86a502c27ce61c5b1157d43fa7de4b8b19.  It
> will show up in the API docs (run "debian/rules api-doc").
>   I am not sure it teaches you anything atm, but feel free to send
> suggestions or patches for it.  :)
>
> ~Niels
>


Sure Niels, I'll definitely have a look at the commit and get back to
you :) With this, ARB lintian should be in place hopefully. Thanks a
lot again and Happy new year to you in advance!

Regards,

-- 
Bhavani Shankar
Ubuntu Developer       |  www.ubuntu.com
https://launchpad.net/~bhavi



More information about the App-review-board mailing list