AndroidLintPlus:定制Lint规则,程序员何苦为难程序员!
2016-05-04 16:16
736 查看
扩展Lint 规则
1、JavaChineseStringDetector:检查 java 代码中的中文字符串,有些团队的开发规范里规定中文字符串必须放到 string.xml里。2、LayoutFileNameDetector:检查布局文件的文件名,你可以在这个类里定义一套自己团队的命名规范的正则表达式。强制整个团队的命名统一。
3、ViewIdDetector:检查布局文件里 view 的 id,同上上一条,你也可以定义一套自己的正则。
4、用法见下文,顺便提一下你可以把定制后的 lint task加到 build 过程里来强制规范代码,如果 lint 失败则 build 失败。你还可以集成到AndroidCodeQuality
使用checkstyle,pmd,findbug共同提高代码质量。
【Github源码地址,欢迎Star和Follow】
最后一句:程序员何苦为难程序员呢
Feature
1.JavaChineseStringDetector:check chinese string in java file.2.LayoutFileNameDetector:check xml file name in layout folder.
3.ViewIdDetector:check view id name in layout xml file.
4.custom your own rule in JavaChineseStringDetector.java,LayoutFileNameDetector.java,ViewIdDetector.java
Usage
1.go to the module ‘library_java’ and run ‘../gradlew clean install’2.config which Detector to use
android { ... lintOptions { abortOnError true textReport true //checkAllWarnings true check 'ViewId','JavaChineseString','LayoutFileName' } }
3.run ‘./gradlew lint’ at project root
4.you can config this to the build task,when the check rule error,stop build task. you can integrate this into AndroidCodeQuality
To go further
This project is based on these two other projects, which are awesome. Consider take a look at them :- custom-lint-rules.
- linette.
相关文章推荐
- PHP程序员的技术成长规划
- 剑指offer之面试题27:二叉搜索树与双向链表
- 奋斗吧,程序员——第二十六章 赌书消得泼茶香, 当时只道是寻常
- 那天的面试题
- 论程序员的自我修养
- 经典的SQL语句面试题
- 职业规划[转]
- 程序员的成长和代码行数的关系
- 手机的九宫格图案解锁总共能绘出多少种图案?(hiho模拟面试题2 - google在线技术笔试模拟)
- 神网友的面试总结
- 【公测】智能&便捷&稳定 新版家园只为给你不一样的体验~
- Java面试常客之四大代码块
- 程序员公司任职软件开发著作权该归谁呢
- 百度——基础架构部面试(产品实习生-营销云方向)
- UIImage初始化的区别两种方法介绍(面试常见)
- 【杂谈】PHP程序员的能力水平层次
- 纷享逍客前端开发面试心得
- Mybatis常见面试题一
- 作为程序员最应该投资的是这十件事
- 转:手册网(程序员开发手册相关网站)