Grinnz / Perl-Critic-Community

Perl::Critic::Community - Community-inspired Perl::Critic policies
https://metacpan.org/pod/Perl::Critic::Community
Other
8 stars 10 forks source link

Freenode::DeprecatedFeatures thinks << in formats are heredocs. #32

Open petdance opened 5 years ago

petdance commented 5 years ago
$ cat format.pl
#!/usr/bin/perl

use strict;
use warnings;

my $x = 14;
format STDOUT =
@<<<<<<<<<
$x
.

write STDOUT;
$ perl format.pl
14
$ perlcritic -s Freenode::DeprecatedFeatures format.pl
format.pl: Bare here-doc is deprecated.
    8:@<<<<<<<<<

format.pl: Bare here-doc is deprecated.
    8:@<<<<<<<<<

format.pl: Bare here-doc is deprecated.
    8:@<<<<<<<<<

format.pl: Bare here-doc is deprecated.
    8:@<<<<<<<<<
Grinnz commented 5 years ago

Good lord, people use formats? ;)

petdance commented 5 years ago

Good lord, people use formats? ;)

Yes, people work with codebases that include programs that have been keeping the company running since the early 2000s, and that happen to use formats.

Tux commented 5 years ago

Please fix. This is very annoying. And the longer your @<<<<<< lines are the more errors you get. Can I up the priority somewhere?

$ cat test.pl
#!/usr/bin/perl

use strict;
use warnings;

our $VERSION = "1.00";

write;

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$0
.
$ perl test.pl
test.pl
$ perlcritic -1 test.pl
test.pl#11.2:   [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.4:   [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.6:   [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.8:   [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.10:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.12:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.14:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.16:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.18:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.20:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.22:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.24:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.26:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.28:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.30:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.32:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.34:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test.pl#11.36:  [4 - Freenode::DeprecatedFeatures]      Bare here-doc is deprecated     :@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Grinnz commented 5 years ago

You can up the priority by providing a PR :)

Grinnz commented 5 years ago

As a note, this will have to start with a PR to PPI. Here is the ppi_dumper output for your example file:

PPI::Document
  PPI::Token::Comment   '#!/usr/bin/perl\n'
  PPI::Token::Whitespace        '\n'
  PPI::Statement::Include
    PPI::Token::Word    'use'
    PPI::Token::Whitespace      ' '
    PPI::Token::Word    'strict'
    PPI::Token::Structure       ';'
  PPI::Token::Whitespace        '\n'
  PPI::Statement::Include
    PPI::Token::Word    'use'
    PPI::Token::Whitespace      ' '
    PPI::Token::Word    'warnings'
    PPI::Token::Structure       ';'
  PPI::Token::Whitespace        '\n'
  PPI::Token::Whitespace        '\n'
  PPI::Statement::Variable
    PPI::Token::Word    'my'
    PPI::Token::Whitespace      ' '
    PPI::Token::Symbol          '$x'
    PPI::Token::Whitespace      ' '
    PPI::Token::Operator        '='
    PPI::Token::Whitespace      ' '
    PPI::Token::Number          '14'
    PPI::Token::Structure       ';'
  PPI::Token::Whitespace        '\n'
  PPI::Statement
    PPI::Token::Word    'format'
    PPI::Token::Whitespace      ' '
    PPI::Token::Word    'STDOUT'
    PPI::Token::Whitespace      ' '
    PPI::Token::Operator        '='
    PPI::Token::Whitespace      '\n'
    PPI::Token::Cast    '@'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<'
    PPI::Token::Whitespace      '\n'
    PPI::Token::Symbol          '$x'
    PPI::Token::Whitespace      '\n'
    PPI::Token::Operator        '.'
    PPI::Token::Whitespace      '\n'
    PPI::Token::Whitespace      '\n'
    PPI::Token::Word    'write'
    PPI::Token::Whitespace      ' '
    PPI::Token::Word    'STDOUT'
    PPI::Token::Structure       ';'
  PPI::Token::Whitespace        '\n'
karenetheridge commented 4 years ago
    PPI::Token::Cast    '@'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<<'
    PPI::Token::Operator        '<'

It would appear that PPI isn't recognizing formats either. So that's where to start.