.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Perl::Critic::Policy::Miscellanea::TextDomainPlaceholders 3pm" .TH Perl::Critic::Policy::Miscellanea::TextDomainPlaceholders 3pm "2018-05-30" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Perl::Critic::Policy::Miscellanea::TextDomainPlaceholders \- check placeholder names in Locale::TextDomain calls .SH "DESCRIPTION" .IX Header "DESCRIPTION" This policy is part of the \f(CW\*(C`Perl::Critic::Pulp\*(C'\fR add-on. It checks the placeholder arguments in format strings to the following functions from \f(CW\*(C`Locale::TextDomain\*(C'\fR. .PP .Vb 1 \& _\|_x _\|_nx _\|_xn _\|_px _\|_npx .Ve .PP Calls with a key missing from the args or args unused by the format are reported. .PP .Vb 2 \& print _\|_x(\*(AqSearching for {data}\*(Aq, # bad \& datum => 123); \& \& print _\|_nx(\*(AqRead one file\*(Aq, \& \*(AqRead {num} files\*(Aq, # bad \& $n, \& count => 123); .Ve .PP This is normally a mistake, so this policy is under the \*(L"bugs\*(R" theme (see \&\*(L"\s-1POLICY THEMES\*(R"\s0 in Perl::Critic). An error can easily go unnoticed because (as of Locale::TextDomain version 1.16) a placeholder without a corresponding arg goes through unexpanded and any extra args are ignored. .PP The way Locale::TextDomain parses the format string allows anything between \&\f(CW\*(C`{ }\*(C'\fR as a key, but for the purposes of this policy only symbols (alphanumeric plus \*(L"_\*(R") are taken to be a key. This is almost certainly what you'll want to use, and it's then possible to include literal braces in a format string without tickling this policy all the time. (Symbol characters are per Perl \f(CW\*(C`\ew\*(C'\fR, so non-ASCII is supported, though the Gettext manual in node \*(L"Charset conversion\*(R" recommends message-IDs should be ASCII-only.) .SH "Partial Checks" .IX Header "Partial Checks" If the format string is not a literal then it might use any args, so all are considered used. .PP .Vb 2 \& # ok, \*(Aqdatum\*(Aq might be used \& _\|_x($my_format, datum => 123); .Ve .PP Literal portions of the format are still checked. .PP .Vb 2 \& # bad, \*(Aqfoo\*(Aq not present in args \& _\|_x("{foo} $bar", datum => 123); .Ve .PP Conversely if the args have some non-literals then they could be anything, so everything in the format string is considered present. .PP .Vb 2 \& # ok, $something might be \*(Aqworld\*(Aq \& _\|_x(\*(Aqhello {world}\*(Aq, $something => 123); .Ve .PP But again if some args are literals they can be checked. .PP .Vb 2 \& # bad, \*(Aqblah\*(Aq is not used \& _\|_x(\*(Aqhello {world}\*(Aq, $something => 123, blah => 456); .Ve .PP If there's non-literals both in the format and in the args then nothing is checked, since it could all match up fine at runtime. .ie n .SS """_\|_nx"" Count Argument" .el .SS "\f(CW_\|_nx\fP Count Argument" .IX Subsection "__nx Count Argument" A missing count argument to \f(CW\*(C`_\|_nx\*(C'\fR, \f(CW\*(C`_\|_xn\*(C'\fR and \f(CW\*(C`_\|_npx\*(C'\fR is sometimes noticed by this policy. For example, .PP .Vb 3 \& print _\|_nx(\*(AqRead one file\*(Aq, \& \*(AqRead {numfiles} files\*(Aq, \& numfiles => $numfiles); # bad .Ve .PP If the count argument looks like a key then it's reported as a probable mistake. This is not the main aim of this policy but it's done because otherwise no violations would be reported at all. (The next argument would be the key, and normally being an expression it would be assumed to fulfill the format strings at runtime.) .SH "SEE ALSO" .IX Header "SEE ALSO" Perl::Critic::Pulp, Perl::Critic, Locale::TextDomain, Perl::Critic::Policy::Miscellanea::TextDomainUnused .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde .PP Perl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. .PP Perl-Critic-Pulp is distributed in the hope that it will be useful, but \&\s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 See the \s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with Perl-Critic-Pulp. If not, see .