Custom Checkstyle checks for Android projects.
Check | Description |
---|---|
AndroidViewFieldNameCheck |
Check Android view field name (example: for TextView variable's name must be starts with tv ) |
ContextFirstParameterCheck |
Check Context as first parameter in a class constructor or in an arguments list |
MethodObjectReturnAnnotationCheck |
Check annotation for a method with return values (by default it is @NonNull and @Nullable ) |
MethodParametersAnnotationCheck |
Check annotation for an argument in a class constructor or a method (by default it is @NonNull and @Nullable ) |
Add https://jitpack.io
as Maven repository to build.gradle
(needs for downloading dependencies from GitHub):
repositories {
maven {
url "https://jitpack.io"
}
}
If you are using Checkstyle plugin for Gradle, add
checks project as dependency in the dependencies
section in the build.gradle
:
checkstyle 'com.github.fartem:checkstyle-checks-android:master'
Add to TreeWalker
module:
<module name="com.smlnskgmail.jaman.checkstyle.checks.AndroidViewFieldNameCheck">
<property name="id" value="AndroidViewFieldNameCheck" />
</module>
<module name="com.smlnskgmail.jaman.checkstyle.checks.ContextAsFirstParameterCheck">
<property name="id" value="ContextFirstParameterCheck" />
</module>
<module name="com.smlnskgmail.jaman.checkstyle.checks.MethodObjectReturnAnnotationCheck">
<property name="id" value="MethodObjectReturnAnnotationCheck" />
</module>
<module name="com.smlnskgmail.jaman.checkstyle.checks.MethodParametersAnnotationCheck">
<property name="id" value="MethodParametersAnnotationCheck" />
</module>
Read Commit Convention. Make sure your build is green before you contribute your pull request. Then:
./gradlew clean
./gradlew build
If you don't see any error messages, submit your pull request.
- @fartem as Artem Fomchenkov