Skip to content

Commit e817b26

Browse files
committed
2021-01-10 Version 1.0.0: Repository update
1. Added: - GitHub Actions integration; - Checkstyle support; - CPD support; - README.md.
1 parent b52cec0 commit e817b26

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
GRADLE_OPTS: -Dorg.gradle.daemon=false
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Set up JDK 1.8
18+
uses: actions/setup-java@v1
19+
with:
20+
java-version: 1.8
21+
- name: Build with Gradle
22+
run: ./gradlew build

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# checkstyle-checks-android
2+
3+
[![GitHubActions](https://github.com/fartem/checkstyle-checks-android/workflows/Build/badge.svg)](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+

build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
11
plugins {
22
id 'java'
3+
id 'checkstyle'
4+
id 'de.aaschmid.cpd' version '3.1'
35
}
46

57
group 'com.smlnskgmail.jaman.checkstyle'
68
version '1.0.0'
79

10+
checkstyle {
11+
toolVersion '8.38'
12+
ignoreFailures false
13+
showViolations true
14+
15+
def checkstyleConfigPath = "$rootDir/checkstyle.xml"
16+
def checkstyleConfig = new File(checkstyleConfigPath)
17+
new URL(
18+
"https://raw.githubusercontent.com/fartem/repository-rules/master/rules/java/checkstyle/checkstyle.xml"
19+
).withInputStream {
20+
i -> checkstyleConfig.withOutputStream {
21+
it << i
22+
}
23+
}
24+
25+
configFile file(checkstyleConfigPath)
26+
}
27+
28+
checkstyleMain {
29+
source = 'src/main/java'
30+
}
31+
32+
cpd {
33+
language = 'java'
34+
}
35+
836
repositories {
937
mavenCentral()
1038
}

gradle/wrapper/gradle-wrapper.jar

53.1 KB
Binary file not shown.

gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)