Reputation: 770
Can A Javascript static analysis tool like Google Closure , JSHint , JSLint do the following :
Upvotes: 1
Views: 456
Reputation: 95334
Our CloneDR static analysis tool will find exact and near-duplicate copies of arbitrary code fragments for many languages, including JavaScript. It will do so within and across files. (CloneDR does not detect unused code.)
Upvotes: 0
Reputation: 28810
These static analysis tools have no concept of files, only the textual representation of code. So they do not identify unused or duplicate files. They would have to have knowledge about how you deploy the files in order to do that.
They do not identify unused functions.
They do identify duplicate functions in the same file. At least in most cases:
function a() {}
/* ... */
function a() {}
will give you a is already defined
. However:
var a;
a = function () {};
/* ... */
a = function () {};
is perfectly legal, and will not give you an error.
If you want to find duplicate functions in all your files, you can simply concatenate them together before linting.
Upvotes: 1