-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.sw
48 lines (37 loc) · 1.59 KB
/
main.sw
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
contract;
abi TestMagicNumber {
fn test_magic_number();
}
fn run_this(_amount: u64) {}
// Report entry should not be created
const VALUE: u64 = 120;
impl TestMagicNumber for Contract {
fn test_magic_number() {
let mut radius = VALUE;
// Report entry should be created:
// L18: The `Contract::test_magic_numbers` function contains magic number usage: `3 * radius`. Consider introducing a constant value.
let _di = 3 * radius * radius;
// Report entry should be created:
// L22: The `Contract::test_magic_numbers` function contains magic number usage: `radius * 10 / 200`. Consider introducing a constant value.
let _xi = radius * 10 / 200;
// Report entry should be created:
// L26: The `Contract::test_magic_numbers` function contains magic number usage: `radius * 10 * 200`. Consider introducing a constant value.
let _yi = radius * 10 * 200;
// Report entry should be created:
// L30: The `Contract::test_magic_numbers` function contains magic number usage: `radius < 221`. Consider introducing a constant value.
if radius < 221 {
return;
}
// Report entry should not be created:
if radius > radius {
return;
}
// Report entry should be created:
// L41: The `Contract::test_magic_numbers` function contains magic number usage: `radius > 5`. Consider introducing a constant value.
while radius > 5 {
radius = radius - 1;
}
// Report entry should not be created
run_this(5);
}
}