Mark Gardner ‍:sdf: · @mjgardner
713 followers · 4940 posts · Server social.sdf.org

@eliasp @ColinTheMathmo BTW has two well-known tools to encourage and enforce style and best practices, respectively:
: perltidy.github.io/perltidy
: perlcritic.com

Your project or team can use their reasonable defaults or further configure them to reflect and maintain the consistent application of your preferences. They also integrate with editors/IDEs, source control management, and author .

#perl #programming #perltidy #perlcritic #testing

Last updated 1 year ago

Mark Gardner ‍:sdf: · @mjgardner
698 followers · 4598 posts · Server social.sdf.org

@dakkar @Perl `use v5.36;` or later will disable indirect object syntax.

And the MetaCPAN.org/pod/Perl::Critic: policy will catch it.

You mandate things by adding to your tests or pre-commit hooks, not by relying on your team’s individual vigilance

#perl #perlcritic

Last updated 1 year ago

aegilops :github::microsoft: · @aegilops
147 followers · 566 posts · Server fosstodon.org

@ovid and other Perl :perl: mongers. What, if anything, do you use for code security?

I know that using taint gets you far, but SAST is mostly what I’m thinking (especially for legacy code without taint). Any tips?

Does Perl::Critic do a decent job, and is there a list of what its security policy and 3rd party plug-ins cover?

Other OS SAST I found are: github.com/htrgouvea/zarn and this grep-based one: github.com/wireghoul/graudit

Are they OK?

#sast #perl #appsec #codesecurity #perlcritic

Last updated 1 year ago

Mark Gardner ‍:sdf: · @mjgardner
661 followers · 4097 posts · Server social.sdf.org

@regehr @commodore @dev There is even a (low-severity, a/k/a “cruel”) policy to discourage everything but $_, @_, $], and numbered capture variables: metacpan.org/pod/Perl::Critic:

