根据覆盖率报告删除未使用的JavaScript代码 [英] Remove unused javascript code based on coverage report
问题描述
有一个很大的javascript库(〜40 000行代码),一个应用程序使用的库代码不到 50%。
There is a big javascript library (~ 40 000 lines of code) and an application which uses less than 50% of the library's code.
有一个利用库中所有必需功能并可以生成覆盖率报告的测试。
There is a test which utilizes all the needed functionality from the library and can produce coverage report.
如何以编程方式删除依赖于该测试的所有未使用的代码行?
How to remove programmatically every unused line of code relying on the test?
注意:覆盖率报告包含已执行行的索引,但不正确:忽略右括号,使用方法名的行
Note: coverage report contains indices of lines which were executed but it is not accurate: closing braces are ignored, lines with method names are marked as executed even if the method body was not etc.
推荐答案
您可以尝试使用:
npm install -g fixmyjs
fixmyjs <filename or folder>
这是 fixmyjs项目
这是一个很棒的清理工具,它似乎与某些版本的ecmascript不兼容
it is a great tool for cleanup, it appears to lack compatibility with some versions of ecmascript
这篇关于根据覆盖率报告删除未使用的JavaScript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!