Remove unused javascript code based on coverage report

后端 未结 6 811
北海茫月
北海茫月 2021-02-05 07:45

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 uti

6条回答
  •  青春惊慌失措
    2021-02-05 08:15

    This approach will not work I fear. Not that easy and not with the data you have available at least.

    1. The coverage report for your test which utilizes all the needed functionality is using which coverage metric? Does it excercise all values, conditions and possible combinations thereof? If not, you may miss out on usage of some part of the code.

    2. If your coverage report is not accurate you cannot rely on it for removal actions. Although braces

    Given a sufficiently good test suite you can use the code coverage reports for hints however. Remove code that is reported as unused, re-run your tests and check whether they still pass. Repeat until nore more code snippets can be removed.

提交回复
热议问题