Skip to content

Commit

Permalink
Add a perlcriticrc file.
Browse files Browse the repository at this point in the history
Change the format so we can see the policy names (and turn them off)

Correct or turn off all the severity 5 policies.

$VERSION = eval { $VERSION };  does not DWIM.  It must be a string eval.

Remove uses of "use vars".
  • Loading branch information
schwern committed Aug 13, 2008
1 parent bd54d53 commit 65ce630
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .perlcriticrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Change the default message to show the policy name so we can shut it up if necessary
verbose = %m [%p] at %f line %l, near '%r'\n
10 changes: 8 additions & 2 deletions lib/Test/Builder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use 5.006;
use strict;

our $VERSION = '0.80_01';
$VERSION = eval { $VERSION }; # make the alpha version come out as a number
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)

# Make Test::Builder thread-safe for ithreads.
BEGIN {
Expand Down Expand Up @@ -286,6 +286,8 @@ sub no_plan {

$self->{No_Plan} = 1;
$self->{Have_Plan} = 1;

return 1;
}

=item B<has_plan>
Expand Down Expand Up @@ -712,6 +714,8 @@ sub cmp_ok {

my $test;
{
## no critic (BuiltinFunctions::ProhibitStringyEval)

local($@,$!,$SIG{__DIE__}); # isolate eval

my $code = $self->_caller_context;
Expand Down Expand Up @@ -977,6 +981,8 @@ sub _regex_ok {
}

{
## no critic (BuiltinFunctions::ProhibitStringyEval)

my $test;
my $code = $self->_caller_context;

Expand Down Expand Up @@ -1577,7 +1583,7 @@ of ''. Type can be one of the following:
Sometimes the Test::Builder test counter is incremented without it
printing any test output, for example, when current_test() is changed.
In these cases, Test::Builder doesn't know the result of the test, so
it's type is 'unkown'. These details for these tests are filled in.
it's type is 'unknown'. These details for these tests are filled in.
They are considered ok, but the name and actual_ok is left undef.
For example "not ok 23 - hole count # TODO insufficient donuts" would
Expand Down
39 changes: 21 additions & 18 deletions lib/Test/More.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package Test::More;
use 5.006;
use strict;

#---- perlcritic exemptions. ----#

# We use a lot of subroutine prototypes
## no critic (Subroutines::ProhibitSubroutinePrototypes)


# Can't use Carp because it might cause use_ok() to accidentally succeed
# even though the module being used forgot to use Carp. Yes, this
Expand All @@ -13,25 +18,23 @@ sub _carp {
}



use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO);
$VERSION = '0.80';
$VERSION = eval $VERSION; # make the alpha version come out as a number
our $VERSION = '0.80';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)

use Test::Builder::Module;
@ISA = qw(Test::Builder::Module);
@EXPORT = qw(ok use_ok require_ok
is isnt like unlike is_deeply
cmp_ok
skip todo todo_skip
pass fail
eq_array eq_hash eq_set
$TODO
plan
can_ok isa_ok new_ok
diag
BAIL_OUT
);
our @ISA = qw(Test::Builder::Module);
our @EXPORT = qw(ok use_ok require_ok
is isnt like unlike is_deeply
cmp_ok
skip todo todo_skip
pass fail
eq_array eq_hash eq_set
$TODO
plan
can_ok isa_ok new_ok
diag
BAIL_OUT
);


=head1 NAME
Expand Down Expand Up @@ -746,7 +749,7 @@ sub _eval {
my ($sigdie, $eval_result, $eval_error);
{
local($@,$!,$SIG{__DIE__}); # isolate eval
$eval_result = eval $code;
$eval_result = eval $code; ## no critic (BuiltinFunctions::ProhibitStringyEval)
$eval_error = $@;
$sigdie = $SIG{__DIE__} || undef;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/Test/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package Test::Simple;

use 5.004;

use strict 'vars';
use vars qw($VERSION @ISA @EXPORT);
$VERSION = '0.80';
$VERSION = eval $VERSION; # make the alpha version come out as a number
use strict;

our $VERSION = '0.80';
$VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval)

use Test::Builder::Module;
@ISA = qw(Test::Builder::Module);
@EXPORT = qw(ok);
our @ISA = qw(Test::Builder::Module);
our @EXPORT = qw(ok);

my $CLASS = __PACKAGE__;

Expand Down Expand Up @@ -77,7 +77,7 @@ will do what you mean (fail if stuff is empty)
=cut

sub ok ($;$) {
sub ok ($;$) { ## no critic (Subroutines::ProhibitSubroutinePrototypes)
$CLASS->builder->ok(@_);
}

Expand Down

0 comments on commit 65ce630

Please sign in to comment.