From a8eb245f2cf4922a08f32659d5a5277e48efb795 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 6 Dec 2007 22:38:33 +0000 Subject: [PATCH] Remove debugging code. Only process ->get method calls for existing i18n objects. Handle the default namespace setup in ->new Add POD code on how to run this from the command line. Basically, it's done but needs to be run against more code to handle variable based i18n calls (which need to be ignored) and nested scope object creation. --- .../Critic/Policy/WebGUI/NoIllegalI18NLabels.pm | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/t/lib/Perl/Critic/Policy/WebGUI/NoIllegalI18NLabels.pm b/t/lib/Perl/Critic/Policy/WebGUI/NoIllegalI18NLabels.pm index 816278e26..c90b97fba 100644 --- a/t/lib/Perl/Critic/Policy/WebGUI/NoIllegalI18NLabels.pm +++ b/t/lib/Perl/Critic/Policy/WebGUI/NoIllegalI18NLabels.pm @@ -5,16 +5,22 @@ use warnings; use Readonly; use FindBin; +use WebGUI::Test; +use WebGUI::International; + use Perl::Critic::Utils qw{ :all }; use base 'Perl::Critic::Policy'; -use WebGUI::International; -use WebGUI::Test; - =head1 Perl::Critic::Policy::WebGUI::NoIllegalI18NLabels Scan WebGUI modules for i18n calls and make sure that each -call has a corresponding i18n table entry +call has a corresponding i18n table entry. + +Running this policy requires setting up some environmental +variables to that it can get a proper WebGUI session, and access +the test library. + +env WEBGUI_CONFIG=/data/WebGUI/etc/my.conf PERL5LIB=/data/WebGUI/t/lib perlcritic -single-policy NoIllegalI18N =cut @@ -71,12 +77,13 @@ sub violates { return unless ref $arg_list eq 'PPI::Structure::List'; my @arguments = _get_args($arg_list); my $namespace = $arguments[1]->[0]; - $namespace = $namespace->string; + $namespace = $namespace->string || 'WebGUI'; $self->{_i18n_objects}->{$symbol_name} = $namespace; return; } elsif ($elem eq 'get') { ##i18n fetch? Check symbol my $symbol_name = _get_symbol_name($elem); + return unless $symbol_name && exists $self->{_i18n_objects}->{$symbol_name}; my $arg_list = $elem->snext_sibling; return unless ref $arg_list eq 'PPI::Structure::List'; my @arguments = _get_args($arg_list);