in reply to perlcritic and heredocs

Can you post a short example of source code (and the corresponding Perl::Critic configuration and invocation) to demonstrate the problem?

I don't use Perl::Critic, but I imagine that it would understand what heredocs are...

Replies are listed 'Best First'.
Re^2: perlcritic and heredocs
by redtux (Sexton) on Apr 15, 2020 at 13:09 UTC
    (my $lintags_inssql = <<~'SQLSTR') =~s/(?:^\t*|\n)/ /gmx; INSERT INTO linktags (filesrc, metadir, tagname, tagvalue, symlink +, filesref, dirtype,status) SELECT a.filesrc, a.metadir, tagname, tagvalue, ## This is line 4486 ## metadir||'/'||tagname||$1||tagvalue||$1 +||filenameparts[1]||'_'||array_to_string(linka[linkano-2:linkano-1] ## line 4486 ## ,'_')||filenameparts[2] symlink ,filesref,dirtype,'new' FROM (SELECT DISTINCT l.filesrc, c.metadir||'/0_meta' metadir, tag +name, tagvalue ,string_to_array(filesrc,$1)linka, cardinality(string_to_array(filesrc,$1)) linkano, regexp_matches(filesrc,'.*/(.*)(\..*)') filenameparts, filesref, dirtype FROM public.linktags l JOIN chkmeta c ON l.filesrc LIKE c.metadir||'%' WHERE (st +atus='new') ) a ON CONFLICT(symlink) DO UPDATE SET dirtype=EXCLUDED.dirtype SQLSTR

    perlcritic error

    Hard tabs used at line 4486, column 64. See page 20 of PBP. (Severity: 3)
    Literal line breaks in a string at line 4486, column 64. See pages 60,61 of PBP.
    (Severity: 3)

    perlcritic cmd

    sudo perlcritic --force -1 /usr/bin/use_videotagspg|grep -i -B2 'hard tabs'

    .perlcriticrc

    [TestingAndDebugging::ProhibitNoStrict] allow = refs
      I downloaded the code, removed the ## comments, included the standard boilerplate for scripts (shebang, strictures, warnings) and run freshly installed perlcritic on it:
      $ perlcritic --force -1 1.pl Code is not tidy at line 1, column 1. See page 33 of PBP. (Severity: + 1) No package-scoped "$VERSION" variable found at line 1, column 1. See +page 404 of PBP. (Severity: 2) Regular expression without "/s" flag at line 6, column 38. See pages +240,241 of PBP. (Severity: 2)

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        Very tangentially related but: perl (and perlcritic) will honour cpp-style #line filename linenumber directives so you can embed those in disjoint snippets to get line numbers to line up (as it were) with the original full source.

        Update: additionally I get the same output (perlcritic 1.138, perl 5.30.2) albeit with the regex error reported at line 4483 since I diddled in #line 4483 before the first line of code after similar shebang/strict/warnings.

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.

      Like choroba, I also can't reproduce those two policy warnings here either, with versions 1.134 and the latest 1.138. What version of Perl::Critic do you have installed? (perlcritic --version) And do you perhaps have any other Perl::Critic::* add-ons installed?

        1.132 (rpm for fedora 30),Nothing else installed