metacpan.org/pod/Perl::Critic: already protects you against the performance-sapping $`, $&, and $' match variables

And you can configure your own prohibited list with metacpan.org/pod/Perl::Critic:

#perlcritic #regularexpression #perl #regex #regexp #regexes #regexps

Last updated 1 year ago

Mark Gardner ‍:sdf: · @mjgardner
650 followers · 3961 posts · Server social.sdf.org

@rrwo Neat! TIL about the Sub::Util module and its `set_prototype` function: perldoc.perl.org/Sub::Util#set

Did you switch to that in github.com/robrwo/Hash-Util-Me just to remove noise, or was there another reason?

#perl #perlcritic

Last updated 1 year ago

Mark Gardner ‍:sdf: · @mjgardner
612 followers · 3409 posts · Server social.sdf.org

@rbairwell @barubary Conway notes some problems with AUTOLOAD in “Perl Best Practices” (2005) and there is a severity 3 policy against it provided with : metacpan.org/pod/Perl::Critic:

Basic problems are: first AUTOLOAD wins in a class hierarchy; your AUTOLOAD has to handle/reject everything cleanly and is therefore an infinitely complex interface; AUTOLOAD gets called on object destruction if the class is missing an explicit DESTROY method

#perl #perlcritic

Last updated 2 years ago

· @barubary
34 followers · 447 posts · Server infosec.exchange

@rrwo In my experience, functions that return scalars are much more common than functions that return multiple values (lists), so all else being equal, return undef; is much more likely to be correct than return; in a function that returns a value.

I'm not a fan of the default policies in general, but this one is just wrong.

#perlcritic

Last updated 2 years ago

Mark Gardner ‍🤑 · @mjgardner
496 followers · 2131 posts · Server social.sdf.org
Mark Gardner ‍🤑 · @mjgardner
496 followers · 2131 posts · Server social.sdf.org

@jens @RL_Dane @stoerdebegga One reason I choose is its expressivity without being too “large” of a language. (This last is why I still haven’t wrapped my head around —they threw so much into its core.)

I use and to set fairly strict defaults, but both have escape hatches for code islands that need to bend the rules for whatever reason (e.g. better modeling or critical-path performance, or sometimes fencing off legacy code to be brought up to spec later).

#perl #rakulang #perlcritic #perltidy

Last updated 2 years ago

· @barubary
34 followers · 447 posts · Server infosec.exchange

@RL_Dane Hah. Great question. The default policies are based on a book by Damian Conway (Perl Best Practices), many of which I disagree with.¹ (In fact, I would recommend avoiding any Conway modules in your dependency chain.) So I don't think the perlcritic defaults are sane, but alternatives are available (e.g. metacpan.org/pod/Perl::Critic:).

¹ From what I recall, a central point of the book is that the policies are not a "one size fits all" solution, but that you should consciously evaluate each recommendation and whatever the result, write it down (along with your rationale). That way you end up with a useful and consistent style guide for your org, even if you disagree with every single recommendation.

#perl #perlcritic

Last updated 2 years ago

Mark Gardner ‍🤑 · @mjgardner
496 followers · 2131 posts · Server social.sdf.org

#perltidy #perlcritic

Last updated 2 years ago

Mark Gardner ‍🤑 · @mjgardner
496 followers · 2131 posts · Server social.sdf.org

@RL_Dane @jens @stoerdebegga is not a module you ordinarily use. It is a command you run: metacpan.org/dist/Perl-Critic/

Or a test you incorporate via something like metacpan.org/pod/Test::Perl::C or metacpan.org/pod/Test2::Tools:.

It would not make a lot of sense to require you to modify all your code to make sure it complies.

Default is to only report severe violations from all installed policies. The core policies are summarized here: metacpan.org/dist/Perl-Critic/

#perlcritic

Last updated 2 years ago

Mark Gardner ‍🤑 · @mjgardner
496 followers · 2131 posts · Server social.sdf.org

@RL_Dane @jens @stoerdebegga Opinions vary on how, but you should always check the return value of `open`. metacpan.org/pod/Perl::Critic: enforces that.

I like autodie: perldoc.perl.org/autodie

General consensus is that `unless` is confusing and postfix conditionals are too, except when used in flow control. metacpan.org/pod/Perl::Critic: and metacpan.org/pod/Perl::Critic: enforce that.

Since opinions vary, codify your projects’ standards in ’s configuration to settle arguments: metacpan.org/pod/Perl::Critic#

#perlcritic

Last updated 2 years ago

Mark Gardner ‍🤑 · @mjgardner
496 followers · 2102 posts · Server social.sdf.org
Mark Gardner ‍🤑 · @mjgardner
496 followers · 2102 posts · Server social.sdf.org

@jens @RL_Dane @stoerdebegga (I also think every distribution should include and configs and author tests to encourage consistently-written contributions.)

#cpan #perltidy #perlcritic

Last updated 2 years ago

Mark Gardner ‍🤑 · @mjgardner
416 followers · 1569 posts · Server social.sdf.org

@sjn @cb 99% of the “ is line noise” complaints are because of unformatted . Every language worth anything eventually supports them, but only @Perl (and , earlier) makes them first-class citizens. And with Perl you can format and comment them for readability: perldoc.perl.org/perlretut#Emb

We format the rest of our code for humans. Why not ?

can warn against bad regexps: metacpan.org/search?size=200&q

#perl #regularexpressions #awk #regexps #perlcritic #regex #regexes #programming #coding #softwaredevelopment

Last updated 2 years ago

Mark Gardner ‍🤑 · @mjgardner
406 followers · 1454 posts · Server social.sdf.org

@smxi @ChristosArgyrop Of course, there’s a policy to slap you on the wrist if you’re tempted to do such a rude thing as automatically export into a caller’s namespace: metacpan.org/pod/Perl::Critic:

#perlcritic

Last updated 2 years ago

Mark Gardner · @mjgardner
377 followers · 1200 posts · Server social.sdf.org

@ChristosArgyrop @Perl In answer to your question about symbolic references on the Twitter community (twitter.com/ChristosArgyrop/st), I still find them useful when you want to dynamically define things in the symbol table like functions/methods. Though Package::Stash provides a nice API for that so you don’t have to litter your code with `no strict 'refs'` and attendant annotations. metacpan.org/pod/Package::Stas

#perl #perlcritic

Last updated 2 years ago

Mark Gardner · @mjgardner
347 followers · 752 posts · Server social.sdf.org

@chrisjrob @snonux @Perl and also help with readable, maintainable, and consistent code. I like to joke that I don’t have a style, I have a perlcritic policy.

#perltidy #perlcritic #perl

Last updated 2 years ago

Mark Gardner · @mjgardner
296 followers · 495 posts · Server social.sdf.org

@living8bit FWIW it’s bad form to use $a and $b for your own variables unless they’re local to a block. They’re magic inside a sort block perldoc.perl.org/functions/sor

Here’s the relevant policy: metacpan.org/pod/Perl::Critic:

#perl #perlcritic

Last updated 2 years ago