Policy/Community/ArrayAssignAref.pm

filter: Statementstmt 93.7% 15 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 91.6% 22 / 24 CC 1 SCAR 1.5
CC
1
Cov
94%
default_themes
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Policy/Community/AmpersandSubCalls.pm ↑ Summary Policy/Community/ConditionalDeclarations.pm »
1 package Perl::Critic::Policy::Community::ArrayAssignAref;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Perl::Critic::Utils qw(:severities :classification :ppi);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use parent 'Perl::Critic::Policy::Plicease::ProhibitArrayAssignAref';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = 'v1.0.4';
10  
11 2 ▶sub default_severity { $SEVERITY_MEDIUM }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
12 0 ▶sub default_themes { 'community' }
Subroutine default_themes: not called CC=1 SCAR=6.9
Pod documented
13  
14 1 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>
« Policy/Community/AmpersandSubCalls.pm ↑ Summary Policy/Community/ConditionalDeclarations.pm »