by QJoy (email alexq_andr@163.com)
AndroidLintWatchDog is a collection of some typical Android-Custom-Lint-Check sample. some of them can be used directly, others you can make a little modification to adapt to your project.
##Features
- ImageFileSizeDetector : 检查图片文件尺寸是否超过某个限定的大小;
- LoggerUsageDetector : 使用android.util.Log任何方法;
- FastJsonDetector : 检查fastJson格式化类对象是否实现了Serializable或者Parcelable;
- BaseActivityDetector : 检查工程所有Activity是否继承自LFBaseActivity或者LFBaseAppCompatActivity;
- ViewIdNameDetector : 检查layout文件中的id是否符合《Android-Code-Style》中"布局文件中的id命名"这个部分的规定;
- AndroidStudio
###Import library into project
Here is two way to use yourself's custom-lint-check.
1. Basic Way : import library from local module.
Like this:
debugCompile project(':liblflintrules_aarwrap')
2. Advanced Way : push your library to maven/jcenter,import from remote.
Like this:
debugCompile 'com.qjoy:liblflintrules_aarwrap:1.0.3'
###Setting for lint Add lint setting in your module gradle file.
android {
...
lintOptions {
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
}
}
Do these in AndroidStudio Terminal tab:
1. "cd" to the module that you want check your lint-rules;
例:cd app
2. "lint" command for it;
例:../gradlew lint
3. BUILD SUCCESSFUL,now here is a html file be maked.open it,read it.
例:Wrote HTML report to file:///省去了无用的路径/app/build/outputs/lint-results-debug.html
AndroidLintWatchDog is released under the BSD license. See LICENSE for details.