-
Notifications
You must be signed in to change notification settings - Fork 39
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
Using Object::Pad and perlcritic #63
Comments
Thanks for the report. These are great issues to solve. In general, the issue is that PPI does not support modern keyword-based extensions like Object::Pad. There is movement in that repo (in Perl-Critic/PPI#273 ), but that is more about signatures and try/catch, so it might be a while before full support for Object::Pad arrives. More specifically, you'll see these errors even if you directly call For the first issue (Code not contained in explicit package), it may help to follow the Object::Pad file layout suggestions shown here, where they also specify a package in addition to the class: https://metacpan.org/pod/Object::Pad#File-Layout . I believe this recommendation is primarily for Perl::Critic. However, I'm also in support of trying to work around these issues. For example, using an Pull requests more than welcome, or I'll otherwise eventually get around to it. Fixing this before Perl 5.38 would be great, since that's when |
@bscan Thanks for the positive reply, I will take a look. |
Thanks for digging in here. I was thinking about the issue a bit more. Pre-processing the source code is one route. Another idea could be dynamically disabling policies. For example, we may find that RequireEndWithOne is currently not possible to get working. So, we could detect that Object::Pad is "use'd", and then remove the policy by adding it to the exclude list. There may be many other policy/features combinations as well that don't work. |
Sorry, accidentally closed. |
Good idea. I tried this: first removing this still gives critique |
Added a question on stackoverflow.com to get some more feedback: https://stackoverflow.com/q/75760912/2173773 |
Awesome, thanks! I'm curious what the response will be. There was some similar discussion here: Perl-Apollo/Corinna#95 , but this was more related to the design of the Object-Oriented system than a precise style recommendation for dealing with Perl::Critic. I also looked into the
I suspect PPI is parsing this as calling a sub named However, PPI considers a phasers as an "implied end", which do not need a semicolon. Seems like there are two possible fixes for this problem. Either we map the Object::Pad phasers (BUILD and ADJUST) to the types of phasers that PPI recognizes (e.g. Removing entirely might be better to ensure the word
which does appear to parse correctly in PPI when adjusted to:
|
Hi @hakonhagland , thanks again for pushing this forward. I spent some more time looking at this. Given the conflicting information about proper file layout, and the StackOverflow answers, I think it best if the Navigator tolerated all the different forms, as they'll all be common and not really "wrong". Trying to organize my thoughts and document reasons for changes, I put together a checklist of various changes I think are needed. I'm happy to do them, or I'd gladly accept pull requests if you're looking at any of them already.
Thanks! |
@bscan Looks great to me!
Great! Please go ahead, sorry I have a busy schedule so I will probably be very slow if I should do any of these :) But let me know if you want me to have look at any of the items on your list or some other issue with PerlNavigator within a longer time frame (not so urgent issues). |
The updates for Perl::Critic and syntax highlighting should are now available in the Marketplace (and on NPM) in version v0.5.5. Normally will automatically update to the latest version, but may require reloading vscode. I also added some code to allow for lexical methods like @hakonhagland, thanks again for your help on this one. I think this helps substantially toward the goal of making vscode with the Perl Navigator the best development environment for modern Perl. |
When using Object::Pad, for example this program:
Notice the blue lines under lines 1 and 7, when I hover the mouse over those lines I get
and
The text was updated successfully, but these errors were encountered: