-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convention for noting that a dist is intentionally not using strict and warnings #39
Comments
Good point. How about adding something like |
yeah, that sounds good. |
The "special comments" approach has the benefit of working with any intentionnaly ignored module, for any checking tool. It has the big drawback of cluttering the code, which becomes even more annoying if the distribution contains several modules. The META option can be used by other tools than CPANTS, and does not clutter the code. Given that intentionnaly not using some module seems to be a distribution-level choice for an author, going the META route makes more sense. What about |
The comments approach also has the advantage that it's self documenting, so someone looking at the code thinking "ha, the bozo hasn't even used strict or warnings", gets to see a comment why. That said, I prefer the metadata approach. There should just be a comment as well :-) |
It's ok for me to support something like I'd rather stick to Comments to explain why you don't use some modules would always be nice, but comments to trick CPANTS / Module::ExtractUse may not work in the future, especially when someone makes a faster and more reliable module detector than M::EU with something like Compiler::Lexer / Perl::Lexer. |
That can end up producing some nasty warnings:
You need to go further and clean all the subs defined by strict.pm out of the symbol table:
This may cause problems if somebody has taken a reference to something that lived in |
I've added the topic for discussion to the Perl QA Hackathon project page. |
It's pretty clear from that what the author's intention is, and no sugar in comments is necessary. |
I sort of like Karen's self-documenting suggestion, but I prefer @charsbar's suggestion of a top-level
That keeps the top-level of the META pretty clean and allows for future hints to x_cpants other than 'ignore'. |
|
Hmm, maybe I'm arriving a bit late in the discussion, but I remember have a similar one a few years ago, when domm first added the "use strict" metric, and I made the same remark, because I maintain the CPAN version of XSLoader, which deliberately does not use strict. The discussion was to add a commented statement (#use strict;) but I can't remember if the handling was implemented in CPANTS. @dagolden warnings::compat provides a warnings module for older Perls |
@maddingue yes, but then I would have to specify a dependency on warnings::compat, simply to be able to say |
@maddingue but you use warnings. I don't think that's crazy at all. What I think is crazy is to make warnings::compat a prereq only to say "You must have this thing installed so I can tell you that I'm not using it!" :-) |
In the interests of bikeshedding, I'd like to propose:
This way people don't just get a free pass to ignore a metric - they actually need to provide an excuse. The excuses for ignored metrics could be displayed as part of the distribution overview on the CPANTS website. |
On Sun, Mar 16, 2014 at 07:16:07AM -0700, Toby Inkster wrote:
+1 |
I have no objection to providing an excuse, but I still want only a single
That way, any future CPANTS hints can go in the same place. |
|
+1 to Toby for having to give excuse I think of it as CPANTS is the system that produces the kwalitee measure, hence x_cpants is a hint to the system that measures kwalitee. |
Just a thought.
|
@rwfranks because some people might want to stay back-compat before 5.6. Read up in the thread again for details. |
[apologies: my mouse battery just died and jumped on the comment button before I'd finished] CPANTS already knows (or has complained about) minimum perl version, so can avoid penalising pre-5.6 packages. |
@rwfranks: there are a number of modules which tell you what modules were used in your code. For example Devel::Dependencies (which I now maintain), Devel::TraceUse and others. For these modules we just won't want
will still report that the warnings module was loaded. There are modules that try to be smarter about handling this, but I'm not maintaining any of those :-) |
I was attempting to breathe life back into Karen E.'s clean and tidy suggestion, by answering David G.'s backward compatibility objection. A distro with a properly declared ancient perl version in its meta data should be scored as if it had "use warnings" declared in each of its components. "no warnings" and "use warnings" should be treated as equivalent for the purposes of the test. This expresses the idea that the author has some settled opinion about warnings (5.6+), or is prevented from making this explicit by an overriding compatibility requirement (pre-5.6). If the parser does not have easy access to the meta data, an alternative (somewhat clumsy) mechanism would be to declare the version in the package:
If you are troubled by the idea that authors could fiddle the score by unsubstantiated claims in the meta data, syntax could be checked using the appropriate perl rev with appropriate penalty point tariff applied. |
That's an interesting idea. Whether from metadata or from code, declaring an old perl version as a dependency then scores warnings differently. Even That doesn't help with strict, but then I'm fine with the idea that "no strict" is used to be explicit.
That would work for me and avoids junking up META. |
As of this writing...
I don't think it a good idea to modify the behavior of I'm also supposing |
The 'use warnings' test is meaningless when applied to a distro declaring a dependency on pre-5.6 perl in its meta data. Whether you record a "pass" or "N/A" in the database, and where in the code you do it, are matters for you decide. It is gross miscarriage of justice to penalise code merely for still being alive after 15 or 20 years. 'use warnings' and 'no warnings' are equally good indications that the author has engaged with the topic sufficiently to decide one way or the other. There is no need for CPANTS to record whether the negative form of pragma was used, or to do anything different with it. Knobbling the front-end of the analyser to turn 'no warnings' into 'use warnings' on the fly would solve the problem admirably. Deal with 'no strict' in a similar way. There is clearly some value in doing this, otherwise nobody would be discussing it here. |
On Sat, Mar 22, 2014 at 07:20:21AM -0700, rwfranks wrote:
"penalise" is a bit harsh since this is just a heuristic. No one's being Here's a suggestion for a way forward: we could introduce a third state for |
As for
That said, introducing a third state is a todo that I couldn't finish during the QAH this year. I thought of missing META.* for META related metrics etc, and also of tentative metrics (such as prereq stuff) that can't be determined until everything is settled, but it might be applicable to |
Being able to exclude files or directories from Kwalitee checking would mean that testing files aren't picked up in error: http://cpants.cpanauthors.org/dist/Dist-Zilla-Plugin-NexusRelease-0.0.1/errors All 3 of those fails are for a file that's there to be used as a test subject; and one of the fails is that the test subject library isn't in the lib/ directory... |
@brad-mac that's because you haven't excluded anything. See the following: |
Nice - and that's documented now (assuming other people go through the same set of Google searches I did and end up here) in a way that I find a bit more obvious. There wasn't anything that jumped out at me about indexing in the Test::Kwalitee docs or on http://cpants.cpanauthors.org/kwalitee. Thanks! |
@karenetheridge whichever is ok as long as it excludes stuff in |
Thanks Karen - much better than my first attempt with [MetaProvides::Class] :-) @charsbar, I've forked M:C:A and added some documentation to the 'remedy' for 'proper_libs' - hope that's up to scratch. |
@brad-mac, thanks. The source of your fork is an old one, but applied it by hand anyway: cpants/Module-CPANTS-Analyse@b6a525e |
More usecases for this metadata:
|
It would be handy if I could include a comment like the following my my code
Or non CPANTS-specific:
This would flag that there's a reason why I'm not using strict and warnings, so don't fail me on that please :-)
See the discussion on questhub for a quest to get all one's dists "CPANTS clean". Both @book and I have modules (Devel::TraceUse and Devel::Dependencies respectively) where we don't want to use strict and warnings because it will affect the behaviour of the modules.
@tobyink suggested the following:
Which I did, but now CPANTS is complaining because my declared dependencies don't match my code :-)
Which means I have to do one of:
The text was updated successfully, but these errors were encountered: