Login
ARRGH! RestrictLongStrings is not a core Policy, so I can't
authorJeffrey Ryan Thalhammer <jeff@imaginative-software.com>
Tue, 3 Jul 2012 20:16:50 +0000 (20:16 +0000)
committerJeffrey Ryan Thalhammer <jeff@imaginative-software.com>
Tue, 3 Jul 2012 20:16:50 +0000 (20:16 +0000)
use it for testing.  So I switched to ProhibitQuotedWordLists.
I just needed any core Policy that accepts some config params.

t/01_config.t
t/10_user_profile.t

index 93bdddf..6cee356 100644 (file)
@@ -258,10 +258,10 @@ my $total_policies   = scalar @names_of_policies_willing_to_work;
 
     my %profile = (
         '-NamingConventions::Capitalization' => {},
-        '-ValuesAndExpressions::RestrictLongStrings' => {},
+        '-CodeLayout::ProhibitQuotedWordLists' => {},
     );
 
-    my @include = qw(capital RCS);
+    my @include = qw(capital quoted);
     my %pc_args = (
         -profile    => \%profile,
         -severity   => 1,
@@ -416,7 +416,7 @@ my $total_policies   = scalar @names_of_policies_willing_to_work;
 {
     my %profile = (
         'NamingConventions::Capitalization' => {},
-        'ValuesAndExpressions::RestrictLongStrings' => {},
+        'CodeLayout::ProhibitQuotedWordLists' => {},
     );
 
     my %pc_config = (-severity => 1, -only => 1, -profile => \%profile);
@@ -533,12 +533,12 @@ my $total_policies   = scalar @names_of_policies_willing_to_work;
 {
     my %profile = (
         'NamingConventions::Capitalization' => {},
-        'ValuesAndExpressions::RestrictLongStrings' => {},
+        'CodeLayout::ProhibitQuotedWordLists' => {},
     );
 
-    # Pretend that RestrictLongStrings is actually unsafe
+    # Pretend that ProhibitQuotedWordLists is actually unsafe
     no warnings qw(redefine once);  ## no critic qw(ProhibitNoWarnings)
-    local *Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings::is_safe = sub {return 0};
+    local *Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists::is_safe = sub {return 0};
 
     my %safe_pc_config = (-severity => 1, -only => 1, -profile => \%profile);
     my @p = Perl::Critic::Config->new( %safe_pc_config )->policies();
@@ -548,7 +548,7 @@ my $total_policies   = scalar @names_of_policies_willing_to_work;
     @p = Perl::Critic::Config->new( %unsafe_pc_config )->policies();
     is(scalar @p, 2, 'Also loaded unsafe policies with -allow-unsafe switch');
 
-    my %singular_pc_config = ('-single-policy' => 'RestrictLongStrings');
+    my %singular_pc_config = ('-single-policy' => 'QuotedWordLists');
     @p = Perl::Critic::Config->new( %singular_pc_config )->policies();
     is(scalar @p, 1, '-single-policy always loads Policy, even if unsafe');
 }
index 30bda89..5f04507 100644 (file)
@@ -26,17 +26,17 @@ our $VERSION = '1.118';
 # Create profile from hash
 
 {
-    my %policy_params = (max_length => '40');
+    my %policy_params = (min_elements => 4);
     my %profile_hash = ( '-NamingConventions::Capitalization' => {},
-                         'ValuesAndExpressions::RestrictLongStrings' => \%policy_params );
+                         'CodeLayout::ProhibitQuotedWordLists' => \%policy_params );
 
     my $up = Perl::Critic::UserProfile->new( -profile => \%profile_hash );
 
     # Using short policy names
     is(
-        $up->policy_is_enabled('ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('NamingConventions::Capitalization'),
@@ -44,16 +44,16 @@ our $VERSION = '1.118';
         'NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Now using long policy names
     is(
-        $up->policy_is_enabled('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('Perl::Critic::Policy::NamingConventions::Capitalization'),
@@ -61,9 +61,9 @@ our $VERSION = '1.118';
         'Perl::Critic::Policy::NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Using bogus policy names
@@ -88,10 +88,10 @@ our $VERSION = '1.118';
 # Create profile from array
 
 {
-    my %policy_params = (max_length => 40);
+    my %policy_params = (min_elements => 4);
     my @profile_array = ( q{ [-NamingConventions::Capitalization] },
-                          q{ [ValuesAndExpressions::RestrictLongStrings]           },
-                          q{ max_length = 40                         },
+                          q{ [CodeLayout::ProhibitQuotedWordLists]           },
+                          q{ min_elements = 4                         },
     );
 
 
@@ -99,9 +99,9 @@ our $VERSION = '1.118';
 
     # Now using long policy names
     is(
-        $up->policy_is_enabled('ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('NamingConventions::Capitalization'),
@@ -109,16 +109,16 @@ our $VERSION = '1.118';
         'NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Now using long policy names
     is(
-        $up->policy_is_enabled('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('Perl::Critic::Policy::NamingConventions::Capitalization'),
@@ -126,9 +126,9 @@ our $VERSION = '1.118';
         'Perl::Critic::Policy::NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Using bogus policy names
@@ -153,20 +153,20 @@ our $VERSION = '1.118';
 # Create profile from string
 
 {
-    my %policy_params = (max_length => 40);
+    my %policy_params = (min_elements => 4);
     my $profile_string = <<'END_PROFILE';
 [-NamingConventions::Capitalization]
-[ValuesAndExpressions::RestrictLongStrings]
-max_length = 40
+[CodeLayout::ProhibitQuotedWordLists]
+min_elements = 4
 END_PROFILE
 
     my $up = Perl::Critic::UserProfile->new( -profile => \$profile_string );
 
     # Now using long policy names
     is(
-        $up->policy_is_enabled('ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('NamingConventions::Capitalization'),
@@ -174,16 +174,16 @@ END_PROFILE
         'NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Now using long policy names
     is(
-        $up->policy_is_enabled('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('Perl::Critic::Policy::NamingConventions::Capitalization'),
@@ -191,9 +191,9 @@ END_PROFILE
         'Perl::Critic::Policy::NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Using bogus policy names
@@ -218,20 +218,20 @@ END_PROFILE
 # Test long policy names
 
 {
-    my %policy_params = (max_length => 40);
+    my %policy_params = (min_elements => 4);
     my $long_profile_string = <<'END_PROFILE';
 [-Perl::Critic::Policy::NamingConventions::Capitalization]
-[Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings]
-max_length = 40
+[Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists]
+min_elements = 4
 END_PROFILE
 
     my $up = Perl::Critic::UserProfile->new( -profile => \$long_profile_string );
 
     # Now using long policy names
     is(
-        $up->policy_is_enabled('ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('NamingConventions::Capitalization'),
@@ -239,16 +239,16 @@ END_PROFILE
         'NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Now using long policy names
     is(
-        $up->policy_is_enabled('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->policy_is_enabled('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         1,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings is enabled.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists is enabled.',
     );
     is(
         $up->policy_is_disabled('Perl::Critic::Policy::NamingConventions::Capitalization'),
@@ -256,9 +256,9 @@ END_PROFILE
         'Perl::Critic::Policy::NamingConventions::Capitalization is disabled.',
     );
     is_deeply(
-        $up->raw_policy_params('Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings'),
+        $up->raw_policy_params('Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists'),
         \%policy_params,
-        'Perl::Critic::Policy::ValuesAndExpressions::RestrictLongStrings got the correct configuration.',
+        'Perl::Critic::Policy::CodeLayout::ProhibitQuotedWordLists got the correct configuration.',
     );
 
     # Using bogus policy names