Perl::Critic: Life after Moose?

為{幸葍}努か 提交于 2019-12-03 10:00:19

Have you seen Perl::Critic::Moose?

Both of them can be configured into detail.

I have no idea why perltidy wouldn't like it, it has nothing to do with it. Perltidy only governs style. You can change the style of your code without changing any functionality, it's mostly a matter of whitespace really. You should either change your style or change the perltidy configuration using the .perltidyrc file.

I don't know what problems perlcritic has with it (lvalue methods perhaps?), but you could consider turning off those specific policies using the .perlcriticrc file. Also, if your perlcritic is old you may want to upgrade it, as some old versions gave some incorrect errors in Moose classes.

Earlier versions of Perl::Critic's "use strict" policy wasn't aware of Moose enabling strict for you, but that'll be fixed if you upgrade Perl::Critic.

I use both Perl::Critic and Perl::Tidy with Moose, and I don't see anything particularly broken. Well, actually, I can't get Perl::Tidy to layout things like this properly:

my $apple = Apple->new({
    color => "red",
    type  => "delicious",
});

Tidy will insist that ( and { are two opening levels of indentation, and it will just look this silly:

my $apple = Apple->new({
        color => "red",
        type  => "delicious",
});

But we had this problem before; the coding convention in the project is to use a hashref, not a hash, for named parameters. So it's not really a Moose related problem as such.

What exactly are your symptoms?

/J

I have no problem with Critic tests - admittedly I run at severity=3, at least in part because some of what I have to work with is legacy code that I don't have /time/ to tidy, but my Moose stuff sails through that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!