Is there any tool to detect code duplication in JavaScript? I tried "PMD Duplicate code detector" but it is not supporting .js extension.
You can use JS Inspect it detects copy-pasted and structurally similar code, also supports *.js
npm install -g jsinspect
jsinspect -t 50 ./path/to/src
I would recommend JSCPD
npm install -g jscpd
jscpd ./path/to/code
(you have several type of reporters, default is console, but you can use html like this: jscpd -r html ./path/to/code
)
Other solutions:
IDE can have this functionality. I use IntelliJ, this IDE has a built-in duplicate code checking mechanism at 2 scopes:
我建议看看这个线程(也在stackoverflow上): Javascript源代码分析(特别是复制检查)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.