前端工程javascript代码中的坏味道
常见问题:
1、Function ‘englishToPigLatin‘ has a complexity of xxx.
2、This function has too many statements (16)
3、Blocks are nested too deeply (5).
关于Lint的配置项:如最大语句数,复杂度,最大嵌套数,最大长度,最多传参,最多嵌套回调
学会使用ESlint或其他诊断工具
检查出粘贴复制和结构类似的代码片段 – jsinspect (https://github.com/danielstjules)
$ npm install -g jsinspect
$ jsinspect -t 30 -i ./path/to/src
(某个整体部分有多少个重复点?)
Match - 2 instances
(出现重复的代码地方)
- .\transferOperation.js:740,747
+ .\transferOperation.js:754,761
(扫描总结)
85 matches found across 33 files
原文:http://www.cnblogs.com/HXW-from-DJTU/p/6096706.html