File Coverage

blib/lib/Perl/Critic/Policy/Community/ArrayAssignAref.pm
Criterion Covered Total %
statement 13 14 92.8
branch n/a
condition n/a
subroutine 5 6 83.3
pod 2 2 100.0
total 20 22 90.9


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::Community::ArrayAssignAref;
2              
3 1     1   1040 use strict;
  1         2  
  1         59  
4 1     1   11 use warnings;
  1         2  
  1         63  
5              
6 1     1   6 use Perl::Critic::Utils qw(:severities :classification :ppi);
  1         3  
  1         72  
7 1     1   555 use parent 'Perl::Critic::Policy::Plicease::ProhibitArrayAssignAref';
  1         3  
  1         6  
8              
9             our $VERSION = 'v1.0.4';
10              
11 2     2 1 47010 sub default_severity { $SEVERITY_MEDIUM }
12 0     0 1   sub default_themes { 'community' }
13              
14             1;
15              
16             =head1 NAME
17              
18             Perl::Critic::Policy::Community::ArrayAssignAref - Don't assign an anonymous
19             arrayref to an array
20              
21             =head1 DESCRIPTION
22              
23             A common mistake is to assign values to an array but use arrayref brackets
24             C<[]> rather than parentheses C<()>. This results in the array containing one
25             element, an arrayref, which is usually unintended. If intended, the arrayref
26             brackets can be wrapped in parentheses for clarity.
27              
28             @array = []; # not ok
29             @array = [1, 2, 3]; # not ok
30             @array = ([1, 2, 3]); # ok
31              
32             This policy is a subclass of L<Perl::Critic::Policy::Plicease::ProhibitArrayAssignAref>,
33             which is a fork of the L<Perl::Critic::Pulp> policy
34             L<Perl::Critic::Policy::ValuesAndExpressions::ProhibitArrayAssignAref>, and
35             performs the same function but in the C<community> theme.
36              
37             =head1 AFFILIATION
38              
39             This policy is part of L<Perl::Critic::Community>.
40              
41             =head1 CONFIGURATION
42              
43             This policy is not configurable except for the standard options.
44              
45             =head1 AUTHOR
46              
47             Dan Book, C<dbook@cpan.org>
48              
49             =head1 COPYRIGHT AND LICENSE
50              
51             Copyright 2015, Dan Book.
52              
53             This library is free software; you may redistribute it and/or modify it under
54             the terms of the Artistic License version 2.0.
55              
56             =head1 SEE ALSO
57              
58             L<Perl::Critic>, L<Perl::Critic::Pulp>