pull/926/head
s1m0 3 years ago
parent 20f2aaa036
commit 9e6bcfab07
  1. 39
      tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol
  2. 693
      tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol.0.4.25.CostlyOperationsInLoop.json
  3. 39
      tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol
  4. 693
      tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol.0.5.16.CostlyOperationsInLoop.json
  5. 39
      tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol
  6. 693
      tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol.0.6.11.CostlyOperationsInLoop.json
  7. 39
      tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol
  8. 693
      tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol.0.7.6.CostlyOperationsInLoop.json

@ -1,9 +1,19 @@
pragma solidity ^0.4.24;
contract CostlyOperationsInLoopBase{
uint loop_count_base = 100;
uint state_variable_base = 0;
contract CostlyOperationsInLoop{
function bad_base() external {
for (uint i=0; i < loop_count_base; i++){
state_variable_base++;
}
}
}
contract CostlyOperationsInLoop is CostlyOperationsInLoopBase{
uint loop_count = 100;
uint state_variable=0;
uint state_variable = 0;
mapping (uint=>uint) map;
uint[100] arr;
@ -13,13 +23,32 @@ contract CostlyOperationsInLoop{
}
}
function ignore_for_now1() external {
function bad2() external{
for (uint i=0; i < loop_count; i++){
for (uint j=0; j < loop_count; j++){
// Do something
}
state_variable++;
}
}
function bad3() external{
for (uint i=0; i < loop_count; i++){
bad3_internal();
}
}
function bad3_internal() internal{
state_variable++;
}
function ignore_for_now1() external{
for (uint i=0; i < 100; i++){
map[i] = i+1;
}
}
function ignore_for_now2() external {
function ignore_for_now2() external{
for (uint i=0; i < 100; i++){
arr[i] = i+1;
}

@ -4,21 +4,21 @@
"elements": [
{
"type": "function",
"name": "bad",
"name": "bad_base",
"source_mapping": {
"start": 252,
"length": 373,
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
@ -26,16 +26,18 @@
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 26,
"length": 1081,
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
@ -44,8 +46,133 @@
8,
9,
10,
11,
12,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
},
{
"type": "node",
"name": "state_variable_base ++",
"source_mapping": {
"start": 271,
"length": 21,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
7
],
"starting_column": 7,
"ending_column": 28
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad_base",
"source_mapping": {
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
}
}
}
],
"description": "CostlyOperationsInLoopBase.bad_base() (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#5-9) has costly operations inside a loop:\n\t- state_variable_base ++ (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#7)\n",
"markdown": "[CostlyOperationsInLoopBase.bad_base()](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L5-L9) has costly operations inside a loop:\n\t- [state_variable_base ++](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L7)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L5-L9",
"id": "a5134568bf722ac31d7c4d41595c23e1a5ff9b79902e9502f78ccfe9a430b87a",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad",
"source_mapping": {
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
13,
14,
15,
@ -68,7 +195,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -81,7 +237,7 @@
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 410,
"start": 912,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
@ -89,7 +245,7 @@
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
12
22
],
"starting_column": 7,
"ending_column": 23
@ -99,7 +255,7 @@
"type": "function",
"name": "bad",
"source_mapping": {
"start": 252,
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
@ -107,11 +263,11 @@
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
@ -121,24 +277,14 @@
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 26,
"length": 1081,
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
@ -161,7 +307,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -173,10 +348,450 @@
}
}
],
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#10-14) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#12)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L10-L14) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L12)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L10-L14",
"id": "d00641f4d08f61911f58d8c73e60ce3f655d045c8f6207b7fdf91a029fd14962",
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#20-24) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#22)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L20-L24) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L22)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L20-L24",
"id": "92dbac16da1c357bad3a24661de0e92213ac3a701d80655fadb64359ff98d21d",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1363,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
31
],
"starting_column": 7,
"ending_column": 23
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad2() (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#26-33) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#31)\n",
"markdown": "[CostlyOperationsInLoop.bad2()](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L26-L33) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L31)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L26-L33",
"id": "0cde1ae7c1410e0eb0d07ff2c21adc20b1c7f7a654780c8d41069ad3a34e73b4",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1894,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
42
],
"starting_column": 5,
"ending_column": 21
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad3_internal() (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#41-43) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#42)\n",
"markdown": "[CostlyOperationsInLoop.bad3_internal()](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L41-L43) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L42)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.4.25/multiple_costly_operations_in_loop.sol#L41-L43",
"id": "d92f330b3f0aafe1dd0a8c4d79935664297b8d73741df8970e132423d20a1c08",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"

@ -1,9 +1,19 @@
// pragma solidity ^0.4.24;
contract CostlyOperationsInLoopBase{
uint loop_count_base = 100;
uint state_variable_base = 0;
contract CostlyOperationsInLoop{
function bad_base() external {
for (uint i=0; i < loop_count_base; i++){
state_variable_base++;
}
}
}
contract CostlyOperationsInLoop is CostlyOperationsInLoopBase{
uint loop_count = 100;
uint state_variable=0;
uint state_variable = 0;
mapping (uint=>uint) map;
uint[100] arr;
@ -13,13 +23,32 @@ contract CostlyOperationsInLoop{
}
}
function ignore_for_now1() external {
function bad2() external{
for (uint i=0; i < loop_count; i++){
for (uint j=0; j < loop_count; j++){
// Do something
}
state_variable++;
}
}
function bad3() external{
for (uint i=0; i < loop_count; i++){
bad3_internal();
}
}
function bad3_internal() internal{
state_variable++;
}
function ignore_for_now1() external{
for (uint i=0; i < 100; i++){
map[i] = i+1;
}
}
function ignore_for_now2() external {
function ignore_for_now2() external{
for (uint i=0; i < 100; i++){
arr[i] = i+1;
}

@ -4,21 +4,21 @@
"elements": [
{
"type": "function",
"name": "bad",
"name": "bad_base",
"source_mapping": {
"start": 255,
"length": 373,
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
@ -26,16 +26,18 @@
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 29,
"length": 1081,
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
@ -44,8 +46,133 @@
8,
9,
10,
11,
12,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
},
{
"type": "node",
"name": "state_variable_base ++",
"source_mapping": {
"start": 271,
"length": 21,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
7
],
"starting_column": 7,
"ending_column": 28
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad_base",
"source_mapping": {
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
}
}
}
],
"description": "CostlyOperationsInLoopBase.bad_base() (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#5-9) has costly operations inside a loop:\n\t- state_variable_base ++ (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#7)\n",
"markdown": "[CostlyOperationsInLoopBase.bad_base()](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L5-L9) has costly operations inside a loop:\n\t- [state_variable_base ++](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L7)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L5-L9",
"id": "37bb0ca67ffcfb1625ffbea095bba93ea031ed6f483bb80a976c7c68309872dd",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad",
"source_mapping": {
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
13,
14,
15,
@ -68,7 +195,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -81,7 +237,7 @@
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 413,
"start": 912,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
@ -89,7 +245,7 @@
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
12
22
],
"starting_column": 7,
"ending_column": 23
@ -99,7 +255,7 @@
"type": "function",
"name": "bad",
"source_mapping": {
"start": 255,
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
@ -107,11 +263,11 @@
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
@ -121,24 +277,14 @@
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 29,
"length": 1081,
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
@ -161,7 +307,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -173,10 +348,450 @@
}
}
],
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#10-14) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#12)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L10-L14) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L12)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L10-L14",
"id": "1496f0664c18be47e9b27df825eb148e11f5458abbe2c0b8758c0645a220d802",
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#20-24) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#22)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L20-L24) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L22)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L20-L24",
"id": "94a7ffd0d3ada78ae8ace1304b276d677415a08dcdff51fc05889122e14633da",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1363,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
31
],
"starting_column": 7,
"ending_column": 23
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad2() (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#26-33) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#31)\n",
"markdown": "[CostlyOperationsInLoop.bad2()](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L26-L33) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L31)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L26-L33",
"id": "c0c91898e5b5af12af49b6aefdc4790190101774bffad8e446ba9c857ff86525",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1894,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
42
],
"starting_column": 5,
"ending_column": 21
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad3_internal() (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#41-43) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#42)\n",
"markdown": "[CostlyOperationsInLoop.bad3_internal()](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L41-L43) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L42)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.5.16/multiple_costly_operations_in_loop.sol#L41-L43",
"id": "6ebf2ecedb330a477079a9b72f1ba6ffc5717e08017f700538ec42d3eeab355b",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"

@ -1,9 +1,19 @@
// pragma solidity ^0.4.24;
contract CostlyOperationsInLoopBase{
uint loop_count_base = 100;
uint state_variable_base = 0;
contract CostlyOperationsInLoop{
function bad_base() external {
for (uint i=0; i < loop_count_base; i++){
state_variable_base++;
}
}
}
contract CostlyOperationsInLoop is CostlyOperationsInLoopBase{
uint loop_count = 100;
uint state_variable=0;
uint state_variable = 0;
mapping (uint=>uint) map;
uint[100] arr;
@ -13,13 +23,32 @@ contract CostlyOperationsInLoop{
}
}
function ignore_for_now1() external {
function bad2() external{
for (uint i=0; i < loop_count; i++){
for (uint j=0; j < loop_count; j++){
// Do something
}
state_variable++;
}
}
function bad3() external{
for (uint i=0; i < loop_count; i++){
bad3_internal();
}
}
function bad3_internal() internal{
state_variable++;
}
function ignore_for_now1() external{
for (uint i=0; i < 100; i++){
map[i] = i+1;
}
}
function ignore_for_now2() external {
function ignore_for_now2() external{
for (uint i=0; i < 100; i++){
arr[i] = i+1;
}

@ -4,21 +4,21 @@
"elements": [
{
"type": "function",
"name": "bad",
"name": "bad_base",
"source_mapping": {
"start": 255,
"length": 373,
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
@ -26,16 +26,18 @@
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 29,
"length": 1081,
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
@ -44,8 +46,133 @@
8,
9,
10,
11,
12,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
},
{
"type": "node",
"name": "state_variable_base ++",
"source_mapping": {
"start": 271,
"length": 21,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
7
],
"starting_column": 7,
"ending_column": 28
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad_base",
"source_mapping": {
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
}
}
}
],
"description": "CostlyOperationsInLoopBase.bad_base() (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#5-9) has costly operations inside a loop:\n\t- state_variable_base ++ (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#7)\n",
"markdown": "[CostlyOperationsInLoopBase.bad_base()](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L5-L9) has costly operations inside a loop:\n\t- [state_variable_base ++](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L7)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L5-L9",
"id": "53602b905c8ae68d5325f0c11263f1c9b905406799ec70ca13638f4b1094c37f",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad",
"source_mapping": {
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
13,
14,
15,
@ -68,7 +195,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -81,7 +237,7 @@
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 413,
"start": 912,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
@ -89,7 +245,7 @@
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
12
22
],
"starting_column": 7,
"ending_column": 23
@ -99,7 +255,7 @@
"type": "function",
"name": "bad",
"source_mapping": {
"start": 255,
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
@ -107,11 +263,11 @@
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
@ -121,24 +277,14 @@
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 29,
"length": 1081,
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
@ -161,7 +307,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -173,10 +348,450 @@
}
}
],
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#10-14) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#12)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L10-L14) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L12)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L10-L14",
"id": "aad1cf92bc7ec06342b0fa39a1affa4e06b09bdb3b0c8fae61aeb4221236041a",
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#20-24) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#22)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L20-L24) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L22)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L20-L24",
"id": "a4f559a14007167a13506a3c865345fb2c050b8d2c660804cc5e301db553822a",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1363,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
31
],
"starting_column": 7,
"ending_column": 23
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad2() (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#26-33) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#31)\n",
"markdown": "[CostlyOperationsInLoop.bad2()](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L26-L33) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L31)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L26-L33",
"id": "3a1b0ff0bee83dfad403a074eb81c6d845c5da8e99e98433004ba72c1b2c624c",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1894,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
42
],
"starting_column": 5,
"ending_column": 21
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad3_internal() (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#41-43) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#42)\n",
"markdown": "[CostlyOperationsInLoop.bad3_internal()](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L41-L43) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L42)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.6.11/multiple_costly_operations_in_loop.sol#L41-L43",
"id": "4bb89ccd252e2233f67cccaf8b40354da7edcb7c5b36df1edfeab0cafed05b74",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"

@ -1,9 +1,19 @@
// pragma solidity ^0.4.24;
contract CostlyOperationsInLoopBase{
uint loop_count_base = 100;
uint state_variable_base = 0;
contract CostlyOperationsInLoop{
function bad_base() external {
for (uint i=0; i < loop_count_base; i++){
state_variable_base++;
}
}
}
contract CostlyOperationsInLoop is CostlyOperationsInLoopBase{
uint loop_count = 100;
uint state_variable=0;
uint state_variable = 0;
mapping (uint=>uint) map;
uint[100] arr;
@ -13,13 +23,32 @@ contract CostlyOperationsInLoop{
}
}
function ignore_for_now1() external {
function bad2() external{
for (uint i=0; i < loop_count; i++){
for (uint j=0; j < loop_count; j++){
// Do something
}
state_variable++;
}
}
function bad3() external{
for (uint i=0; i < loop_count; i++){
bad3_internal();
}
}
function bad3_internal() internal{
state_variable++;
}
function ignore_for_now1() external{
for (uint i=0; i < 100; i++){
map[i] = i+1;
}
}
function ignore_for_now2() external {
function ignore_for_now2() external{
for (uint i=0; i < 100; i++){
arr[i] = i+1;
}

@ -4,21 +4,21 @@
"elements": [
{
"type": "function",
"name": "bad",
"name": "bad_base",
"source_mapping": {
"start": 255,
"length": 373,
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
@ -26,16 +26,18 @@
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 29,
"length": 1081,
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
@ -44,8 +46,133 @@
8,
9,
10,
11,
12,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
},
{
"type": "node",
"name": "state_variable_base ++",
"source_mapping": {
"start": 271,
"length": 21,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
7
],
"starting_column": 7,
"ending_column": 28
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad_base",
"source_mapping": {
"start": 102,
"length": 389,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
5,
6,
7,
8,
9
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoopBase",
"source_mapping": {
"start": 0,
"length": 494,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad_base()"
}
}
}
}
],
"description": "CostlyOperationsInLoopBase.bad_base() (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#5-9) has costly operations inside a loop:\n\t- state_variable_base ++ (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#7)\n",
"markdown": "[CostlyOperationsInLoopBase.bad_base()](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L5-L9) has costly operations inside a loop:\n\t- [state_variable_base ++](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L7)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L5-L9",
"id": "a150cde3056e29877ab4fc8d64ce48a08db143bcb5dc2bcccae8f7848e666940",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad",
"source_mapping": {
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
13,
14,
15,
@ -68,7 +195,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -81,7 +237,7 @@
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 413,
"start": 912,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
@ -89,7 +245,7 @@
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
12
22
],
"starting_column": 7,
"ending_column": 23
@ -99,7 +255,7 @@
"type": "function",
"name": "bad",
"source_mapping": {
"start": 255,
"start": 754,
"length": 373,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
@ -107,11 +263,11 @@
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
10,
11,
12,
13,
14
20,
21,
22,
23,
24
],
"starting_column": 3,
"ending_column": 4
@ -121,24 +277,14 @@
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 29,
"length": 1081,
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
@ -161,7 +307,36 @@
32,
33,
34,
35
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
],
"starting_column": 1,
"ending_column": 2
@ -173,10 +348,450 @@
}
}
],
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#10-14) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#12)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L10-L14) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L12)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L10-L14",
"id": "d6753ee3bfd5d2bb35baf5f9aa672d98eb00b2a771cbbfe37d5bac0d009f56ad",
"description": "CostlyOperationsInLoop.bad() (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#20-24) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#22)\n",
"markdown": "[CostlyOperationsInLoop.bad()](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L20-L24) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L22)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L20-L24",
"id": "c92490750428b640ff46202b5fe9d0eb62ab98a70419cef5ca80530c15b14180",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1363,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
31
],
"starting_column": 7,
"ending_column": 23
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad2",
"source_mapping": {
"start": 1131,
"length": 343,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
26,
27,
28,
29,
30,
31,
32,
33
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad2()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad2() (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#26-33) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#31)\n",
"markdown": "[CostlyOperationsInLoop.bad2()](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L26-L33) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L31)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L26-L33",
"id": "f7ebc0c37f31c1a68b8fbfe7530fd66f3c590e5631478cc88d03eeaa8c09f6a6",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"
},
{
"elements": [
{
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
},
{
"type": "node",
"name": "state_variable ++",
"source_mapping": {
"start": 1894,
"length": 16,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
42
],
"starting_column": 5,
"ending_column": 21
},
"type_specific_fields": {
"parent": {
"type": "function",
"name": "bad3_internal",
"source_mapping": {
"start": 1855,
"length": 60,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
41,
42,
43
],
"starting_column": 3,
"ending_column": 4
},
"type_specific_fields": {
"parent": {
"type": "contract",
"name": "CostlyOperationsInLoop",
"source_mapping": {
"start": 496,
"length": 1899,
"filename_used": "/GENERIC_PATH",
"filename_relative": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"filename_absolute": "/GENERIC_PATH",
"filename_short": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol",
"is_dependency": false,
"lines": [
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
],
"starting_column": 1,
"ending_column": 2
}
},
"signature": "bad3_internal()"
}
}
}
}
],
"description": "CostlyOperationsInLoop.bad3_internal() (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#41-43) has costly operations inside a loop:\n\t- state_variable ++ (tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#42)\n",
"markdown": "[CostlyOperationsInLoop.bad3_internal()](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L41-L43) has costly operations inside a loop:\n\t- [state_variable ++](tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L42)\n",
"first_markdown_element": "tests/detectors/costly-loop/0.7.6/multiple_costly_operations_in_loop.sol#L41-L43",
"id": "77bb0a1e0308312bb9696553d6384270c433fcbebd6311e053c6979d4bdc2128",
"check": "costly-loop",
"impact": "Informational",
"confidence": "Medium"

Loading…
Cancel
Save