A tool that can analyze a program to find unreachable statements and dead variables (variables which are defined but never used afterwards). It works with a limited subset of JavaScript that includes variable declaration/assignment, if/else statements, continue/break, while loops, try/catch blocks, and throw statements.
The file "Project Documentation.docx" contains details on the analyses implemented.
This was a group project with Judah Rowe for the class COP 5021 (Program Analysis) at the University of Central Florida.
Assuming Node.js and npm are installed.
To use our tool:
- Open a terminal in this directory
- Run command
npm install
- Run command
node analyzer.js <inputFilename>
, replacing<inputFilename>
with the desired input filename
Example:
> node analyzer.js testProgram.js
Unreachable statement found: ExpressionStatement at char offset 611
Unreachable statement found: ExpressionStatement at char offset 1002
Unreachable statement found: ExpressionStatement at char offset 1070
Dead assignment found: i at char offset 388
Dead assignment found: i at char offset 576
Dead assignment found: i at char offset 585
Dead assignment found: i at char offset 984