Skip to content

Stop improper violation for lexical subroutines in Subroutines::ProhibitBuiltinHomonyms - #973

Merged
petdance merged 6 commits into
Perl-Critic:devfrom
nanto:lexical-subroutine-name
Dec 12, 2022
Merged

petdance merged 6 commits into
Perl-Critic:devfrom
nanto:lexical-subroutine-name

Conversation

@nanto

@nanto nanto commented Nov 30, 2021

Copy link
Copy Markdown
Contributor

Subroutines::ProhibitBuiltinHomonyms policy incorrectly emits violation for lexical subroutine whose name is not same as builtin functions. Running the following code:

use Perl::Critic;
my $critic = Perl::Critic->new('-single-policy' => 'Subroutines::ProhibitBuiltinHomonyms');
my @violations = $critic->critique(\'my sub foo { 1 }');
print @violations;

Actual result: a violation Subroutine name is a homonym for builtin keyword sub at line 1, column 1. See page 177 of PBP. is printed.

Expected result: no violation is printed.

Fixes #955.

Fixes #546.

@nanto

nanto commented Jan 26, 2022

Copy link
Copy Markdown
Contributor Author

Since Perl-Critic/PPI#260 is fixed, we can treat names of lexical subroutines appropriately once we update PPI.

@nanto

nanto commented Jan 26, 2022

Copy link
Copy Markdown
Contributor Author

Oops! Tests on Perl 5.10 and 5.8 are failed because URI-cpan-1.008 requires Perl 5.12. https://metacpan.org/release/RJBS/URI-cpan-1.008/source/Makefile.PL#L17

@petdance

Copy link
Copy Markdown
Member

What do we need to do to get this something I can merge? I know we'll need to remove the PPI workarounds. How does URI::cpan fit in to this?

@petdance
petdance merged commit 20459d7 into Perl-Critic:dev Dec 12, 2022
@petdance

Copy link
Copy Markdown
Member

This tested just fine on a test branch with no conflicts, so I've squashed and merged it here. Thank you.

petdance added a commit that referenced this pull request Dec 12, 2022
@petdance

Copy link
Copy Markdown
Member

All merged and ready for next release: 0edb07d

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

Successfully merging this pull request may close these issues.

ProhibitBuiltinHomonyms misinterprets "my sub" subroutines sub unimport triggers ProhibitBuiltinHomonyms

2 participants