Aazim
Aazim

Reputation: 770

Question on Javascript static analysis tool like Google Closure , JSHint , JSLint

Can A Javascript static analysis tool like Google Closure , JSHint , JSLint do the following :

  1. Can they identify unused Javascript files and functions in the source code ?
  2. Can they identify duplicate Javascript files and functions in the source code ?

Upvotes: 1

Views: 456

Answers (2)

Ira Baxter
Ira Baxter

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

Magnar
Magnar

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

Related Questions