From 6a73e3078b01a71d4a6ea90c85da16523ed56f1d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 31 Dec 2012 21:43:39 +0100 Subject: Do not use double-quotes on strings that do not need interpolation Using double-quotes imposes a small performance penalty as the perl parser needs to check if any interpolation is needed. Use double-quotes only when the string contains single-quotes. Ideally we'd use double-quotes too for escaped meta-characters that might otherwise be confusing to immediately see if they need interpolation or not, but the policy does not (currently) allow to ignore these. Fixes ValuesAndExpressions::ProhibitInterpolationOfLiterals. Warned-by: perlcritic --- test/000_pod.t | 4 ++-- test/100_critic.t | 1 + test/100_critic/perlcriticrc | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/000_pod.t b/test/000_pod.t index 2af85713f..0282a7d0e 100644 --- a/test/000_pod.t +++ b/test/000_pod.t @@ -18,7 +18,7 @@ use Test::More; use strict; use warnings; -eval "use Test::Pod 1.00"; -plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; +eval 'use Test::Pod 1.00'; +plan skip_all => 'Test::Pod 1.00 required for testing POD' if $@; my @poddirs = ( $ENV{srcdir} || '.' ); all_pod_files_ok( all_pod_files( @poddirs ) ); diff --git a/test/100_critic.t b/test/100_critic.t index cae188f0b..9b3e9e1bd 100644 --- a/test/100_critic.t +++ b/test/100_critic.t @@ -69,6 +69,7 @@ my @policies = qw( TestingAndDebugging::RequireUseStrict TestingAndDebugging::RequireUseWarnings ValuesAndExpressions::ProhibitComplexVersion + ValuesAndExpressions::ProhibitInterpolationOfLiterals ValuesAndExpressions::ProhibitLongChainsOfMethodCalls ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator diff --git a/test/100_critic/perlcriticrc b/test/100_critic/perlcriticrc index 486bcf030..8fa73d6f9 100644 --- a/test/100_critic/perlcriticrc +++ b/test/100_critic/perlcriticrc @@ -5,6 +5,10 @@ verbose = %f %l:%c (Severity: %s)\n %P (%s)\n near '%r'\n%d\n #[RegularExpressions::RequireExtendedFormatting] #minimum_regex_length_to_complain_about = 60 +[ValuesAndExpressions::ProhibitInterpolationOfLiterals] +# TODO: switch these to q{} ? +allow_if_string_contains_single_quote = 1 + # Complex is not always bad. [-BuiltinFunctions::ProhibitComplexMappings] # Needed when generating code. -- cgit v1.2.3