Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

RFC: Test::Copyright

by SilasTheMonk (Chaplain)
on Jun 13, 2011 at 21:21 UTC ( #909453=perlmeditation: print w/ replies, xml ) Need Help??

Experience in packaging perl modules from CPAN , suggests that most CPAN authors are woefully ignorant of copyright and licensing issues. Unfortunately I have been provoked into attempting to do something about this. I present Test::Copyright. I would appreciate feedback not least on the idea.

Edit: Thanks for the feedback, monks!

I need to completely revamp the documentation as the reaction so far has been quite negative overall. I will have a stab here, but first I have to come clean that I have been packaging for Debian. The argument was internal to Debian and centred about how best to "help" the Debian Perl team. My experience is that in easy cases it only takes a few minutes to package a Perl module for Debian. Harder cases tend to be caused by things like this:

  • Fails to build: There is not a lot that can be done there as it is adequately captured by the CPAN testing.
  • Spelling errors: Again this is already dealt with upstream by Test::Spelling. Still many many spelling errors slip through.
  • Bad pod documentation: Again Test::Pod should cover that but many modules have a missing or an extra "=back".
  • Bad shebang in the examples scripts: This is crops up quite a bit, but in no way can I argue that it is an issue for upstream.
  • Inadequate copyright or license information: This is really the killer. But clearly I need to explain why.

Seeing the negative feedback I had a look at the Fedora licensing guidelines. Indeed you will notice that Fedora cares just as much as Debian about the presence of a license. But it seems not to care as much about the copyright. However the Fedora guidelines say:

In cases where the licensing is unclear, it may be necessary to contact the copyright holders to confirm the licensing of code or content. In those situations, it is _always_ preferred to ask upstream .....

I read this as saying that Fedora are assuming that upstream and the copyright holders are always the same, which may not be always entirely true. Debian takes the alternative policy of tracking the the status of the copyright holders explicitly.

Comment on RFC: Test::Copyright
Re: RFC: Test::Copyright
by Tux (Monsignor) on Jun 13, 2011 at 22:16 UTC
      That only seems to cover the license and that was much the easier part.
Re: RFC: Test::Copyright
by mirod (Canon) on Jun 14, 2011 at 10:31 UTC

    Do we really need this? (ob IANAL but...) it seems to me that by default everything is copyrighted so there is no need to mention it.

    Also, from the docs, the module tests "That the said default copyright statement has at least one final year that matches the current year". The code seems to be supporting this. Why? If I have a module that hasn't been updated since 2006, why would the copyright mention 2011 at all? Does this also means that a test that passes on December 31st 2011 will stop passing on January 1st 2012? That seems a little extreme, not to mention impolite.

      If I were to use this, it would probably be in a 'releasetest' target or somesuch -- something only run at release time. I see it as only applying at release time, so why run it at any other time.

      --MidLifeXis

      Do we really need this? (ob IANAL but...) it seems to me that by default everything is copyrighted so there is no need to mention it.

      I have clarified the issues in my original post.

      Also, from the docs, the module tests "That the said default copyright statement has at least one final year that matches the current year". The code seems to be supporting this. Why? If I have a module that hasn't been updated since 2006, why would the copyright mention 2011 at all? Does this also means that a test that passes on December 31st 2011 will stop passing on January 1st 2012? That seems a little extreme, not to mention impolite.

      My assumption was that this would only be run by module authors just prior to release. So the default copyright should be uptodate. Individual files only have to match a subset of the default range.

Re: RFC: Test::Copyright
by sundialsvc4 (Abbot) on Jun 14, 2011 at 16:13 UTC

    The year of a copyright does not have to be the present year.   Perhaps you could test that a copyright notice exists or not, but I find it difficult to consider how “copyright” could be a meaningful Test subject.

    Edit:   Intended only as an observation, not “negative feedback!”

Re: RFC: Test::Copyright
by Tux (Monsignor) on Jun 15, 2011 at 06:00 UTC
    $ perl Makefile.PL Checking if your kit is complete... Looks good Warning: prerequisite Lingua::EN::NameParse 0 not found. Warning: prerequisite Perl6::Slurp 0 not found. Writing Makefile for Test::Copyright

    Those are two modules that I do not have installed on my test machine (with over 7100 modules installed). That looks like something overly complicated for such a simple module and I'm for sure not going to install those to test/use this new module.


    Enjoy, Have FUN! H.Merijn
Re: RFC: Test::Copyright
by mirod (Canon) on Jun 15, 2011 at 09:27 UTC

    To me it looks like Fedora's policy makes sense: In cases where the licensing is unclear.... So if the license is clear, there should be no need to care about the copyright. The author field should be enough.

    That said, if this helps the Debian packagers, then why not.

    Is there somewhere a list of best practices for modules that would help reduce the packagers work load? Something like the list in your post, but maybe better formalized, ideally as a single test file, to be included, as t/debian.t for example, in distributions?

Re: RFC: Test::Copyright
by Tux (Monsignor) on Jun 15, 2011 at 09:48 UTC
    Fails to build: There is not a lot that can be done there as it is adequately captured by the CPAN testing.

    Well, actually you could reduce the number of dependencies. This module doesn't need Perl6::Slurp at all, as it is easy to do without.

    --- lib/Test/Copyright.pm.org 2011-06-15 11:36:34.179000011 +0200 +++ lib/Test/Copyright.pm 2011-06-15 11:35:08.949000008 +0200 @@ -10,7 +10,6 @@ use Test::More; use CPAN::Meta; use Software::LicenseUtils; use Readonly; -use Perl6::Slurp; use UNIVERSAL::require; use Lingua::EN::NameParse; use Email::Address; @@ -141,6 +140,13 @@ sub _software_licenses_ok { return @licenses; } +sub slurp { + my $filename = shift; + open my $fh, "<", $filename or die "$filename: $!"; + local $/; + return <$fh>; +} + sub _cpan_meta_ok { foreach my $file (@META_FILES) { if (-r $file) {

    After that, and installing mod::

    All tests successful. Files=9, Tests=12, 0 wallclock secs ( 0.03 usr 0.02 sys + 0.47 cusr + 0.04 csys = 0.56 CPU) Result: PASS

    Now let me use that on a module I consider perfect:

    $ perl -MTest::Copyright -MTest::More -wle'copyright_ok (); done_testi +ng' not ok 1 - found CPAN::Meta file # Failed test 'found CPAN::Meta file' # at /pro/lib/perl5/site_perl/5.12.2/Test/Copyright.pm line 91. ok 2 # skip No CPAN::Meta object 1..2 # Looks like you failed 1 test of 2. Exit 1 $

    Well, of course, there is no META.yml during testing. That is generated in a make dist.

    I'm not here to add only negative critiques. I'm very much into any means to increase the quality (kwalitee) of my modules, and I'm also very curious about how others think that can be achieved. So far I have however seen no additional value in this module in the form it is currently presented.

    FWIW, I have created a meta-target in most of my Makefile.PL's that does all quality checks I can imagine. Of course that is only run after I have used Module::Release to check the module against all available and supported perl builds (I have over 70).

    $ make tgzdist pod-spell-check --aspell ok 1 - CSV_XS.pm ok 2 - sandbox/i-ttt/lib/i/ttt.pm 1..2 ok 1 - CommonMistakes ok 1 - CSV_XS.pm ok 2 - sandbox/i-ttt/lib/i/ttt.pm 1..2 ok 2 - Spell-check with aspell 1..0 # SKIP Ispell not selected ok 3 # skip Ispell not selected 1..3 perl sandbox/genPPPort_h.pl perl sandbox/genMETA.pl -c Check if ChangeLog and README are still valid UTF8 ... Check required and recommended module versions ... Checking generated YAML ... Checking if 5.006 is still OK as minimal version for examples 1..5 ok 1 - examples/speed.pl ok 2 - examples/csv-check ok 3 - examples/parser-xs.pl ok 4 - examples/csv2xls ok 5 - examples/csvdiff rm -rf Text-CSV_XS-0.83 /pro/bin/perl "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'Text-CSV_XS-0.83', 'best');" mkdir Text-CSV_XS-0.83 mkdir Text-CSV_XS-0.83/examples mkdir Text-CSV_XS-0.83/t mkdir Text-CSV_XS-0.83/files META.yml not found at -e line 1 Generating META.yml perl sandbox/genMETA.pl tar cvf Text-CSV_XS-0.83.tar Text-CSV_XS-0.83 Text-CSV_XS-0.83/ : Text-CSV_XS-0.83/Makefile.PL rm -rf Text-CSV_XS-0.83 gzip --best Text-CSV_XS-0.83.tar /pro/bin/perl "-MExtUtils::Manifest=fullcheck" -e fullcheck No such file: META.yml Checked dist Text-CSV_XS-0.83.tgz Kwalitee rating 130.43% (30/23) Ignoring metrics is_prereq, prereq_matches_use, build_prereq_ma +tches_use $

    Enjoy, Have FUN! H.Merijn

      When I extract the META.yml from the generated archive, just to see what Test::Copyright would do:

      $ perl -MTest::Copyright -MTest::More -wle'copyright_ok (); done_testi +ng' ok 1 - found CPAN::Meta file isa CPAN::Meta ok 2 - more than zero licenses ok 3 - Found a good license object ok 4 - more than zero recognised licenses ok 5 - found license file: README not ok 6 - Found license perl in file README # Failed test 'Found license perl in file README' # at /pro/lib/perl5/site_perl/5.12.2/Test/Copyright.pm line 208. Use of uninitialized value $holder in anonymous hash ({}) at /pro/lib/ +perl5/site_perl/5.12.2/Test/Copyright.pm line 267, <DATA> line 102. ok 7 - Found default copyright details ok 8 - final copyright year is uptodate Use of uninitialized value $holder in exists at /pro/lib/perl5/site_pe +rl/5.12.2/Test/Copyright.pm line 314. Use of uninitialized value $holder in hash element at /pro/lib/perl5/s +ite_perl/5.12.2/Test/Copyright.pm line 318. Use of uninitialized value $holder in exists at /pro/lib/perl5/site_pe +rl/5.12.2/Test/Copyright.pm line 314. Use of uninitialized value $holder in hash element at /pro/lib/perl5/s +ite_perl/5.12.2/Test/Copyright.pm line 318. ok 9 - File blib/lib/Text/CSV_XS.pm has copyright statement ok 10 - Copyright for blib/lib/Text/CSV_XS.pm is described centrally 1..10 # Looks like you failed 1 test of 10.

      I think that this can all use a bit of cleanup.


      Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://909453]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-12-21 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (101 votes), past polls