moose / Perl-Critic-Moose

Policies for Perl::Critic concerned with using Moose
http://metacpan.org/release/Perl-Critic-Moose/
Other
0 stars 2 forks source link

Bug with Perl::Critic::Policy::Moose::RequireMakeImmutable #8

Open autarch opened 3 years ago

autarch commented 3 years ago

Migrated from rt.cpan.org #128988 (status was 'open')

Requestors:

From ahmed.iabdrabo@gmail.com on 2019-04-01 11:01:28 :

Hi,

I faced a weird issue while running perlcritic on some code in my company. You can reproduce the issue with having DATA string in the source code. Notice the only difference in the following two examples is DATA vs somethingelse but Moose::RequireMakeImmutable behaves differently in both cases.

$ echo ' use Moose;

sub foo { $bar->{DATA}++; }

no Moose; PACKAGE->meta->make_immutable;

1; ' | perlcritic --profile /dev/null -s RequireMakeImmutable --verbose 9 [Moose::RequireMakeImmutable] No call was made to make_immutable() at line 1, near ''. (Severity: 3)

$ echo ' use Moose;

sub foo { $bar->{somethingelse}++; }

no Moose; PACKAGE->meta->make_immutable;

1; ' | perlcritic --profile /dev/null -s RequireMakeImmutable --verbose 9 source OK

My installed Perl-Critic-Moose version is 1.05.

Regards, Ahmed

autarch commented 3 years ago

From drolsky@cpan.org (@autarch) on 2019-04-04 16:51:34 :

On 2019-04-01 06:01:28, ahmed.iabdrabo@gmail.com wrote:

Hi,

I faced a weird issue while running perlcritic on some code in my company. You can reproduce the issue with having DATA string in the source code. Notice the only difference in the following two examples is DATA vs somethingelse but Moose::RequireMakeImmutable behaves differently in both cases.

$ echo ' use Moose;

sub foo { $bar->{DATA}++; }

no Moose; PACKAGE->meta->make_immutable;

1; ' | perlcritic --profile /dev/null -s RequireMakeImmutable --verbose 9 [Moose::RequireMakeImmutable] No call was made to make_immutable() at line 1, near ''. (Severity: 3)

$ echo ' use Moose;

sub foo { $bar->{somethingelse}++; }

no Moose; PACKAGE->meta->make_immutable;

1; ' | perlcritic --profile /dev/null -s RequireMakeImmutable --verbose 9 source OK

My installed Perl-Critic-Moose version is 1.05.

That is an odd bug. I'm not sure what's going on though I suspect it has something to do with how PPI handles the __DATA__ token, and the bug is probably in that package.