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

Community::Prototypes does not recognize :prototype form for declaring prototypes #44

Open
petdance opened this issue Dec 8, 2021 · 3 comments · May be fixed by #47
Open

Community::Prototypes does not recognize :prototype form for declaring prototypes #44

petdance opened this issue Dec 8, 2021 · 3 comments · May be fixed by #47

Comments

@petdance
Copy link

petdance commented Dec 8, 2021

foo and baz get caught correctly. bat is ignored correctly because it's an empty prototype. bar should be caught but is not.

This looks like the same problem as Perl-Critic/Perl-Critic#978

#!/usr/bin/perl

use warnings;
use strict;
use 5.010;


sub foo($$) {}

sub bar :prototype($$) {}

sub bat() {}

sub baz($$) {}
$ perlcritic --s Community::Prototypes foo.pl
foo.pl: Using function prototypes.
    8:sub foo($$) {}

foo.pl: Using function prototypes.
    14:sub baz($$) {}
@Grinnz
Copy link
Owner

Grinnz commented Dec 8, 2021

I'm not sure this is worth catching. So far, :prototype doesn't tend to be used by the target audience of this policy (newbies who think ($) is a normal thing to add to a sub definition). But perhaps.

@Grinnz
Copy link
Owner

Grinnz commented Dec 8, 2021

It would be a bit more complex to recognize, because right now it completely ignores a file using the signatures feature, as it then assumes you know what you're doing.

@atoomic
Copy link

atoomic commented Jan 17, 2022

I'm just hitting this issue where we enable by default function signature in most of our codebase using a custom package
so was adding this to our policy.. but this is useless as the current Community::Prototypes does not recognize :prototype

# Don't use function prototypes
[Community::Prototypes]
# Upgraded severity. Default severity: 3.
# Enforced by cPLint.
severity = 4
signature_enablers = cPstrict

atoomic added a commit to atoomic/Perl-Critic-Community that referenced this issue Jan 17, 2022
Fix Grinnz#44

When using function signatures, prototypes can be set using
the ': prototype'.
With this change we can now detect explicit usage of prototype.
atoomic added a commit to atoomic/Perl-Critic-Community that referenced this issue Jan 17, 2022
Fix Grinnz#44

When using function signatures, prototypes can be set using
the ': prototype'.
With this change we can now detect explicit usage of prototype.
@atoomic atoomic linked a pull request Jan 17, 2022 that will close this issue
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 a pull request may close this issue.

3 participants