package Perl::Critic::Policy::Bangs::ProhibitNoPlan;

use strict;
use warnings;
use Perl::Critic::Utils;
use base 'Perl::Critic::Policy';

our $VERSION = '1.12';

sub supported_parameters { return ()                             }
sub default_severity     { return $SEVERITY_LOW                  }
sub default_themes       { return qw( bangs tests )              }
sub applies_to           { return 'PPI::Token::QuoteLike::Words' }


sub violates {
    my ( $self, $elem, $doc ) = @_;

    if ( $elem =~ qr/\bno_plan\b/ ) {
        # Make sure that the previous sibling was Test::More, or return
        my $sib = $elem->sprevious_sibling() || return;
        $sib->isa('PPI::Token::Word') && $sib eq 'Test::More' || return;

        my $desc = q(Test::More with "no_plan" found);
        my $expl = q(Test::More should be given a plan indicating the number of tests run);
        return $self->violation( $desc, $expl, $elem );



=head1 NAME

Perl::Critic::Policy::Bangs::ProhibitNoPlan - Know what you're going to test.


This Policy is part of the L<Perl::Critic::Bangs> distribution.


Test::More should be given a plan indicting the number of tests to be
run. This policy searches for instances of Test::More called with


This Policy is not configurable except for the standard options.

=head1 AUTHOR

Andrew Moore <>


Adapted from policies by Jeffrey Ryan Thalhammer <>,
Based on App::Fluff by Andy Lester, "<andy at>"


Copyright (c) 2006-2013 Andy Lester <> and Andrew
Moore <>

This library is free software; you can redistribute it and/or modify it
under the terms of the Artistic License 2.0.