Javascript source code analysis ( specifically duplication checking )

浪子不回头ぞ 提交于 2020-01-21 08:33:11

问题


Partial duplicate of this

Notes: I already use JSLint extensively via a tool I wrote that scans in intervals my current project directory for recently updated/created .js files. It's drastically improved productivity for me and I doubt there is anything as good as JSLint for the price (it's free).

That said, is there any analysis tool out there that can find repetitive or near-duplicate code blocks, the goal being to make it easier to find opportunities to consolidate large files or small/medium sized projects?


回答1:


May not be exactly what your after, but Google's Javascript optimizer is worth a look.




回答2:


Our CloneDR is a tool for finding exact and near-miss cloned code blocks for a variety of languages. It will find duplicates in the same file or across literally thousands of files if you have them. You don't have to provide it with any guidance; it can find the cloned code by itself. And it won't be fooled by different indentation or line breaks, or even consistent renaming of identifiers

It does support JavaScript, even if it isn't clear from the website.

You can see sample clone reports for a variety of langauges at the website.




回答3:


You may want to have a look at jsinspect.

jsinspect ./src

It will print a list of code blocks that are either identical or structurally very similar.

And there's also jscpd.



来源:https://stackoverflow.com/questions/2627081/javascript-source-code-analysis-specifically-duplication-checking

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!