Debug Code Elimination
Potency None
Resilience High
Cost None
Tags: debug code, debug, elimination, removal, optimization
Description
Debug code main purpose is to help the developer doing code debugging. This can be done in many different ways, such as log statements or assertions. Debug Code Elimination removes statements and public variable declarations used to control the output of debugging messages that help on code debugging.
Notes:
- Try to use (uppercase) names that do not collide with other declarations
- Local declarations with the same name will not be removed
Code Annotation Example
Examples
The following example contains some debug code to be removed:
if (typeof DEBUG === 'undefined') {
DEBUG = true;
}
if (DEBUG) {
console.log('Collecting objects.');
}
DEBUG && console.log('In debugging mode.');
Adding DEBUG
to the variables list removes any statement or public variable declaration with that name, leading to:
Option Types
Name | Required | Default Value | Description |
variables | Yes | N/A | List of variables that are intended to be removed from the code. |
Browser Compatibility
Browser | Compatible Versions | Tested Versions | Notes |
Chrome | 80+ | 80+ | |
Firefox | 80+ | 80+ | |
Internet Explorer | 8+ | 8+ | |
Microsoft Edge | 108+ | 108+ | |
Safari | 12.1+ | 12.1+ | |
API Parameters
Example:
{
"keys": {
"accessKey": "XXXXXX",
"secretKey": "YYYYYY"
},
"applicationId": "ZZZZZZ",
"params": [
{
"name": "debugCodeElimination",
"options": {
"variables": "VALUE"
}
}
]
}