Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 14855
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: thaljef [...] cpan.org
Requestors: adamk [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.08_02
Fixed in: 0.18



Subject: Home discovery is dangerously naive...
The way you try to discover the default rc file is quite naive and a potential error source. #Check usual env vars for my $var ( qw(HOME USERPROFILE HOMESHARE) ){ my $path = catfile( $ENV{$var}, $rc_file ); return $path if -f $path; } What you need to do here is 1) Check for the installation of File::HomeDir. If it exists, use it first. 2) For each ENV key you check, you need to make sure the key actually exists. So # Use File::HomeDir here if installed... #Check usual env vars for my $var ( qw(HOME USERPROFILE HOMESHARE) ){ next unless defined $ENV{$var}; my $path = catfile( $ENV{$var}, $rc_file ); return $path if -f $path; } BTW, using File::HomeDir like that is going to go a long way to make Perl::Critic Win32-safe.
From: thaljef [...] cpan.org
Hi Adam- I had already fixed the case of undefined environment variables (this was causing some 'uninitialized' warnings). But I hadn't heard of File::HomeDir. I will try it out. Thanks for the tip! -Jeff [ADAMK - Fri Sep 30 12:27:43 2005]: Show quoted text
> The way you try to discover the default rc file is quite naive and a > potential error source. > > #Check usual env vars > for my $var ( qw(HOME USERPROFILE HOMESHARE) ){ > my $path = catfile( $ENV{$var}, $rc_file ); > return $path if -f $path; > } > > What you need to do here is > > 1) Check for the installation of File::HomeDir. If it exists, use it > first. > 2) For each ENV key you check, you need to make sure the key actually > exists. > > So > > # Use File::HomeDir here if installed... > > #Check usual env vars > for my $var ( qw(HOME USERPROFILE HOMESHARE) ){ > next unless defined $ENV{$var}; > my $path = catfile( $ENV{$var}, $rc_file ); > return $path if -f $path; > } > > BTW, using File::HomeDir like that is going to go a long way to make > Perl::Critic Win32-safe. >
This has been resolved. File::HomeDir is now an optional dependency. If it is availble, P::C usese it to locate the home directory.