fartem / checkstyle-checks-android

Custom Checkstyle checks for Android projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

checkstyle-checks-android

GitHubActions

About

Custom Checkstyle checks for Android projects.

Checks

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)

Installation

Gradle

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'

How to use

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>

How to contribute

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.

Contributors

About

Custom Checkstyle checks for Android projects

License:MIT License


Languages

Language:Java 100.0%