views:

1104

answers:

5

I've started a conversion of a project to Moose and the first thing I noticed was that my critic/tidy tests go to hell. Moose, Tidy and Critic don't seem to like each each other as much as they used to.

Are there docs anywhere on how to make critic/tidy be more appreciative if the Moose dialect? What do most Moose users do? Relax/ditch critic for the more heavy Moose modules? Custom policies?

+6  A: 

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.

Leon Timmermans
Well, I guess more to the point. Does anyone have a criticrc/perltidyrc that is tweaked for Moose-based projects? Every time I deviate form the stock tidy rc, I feel dirty, and usually end up making things worse. :-)
claco
Added: Perltidy only governs style. You can change the style of your code without changing any functionality, it's mostly a matter of whitespace really.
Leon Timmermans
Moose does not create lvalue methods for you. I don't even think there's a MooseX extension for this.
Dave Rolsky
PerlTidy can't handle MooseX::Method::Signatures, thinks there are syntax errors everywhere and mangles indentation :(
Kent Fredric
Just to elaborate on that, perltidy will turn function(:$requirednamedparam!) into function( : $requirednamedparam ! ) which is invalid
semi
+2  A: 

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.

Penfold
+2  A: 

Can you provide some examples of the problems you're having with Perl::Critic? I don't think any of the core P::C team are using Moose right now, so maybe we missed something obvious...

Chris Dolan
Well, Elliot Shank is using Moose and is the author of Perl::Critic::Moose. He's a core Perl::Critic guy :)
brian d foy
+4  A: 

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

jplindstrom
+7  A: 

Have you seen Perl::Critic::Moose?

brian d foy