|
| 1 | +# checkstyle-checks-android |
| 2 | + |
| 3 | +[](https://github.com/fartem/checkstyle-checks-android/actions?query=workflow%3ABuild) |
| 4 | + |
| 5 | +## About |
| 6 | + |
| 7 | +Custom Checkstyle checks for Android projects. |
| 8 | + |
| 9 | +## Checks |
| 10 | + |
| 11 | +| Check | Description | Level | |
| 12 | +| --- | --- | --- | |
| 13 | +| `AndroidViewFieldNameCheck` | Check Android view field name (example: for `TextView` variable's name must be starts wit `tv`) | `Error` | |
| 14 | +| `ContextFirstParameterCheck` | Check Context as first parameter in a class constructor or in an arguments list | `Error` | |
| 15 | +| `MethodObjectReturnAnnotationCheck` | Check annotation for a method with return values (by default it is `@NonNull` and `@Nullable`) | `Error` | |
| 16 | +| `MethodParametersAnnotationCheck` | Check annotation for an argument in a class constructor or a method (by default it is `@NonNull` and `@Nullable`) | `Error` | |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +### Gradle |
| 21 | + |
| 22 | +If you are using [Checkstyle plugin](https://docs.gradle.org/current/userguide/checkstyle_plugin.html) for Gradle, add |
| 23 | +checks project as dependency in the `dependencies` section in the `build.gradle`: |
| 24 | + |
| 25 | +```groovy |
| 26 | +checkstyle 'com.github.fartem:checkstyle-checks-android:master' |
| 27 | +``` |
| 28 | + |
| 29 | +## How to use |
| 30 | + |
| 31 | +Add to `TreeWalker` module: |
| 32 | + |
| 33 | +```xml |
| 34 | +<module name="com.smlnskgmail.jaman.checkstyle.checks.AndroidViewFieldNameCheck"> |
| 35 | + <property name="id" value="AndroidViewFieldNameCheck"/> |
| 36 | +</module> |
| 37 | +<module name="com.smlnskgmail.jaman.checkstyle.checks.ContextFirstParameterCheck"> |
| 38 | + <property name="id" value="ContextFirstParameterCheck"/> |
| 39 | +</module> |
| 40 | +<module name="com.smlnskgmail.jaman.checkstyle.checks.MethodObjectReturnAnnotationCheck"> |
| 41 | + <property name="id" value="MethodObjectReturnAnnotationCheck"/> |
| 42 | +</module> |
| 43 | +<module name="com.smlnskgmail.jaman.checkstyle.checks.MethodParametersAnnotationCheck"> |
| 44 | + <property name="id" value="MethodParametersAnnotationCheck"/> |
| 45 | +</module> |
| 46 | +``` |
| 47 | + |
| 48 | +## How to contribute |
| 49 | + |
| 50 | +Read [Commit Convention](https://github.com/fartem/repository-rules/blob/master/commit-convention/COMMIT_CONVENTION.md). |
| 51 | +Make sure your build is green before you contribute your pull request. Then: |
| 52 | + |
| 53 | +```shell |
| 54 | +./gradlew clean |
| 55 | +./gradlew build |
| 56 | +``` |
| 57 | + |
| 58 | +If you don't see any error messages, submit your pull request. |
| 59 | + |
| 60 | +## Contributors |
| 61 | + |
| 62 | +- [@fartem](https://github.com/fartem) as Artem Fomchenkov |
| 63 | + |
0 commit comments