File: ProhibitAmbiguousNames.run

package info (click to toggle)
libperl-critic-perl 1.156-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,544 kB
  • sloc: perl: 24,092; lisp: 341; makefile: 7
file content (110 lines) | stat: -rw-r--r-- 2,509 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
## name Basic failures.
## failures 11
## cut

my $left = 1;          # scalar
my @right = ('foo');   # array
our $no = undef;       # our
my %abstract;          # hash
local *main::contract; # pkg prefix on var
sub record {}          # sub
my ($second, $close);  # catch both of these
sub pkg::bases {}      # pkg prefix on sub
my ($last, $set);

#-----------------------------------------------------------------------------

## name Ambiguous word in compound name.
## TODO False negative: Ambiguous words in compound names should be forbidden
## failures 2
## cut

my $last_record;
my $first_record;

#-----------------------------------------------------------------------------

## name Basic passes.
## failures 0
## cut

for my $bases () {}
print $main::contract;
my %hash = (left => 1, center => 'right');
sub no_left_turn {}
local $\; # for Devel::Cover; an example of a var declaration without \w

#-----------------------------------------------------------------------------

## name Ambiguous name on rhs.
## TODO False positive: Need to distinguish rhs in variable statements
## failures 0
## cut

my ($foo) = ($left);

#-----------------------------------------------------------------------------

## name Ambiguous, but exempt by convention
## failures 0
## cut

no warnings;
close $fh;

#-----------------------------------------------------------------------------

## name Custom null configuration
## parms { forbid => q{} }
## failures 0
## cut

my $left;
my $close;
END_PERL

#-----------------------------------------------------------------------------

## name Custom configuration: "foo bar baz quux"
## parms { forbid => 'foo bar baz quux' }
## failures 2
## cut

my $left;
my $close;
my $foo;
my $bar;

#-----------------------------------------------------------------------------

## name Custom configuration: "foo bar baz quux"
## parms { forbid => 'foo bar left close' }
## failures 4
## cut

my $left;
my $close;
my $foo;
my $bar;

#%config = ( forbid => join q{ }, qw(foo bar baz quux), @default );

#-----------------------------------------------------------------------------

## name Custom null configuration
## parms { forbid => undef }
## failures 2
## cut

my $left;
my $close;

#-----------------------------------------------------------------------------
# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 78
#   indent-tabs-mode: nil
#   c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :