Have a simple module
package Rrr;
use 5.014;
use warnings;
use namespace::sweep;
use Moo;
use Method::Signatures::Simple;
BEGIN {
our $VERSION = '0.0.1';
}
has 'root' => (
is => 'rw',
default => 'root'
);
method func {
say 'This is the func method from ' . __PACKAGE__ . ' with value: ', $self->root;
}
1;
The perlcritic -1
says
Code is not tidy at line 1, column 1. See page 33 of PBP. (Severity: 1)
Module does not end with "1;" at line 17, column 1. Must end with a recognizable true value. (Severity: 4)
Return value of flagged function ignored - say at line 18, column 5. See pages 208,278 of PBP. (Severity: 1)
How to make perlcritic happy?
EDIT - based on @toolic's comment
Yes, the tidy helps with the 1st problem (but the Code is not tidy at line 1, column 1.
isn't much helpful message), as the diff is:
13c13
< is => 'rw',
---
> is => 'rw',
18c18,19
< say 'This is the func method from ' . __PACKAGE__ . ' with value: ', $self->root;
---
> say 'This is the func method from ' . __PACKAGE__ . ' with value: ',
> $self->root;
But still got the:
Module does not end with "1;" at line 17, column 1. Must end with a recognizable true value. (Severity: 4)
Return value of flagged function ignored - say at line 18, column 5. See pages 208,278 of PBP. (Severity: 1)
My percritic:
$ perlcritic --version
1.125
method func { ... }
declaration. Seems like perl critic thinks that is the end of your module. – Sarawakmethod func { ... } 1;
asmethod(func(sub{ ... }, 1));
, i.e. the1
is an argument tofunc
. You can fix this by putting a semicolon after the closing brace, before the final1;
. Due to such issues, I tend to choose between syntax extensions and perlcritic – and sadly have to prefer static analysis over syntactic sugar in most cases. – Fiberglassfunc
keyword, so naming your methodfunc
is potentially confusing. I'll assume you'll use a better method name in your real program. :) – Landward