Freenode::BarewordFileHandles dies on `open(CHECK, '/foo');`
petdance opened this issue · 3 comments
Prompted by https://www.reddit.com/r/perl/comments/c4lhaq/and_most_damning_of_all_the_resulting_code_was/erx5hno/
The punchline is, of course, the 100 kB file keeper in http://www.ibiblio.org/pub/Linux/search/keeper-1.54.tar.gz. The code is so eyewateringly bad, it crashes Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles. esr made a career out of bashing Perl, always blaming the language, never his own lack of skill.
$ cat minimal
#!/usr/bin/perl
open(CHECK, '/foo');
$ perlcritic minimal -s InputOutput::ProhibitBarewordFileHandles
Fatal error while critiquing "minimal": Not an ARRAY reference at /var/perl5.20.3/lib/site_perl/5.20.3/Perl/Critic/Policy/InputOutput/ProhibitBarewordFileHandles.pm line 35.
$ perlcritic minimal -s Freenode::BarewordFileHandles
Fatal error while critiquing "minimal": Not an ARRAY reference at /var/perl5.20.3/lib/site_perl/5.20.3/Perl/Critic/Policy/Freenode/BarewordFilehandles.pm line 47.
See also Perl-Critic/Perl-Critic#878
> ppi_dumper minimal
PPI::Document
PPI::Token::Comment '#!/usr/bin/perl\n'
PPI::Token::Whitespace '\n'
PPI::Statement
PPI::Token::Word 'open'
PPI::Structure::List ( ... )
PPI::Statement::Scheduled
PPI::Token::Word 'CHECK'
PPI::Token::Operator ','
PPI::Token::Whitespace ' '
PPI::Token::Quote::Single ''/foo''
PPI::Token::Structure ';'
PPI::Token::Whitespace '\n'
I believe this is because CHECK is triggering PPI to think it's a CHECK {}
block... the Statement object in the middle of the expression is then confusing parse_arg_list.
If you get this fixed, please make a note of it on the corresponding Perl::Critic policy, too.
This may be fixed by Perl-Critic/PPI#247