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

Feature Request: exceptions for warning in the code #136

Open
Reissner opened this issue Aug 18, 2024 · 1 comment
Open

Feature Request: exceptions for warning in the code #136

Reissner opened this issue Aug 18, 2024 · 1 comment

Comments

@Reissner
Copy link

I am working on something special but still the feature request seems to be more general useful.
I have a perl file which is read in by another software, it is the config file .latexmkrc which is read by latexmk.
As a result, there are some variables read only once and this leads to a warning.
I dont want to disable this in general, nor in the profile, but just for this file,
and maybe only at a specific place.

chktex has an interesting technique:
Just at the critical line start a comment and include chktex num, where num is a number.
In perl and perlnavigator one would exclude warning via

$bibtex='bibtexu %O';# perlnavigator 15

if the warning has identifier 15.

Of course to make this work, each of the warnings must be endowed with an identifier
for the kind of warning.

@bscan
Copy link
Owner

bscan commented Aug 19, 2024

I'd recommend using no warnings 'once'; in your file if you want to disable this warning. This can also be localized to a specific function or code block as needed. It's the simplest fix and localizes it only to this file.

Perl Navigator always enables warnings even when you don't use warnings in your code, which may add to the confusion. You can disable this behavior by setting "perlnavigator.enableWarnings": false, if you want it to apply to all files.

The issue with disabling compiler warnings via code comments is that they'll still print warnings when the code is run (unlike perlcritic warnings for example). Plus, they'll still show up if anyone is using a different tool that still calls perl -c for syntax checking (e.g. flycheck or another language server).

There are also perlcritic warnings that may need to be disabled depending on your particular profile and set of installed policies. Those can be disabled via ## no critic (PolicyName) if needed.

As a side note, the Perl Navigator does support some code comments for typing, so I'm not opposed to the concept of using comments as instructions. For example:

use LWP::UserAgent;
my $ua = LWP::UserAgent->new(timeout => 10);
my $res= $ua->get( $url );    # $res isa HTTP::Response

And this will enable autocompletion of methods available on $res, and improve the accuracy of go-to definition on any $res-> methods. I like this format because it's also a meaningful comment for people not using the Perl Navigator.

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