We will be at OWASP APPSEC EUROPE 2017 - Belfast! Let’s talk!MORE INFO

Help Center

Get to know more about our API, Code Annotations and Code Transformations

Function Outlining

Potency
3 / 3
Resilience
3 / 5
Cost
1 / 5

Tags: statements

Description

Function Outlining transforms a single or group of statements into a new
function declaration.

Examples

Consider the following function declaration:

1
2
3
4
5
function addPrefix (array, prefix) {
for (var i = array.length - 1; i >= 0; i--) {
array[i] = prefix + array[i];
}
}

After transformation the addPrefix function will depend on functions to
evaluate expressions that were previously inline:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var o = {
b: function (b, c) {
return b + c;
},
a: function (b, c) {
return b - c;
},
c: function (b, c) {
return b >= c;
},
d: function (b, c) {
return b[c];
}
};
function addPrefix (array, prefix) {
for (var i = o.a(array.length, 1); o.c(i, 0); i--) {
array[i] = o.b(prefix, o.d(array, i));
}
}

Option Types

Name Required Default Value Description
freq No 0.2 Probability of applying the transformation when the node allows for the transformation to happen.
min No N/A Minimum number of times the transformation is applied on the node.
max No -1 Maximum number of times the transformation is applied on the node.

API Parameters

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"keys": {
"accessKey": "XXXXXX",
"secretKey": "YYYYYY"
},
"applicationId": "ZZZZZZ",
"params": [
{
"name": "functionOutlining",
"options": {}
}
]
}