Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequireFinalReturn bug returning after whitespace-stripping here-doc ? #813

Open
trmz opened this issue Apr 3, 2018 · 3 comments
Open

Comments

@trmz
Copy link

trmz commented Apr 3, 2018

Not sure if bug.

If you return immediately after a whitespace-stripping here-doc, perlcritic warns about Subroutines::RequireFinalReturn, '[...] does not end with "return".'

Test module :

package Test;
use warnings;
use strict;

sub test {
    my $str = <<~'HEREDOC';
        some text
HEREDOC

    return $str;
}

1;

Test.pm: (Severity 4) Line 5: Subroutine "test" does not end with "return"

Doesn't seem to matter what you return.
Putting any code between the closing HEREDOC and the return causes issue to not occur.
Even (incorrectly) putting a semicolon after the closing HEREDOC appeases perlcritic, while also not compiling.

I would expect perlcritic to not complain.

Using Perl 5.26.1 and perlcritic 1.130.

@s-nez
Copy link
Contributor

s-nez commented Apr 18, 2018

It's most likely caused by indented heredocs not being supported by PPI yet (Perl-Critic/PPI#203).

@ralesk
Copy link

ralesk commented Aug 6, 2019

They seem to be supported now and when updating both PPI and Critic to newest (1.270 and 1.134), fixed Critic complaining about things when it shouldn't (in my case it was the last sub in a module and it complained about the module not ending with 1; — but I tried to replicate OP's situation and it passed also).

@bokutin
Copy link

bokutin commented May 6, 2020

I encountered the same problem.

Reproduce if the following line is included in dist.ini.
[PkgVersion] or [PodWeaver]

Most Dist::Zilla users mean that the indented heredoc doesn't work as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants