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

Recognise "method" keyword as a subroutine #18

Open
davorg opened this issue Jul 7, 2024 · 4 comments
Open

Recognise "method" keyword as a subroutine #18

davorg opened this issue Jul 7, 2024 · 4 comments
Assignees

Comments

@davorg
Copy link

davorg commented Jul 7, 2024

I've been using Perl::Metrics::Simple to automatically measure the complexity of a lot of my CPAN code using GitHub Actions (see workflow file here.

Today, I looked at one of the reports for App::MergeCal (see the "run countperl" job). I spotted that the code had a rather high complexity because it's all counted as "code not in named subroutines". I assume that's because I'm using the new perlclass feature and most of my code is in methods, not subroutines.

So this is just here to alert you to the issue. My plan is to look at your code and see if I can work out how to fix this and send you a pull request over the next couple of days.

@matisse
Copy link
Owner

matisse commented Jul 16, 2024

Hi Dave and thanks for the report.

It is indeed true that Perl::Metrics::Simple relies on the sub keyword to find subroutines.
See Perl/Metrics/Simple/Analysis/File.pm line 141

It does this by with the [PPI](https://metacpan.org/pod/PPI::Statement::Sub)

I believe that currently there is not a PPI::Statement subclass for method

So, I am curious what solution you think might be helpful here?

@matisse matisse self-assigned this Jul 16, 2024
@davorg
Copy link
Author

davorg commented Jul 17, 2024

Yeah, I think we need to start by adding a method class to PPI. I'll look into that.

@davorg
Copy link
Author

davorg commented Jul 18, 2024

See Perl-Critic/PPI#299

@matisse
Copy link
Owner

matisse commented Jul 21, 2024

Noting for the record here the PPI
RFC: proof-of-concept for feature-tracking and perl sub signatures

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

2 participants