use
strict;
use
warnings;
use
constant {
DESC
=>
'Private variable used'
,
EXPL
=>
'Use published APIs'
,
};
sub
evaluate {
my
(
$class
,
$file
,
$tokens
,
$src
,
$args
) =
@_
;
my
@violations
;
for
(
my
$i
= 0,
my
$token_type
,
my
$token_data
;
my
$token
=
$tokens
->[
$i
];
$i
++) {
$token_type
=
$token
->{type};
$token_data
=
$token
->{data};
if
(
$token_type
== NAMESPACE &&
$token_data
=~ /\A_/) {
push
@violations
, {
filename
=>
$file
,
line
=>
$token
->{line},
description
=> DESC,
explanation
=> EXPL,
policy
=> __PACKAGE__,
};
}
}
return
\
@violations
;
}
1;