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

ProhibitMatchVars doesn't detect match vars inside interpolated strings #1044

Open
h3xx opened this issue Aug 28, 2023 · 2 comments
Open

ProhibitMatchVars doesn't detect match vars inside interpolated strings #1044

h3xx opened this issue Aug 28, 2023 · 2 comments

Comments

@h3xx
Copy link
Contributor

h3xx commented Aug 28, 2023

The following usages are not detected but should be. The minute you take them out of the strings, they're detected, however.

"$`";
"$&";
"$'";
"$PREMATCH";
"$MATCH";
"$POSTMATCH";

Example:

$foo = 'foo' . $`; # detected
$foo = "foo$`"     # NOT detected
qr/$`/;            # NOT detected
<<"HEREDOC";       # NOT detected
$`
HEREDOC

Perl::Critic version: 5c577fc

@petdance
Copy link
Member

petdance commented Sep 3, 2023

I suspect this is a PPI issue over a Perl::Critic issue, but I haven't looked.

@h3xx
Copy link
Contributor Author

h3xx commented Sep 3, 2023

I suspect this is a PPI issue over a Perl::Critic issue, but I haven't looked.

Not sure if that's correct; P:V:ProhibitPunctuationVars has routines in it to detect its illegal variables being used in heredocs and regexes.

I would imagine the fix would be implementing something similar in P:V:ProhibitMatchVars.

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

No branches or pull requests

2 participants