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
//! `Cyclomatic` implementation for Perl.
#![allow(clippy::wildcard_imports, clippy::enum_glob_use)]
#![allow(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
clippy::cast_sign_loss
)]
use super::*;
impl Cyclomatic for PerlCode {
fn compute<'a>(
node: &Node<'a>,
_code: &'a [u8],
_ancestors: Ancestors<'a, '_>,
stats: &mut Stats,
) {
use Perl as P;
match node.kind_id().into() {
P::IfStatement
| P::UnlessStatement
| P::ElsifClause
| P::WhileStatement
| P::UntilStatement
| P::ForStatement1
| P::ForStatement2
| P::WhenSimpleStatement
| P::IfSimpleStatement
| P::UnlessSimpleStatement
| P::WhileSimpleStatement
| P::UntilSimpleStatement
| P::ForSimpleStatement
| P::AMPAMP
| P::PIPEPIPE
| P::SLASHSLASH
// Compound short-circuit assignments `&&=`, `||=`, `//=`
// are semantically `x = x op y` and each carries one short-
// circuit decision edge, parallel to the JS-family fix in
// #248 (issue #249).
| P::AMPAMPEQ
| P::PIPEPIPEEQ
| P::SLASHSLASHEQ
| P::And
| P::Or
| P::TernaryExpression => {
stats.cyclomatic += 1.;
stats.cyclomatic_modified += 1.;
}
_ => {}
}
}
}