Skip to content

Commit 5b65522

Browse files
authored
Introduce code style and reformat existing code #403 (#579)
* Introduce code style and reformat existing code #403 * Add check-code-style.yml workflow #403 * Add graphql-codegen-check-style.xml and enable it in the workflow #403 * Fix check-code-style.yml workflow * Fix build issues * Revert back changes in gradlew script
1 parent de7335a commit 5b65522

File tree

163 files changed

+6889
-5374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+6889
-5374
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@ assignees: ''
1212
*Describe your bug in detail.*
1313

1414
## Steps to Reproduce
15+
1516
*List in detail the exact steps to reproduce the unexpected behavior.*
1617

1718
## Expected Result
19+
1820
*Explain in detail what behavior you expected to happen.*
1921

2022
## Actual Result
23+
2124
*Explain in detail what behavior actually happened.*
2225

2326
## Your Environment and Setup
2427

2528
* **graphql-java-codegen version**: *X.X.X*
2629
* **Build tool**: *E.g.: Maven/Gradle/SBT*
27-
* **Mapping Config**: *E.g.:*
30+
* **Mapping Config**: *E.g.:*
2831

2932
```xml
33+
3034
<configuration>
3135
<outputDir>${project.build.directory}/generated-sources/graphql</outputDir>
3236
<packageName>io.github.kobylynskyi.graphql.model</packageName>
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Check Code Style
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
branches:
10+
- master
11+
- develop
12+
13+
jobs:
14+
check-code-style:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Check Code Style
21+
env:
22+
WORKDIR: ./
23+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
CHECKSTYLE_CONFIG: config/checkstyle/graphql-codegen-check-style.xml
25+
REVIEWDOG_VERSION: v0.11.0
26+
run: |
27+
wget -O - -q https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.41/checkstyle-8.41-all.jar > /opt/checkstyle.jar
28+
wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b /opt ${REVIEWDOG_VERSION}
29+
java -jar /opt/checkstyle.jar "${WORKDIR}" -c "${CHECKSTYLE_CONFIG}" -f xml \
30+
| /opt/reviewdog -f=checkstyle \
31+
-reporter="${INPUT_REPORTER:-github-pr-check}" \
32+
-filter-mode="${INPUT_FILTER_MODE:-added}" \
33+
-fail-on-error="${INPUT_FAIL_ON_ERROR:-false}"

.github/workflows/github.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
jdk-version: [1.8]
18+
jdk-version: [ 1.8 ]
1919
steps:
2020
- uses: actions/checkout@v2
2121

CONTRIBUTING.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ Before sending your pull requests, make sure you followed this list:
1111
- Build the project locally.
1212
- Run Unit Tests and ensure that you have the test coverage for your code.
1313

14-
1514
## Development process
1615

1716
Please follow the steps below in order to make the changes:
1817

19-
1. Clone the repository and open it in your favourite IDE.
18+
1. Clone the repository
2019
2. Checkout **develop** branch.
21-
3. Make code changes to the core library of `graphql-java-codegen`.
22-
4. If changes are required in the plugin code, then **build** and **install** `graphql-java-codegen` first.
20+
3. Open repository in your favourite IDE.
21+
4. Enable and configure CheckStyle plugin in your IDE (for IntelliJ it is CheckStyle-IDEA).
22+
Import [graphql-codegen-check-style.xml](config/checkstyle/graphql-codegen-check-style.xml) as a .
23+
5. Make code changes to the core library of `graphql-java-codegen`.
24+
6. If changes are required in the plugin code, then **build** and **install** `graphql-java-codegen` first.
2325

2426
```shell script
2527
# This will install the library (including your recent changes) in your local maven repository.
2628
./gradlew clean build publishToMavenLocal
2729
```
28-
29-
5. Build the plugin project with updated `graphql-java-codegen` library.
30+
31+
7. Build the plugin project with updated `graphql-java-codegen` library.
3032

3133
```shell script
3234
# Build Gradle plugin
@@ -37,8 +39,8 @@ Please follow the steps below in order to make the changes:
3739
mvn clean verify
3840
```
3941

40-
6. Make changes to the plugin code
41-
7. Install the plugin (copy to your local maven repository).
42+
8. Make changes to the plugin code
43+
9. Install the plugin (copy to your local maven repository).
4244

4345
```shell script
4446
# Install Gradle plugin
@@ -49,4 +51,4 @@ Please follow the steps below in order to make the changes:
4951
mvn clean install
5052
```
5153

52-
8. Make sure that `example` projects are compiling and running.
54+
10. Make sure that `example` projects are compiling and running.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
4+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
5+
6+
<suppressions>
7+
<suppress checks=".*"
8+
files=".*[/\\]target[/\\]"/>
9+
<suppress checks=".*"
10+
files=".*[/\\]build[/\\]"/>
11+
<suppress checks=".*"
12+
files=".*[/\\]generated.*[/\\]"/>
13+
14+
<suppress checks="MissingJavadocMethod"
15+
files="[\\/]test[\\/]"/>
16+
<suppress checks="MissingJavadocType"
17+
files="[\\/]test[\\/]"/>
18+
<suppress checks="SingleLineJavadoc"
19+
files="[\\/]test[\\/]"/>
20+
<suppress checks="AvoidEscapedUnicodeCharacters"
21+
files="[\\/]test[\\/]"/>
22+
<suppress checks="VariableDeclarationUsageDistance"
23+
files="[\\/]test[\\/]"/>
24+
<suppress checks="TypeName"
25+
files="[\\/]test[\\/]"/>
26+
<suppress checks="MissingJavadocMethod"
27+
files="[\\/]example.*[\\/]"/>
28+
<suppress checks="MissingJavadocType"
29+
files="[\\/]example.*[\\/]"/>
30+
31+
<suppress checks="LineLength"
32+
files="GraphQLCodegenGradleTask\.java"
33+
lines="0-100"/>
34+
35+
<suppress checks="MethodName"
36+
files="GraphQLResponseProjection\.java"/>
37+
38+
<suppress checks="MemberName"
39+
message="Member name '\$alias'.*"/>
40+
41+
<suppress checks="CustomImportOrder"
42+
message="Wrong lexicographical order for 'java\.[^']+' import\. Should be before 'javax\.[^']+'\."/>
43+
</suppressions>

0 commit comments

Comments
 (0)