From 1354d87f98209aa9ee70eb4e2a6de96da211f1bf Mon Sep 17 00:00:00 2001 From: "HARVEYNASH\\hieu.nguyenchi5" Date: Tue, 6 Aug 2024 13:54:05 +0700 Subject: [PATCH 1/4] Add Maven Checkstyle plugin and Add Checkstyle to CI --- .github/workflows/backoffice-bff-ci.yaml | 5 + .github/workflows/cart-ci.yaml | 5 + .github/workflows/customer-ci.yaml | 5 + .github/workflows/inventory-ci.yaml | 5 + .github/workflows/location-ci.yaml | 5 + .github/workflows/media-ci.yaml | 5 + .github/workflows/order-ci.yaml | 5 + .github/workflows/payment-ci.yaml | 5 + .github/workflows/payment-paypal-ci.yaml | 5 + .github/workflows/product-ci.yaml | 5 + .github/workflows/promotion-ci.yaml | 5 + .github/workflows/rating-ci.yaml | 5 + .github/workflows/search-ci.yaml | 5 + .github/workflows/storefront-bff-ci.yaml | 5 + .github/workflows/tax-ci.yaml | 5 + README.md | 19 ++ checkstyle/checkstyle.xml | 364 +++++++++++++++++++++++ checkstyle/suppressions.xml | 8 + pom.xml | 32 ++ 19 files changed, 498 insertions(+) create mode 100644 checkstyle/checkstyle.xml create mode 100644 checkstyle/suppressions.xml diff --git a/.github/workflows/backoffice-bff-ci.yaml b/.github/workflows/backoffice-bff-ci.yaml index 71bd1a3bd7..a0cc6737db 100644 --- a/.github/workflows/backoffice-bff-ci.yaml +++ b/.github/workflows/backoffice-bff-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f backoffice-bff + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f backoffice-bff + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Analyze with sonar cloud if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} env: diff --git a/.github/workflows/cart-ci.yaml b/.github/workflows/cart-ci.yaml index 2720eff7b7..a8d0e5928a 100644 --- a/.github/workflows/cart-ci.yaml +++ b/.github/workflows/cart-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -pl cart -am + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -pl cart -am + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -pl cart -am - name: Unit Test Results diff --git a/.github/workflows/customer-ci.yaml b/.github/workflows/customer-ci.yaml index cd34612952..a09bb862c1 100644 --- a/.github/workflows/customer-ci.yaml +++ b/.github/workflows/customer-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f customer + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f customer + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f customer - name: Unit Test Results diff --git a/.github/workflows/inventory-ci.yaml b/.github/workflows/inventory-ci.yaml index de7002f4b5..722025005e 100644 --- a/.github/workflows/inventory-ci.yaml +++ b/.github/workflows/inventory-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f inventory + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f inventory + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Unit Test run: mvn test -f inventory - name: Run Maven Integration Test diff --git a/.github/workflows/location-ci.yaml b/.github/workflows/location-ci.yaml index 5ed5867389..6b73e295aa 100644 --- a/.github/workflows/location-ci.yaml +++ b/.github/workflows/location-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f location + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f location + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f location - name: Unit Test Results diff --git a/.github/workflows/media-ci.yaml b/.github/workflows/media-ci.yaml index 94caa5b0ad..176ba4c19a 100644 --- a/.github/workflows/media-ci.yaml +++ b/.github/workflows/media-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f media + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f media + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f media - name: Unit Test Results diff --git a/.github/workflows/order-ci.yaml b/.github/workflows/order-ci.yaml index 798cbd28c5..5664d515a2 100644 --- a/.github/workflows/order-ci.yaml +++ b/.github/workflows/order-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -pl order -am + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -pl order -am + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -pl order -am - name: Unit Test Results diff --git a/.github/workflows/payment-ci.yaml b/.github/workflows/payment-ci.yaml index cd8a5ece73..8abccc55fe 100644 --- a/.github/workflows/payment-ci.yaml +++ b/.github/workflows/payment-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -pl payment -am + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -pl payment -am + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -pl payment -am - name: Unit Test Results diff --git a/.github/workflows/payment-paypal-ci.yaml b/.github/workflows/payment-paypal-ci.yaml index 8b4ab4a32c..c8c9822541 100644 --- a/.github/workflows/payment-paypal-ci.yaml +++ b/.github/workflows/payment-paypal-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f payment-paypal + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f payment-paypal + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f payment-paypal - name: Unit Test Results diff --git a/.github/workflows/product-ci.yaml b/.github/workflows/product-ci.yaml index 4e241f4c59..6445170dfe 100644 --- a/.github/workflows/product-ci.yaml +++ b/.github/workflows/product-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -pl product -am + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -pl product -am + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -pl product -am - name: Unit Test Results diff --git a/.github/workflows/promotion-ci.yaml b/.github/workflows/promotion-ci.yaml index 71c744b2d7..37cb241c83 100644 --- a/.github/workflows/promotion-ci.yaml +++ b/.github/workflows/promotion-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f promotion + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f promotion + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f promotion - name: Unit Test Results diff --git a/.github/workflows/rating-ci.yaml b/.github/workflows/rating-ci.yaml index e9bd032140..936f3955a5 100644 --- a/.github/workflows/rating-ci.yaml +++ b/.github/workflows/rating-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f rating + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f rating + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f rating - name: Unit Test Results diff --git a/.github/workflows/search-ci.yaml b/.github/workflows/search-ci.yaml index c35a009718..6ff318af70 100644 --- a/.github/workflows/search-ci.yaml +++ b/.github/workflows/search-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f search + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f search + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f search - name: Unit Test Results diff --git a/.github/workflows/storefront-bff-ci.yaml b/.github/workflows/storefront-bff-ci.yaml index 3648e2d33b..f2ffdf3a45 100644 --- a/.github/workflows/storefront-bff-ci.yaml +++ b/.github/workflows/storefront-bff-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f storefront-bff + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f storefront-bff + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Analyze with sonar cloud if: ${{ env.FROM_ORIGINAL_REPOSITORY == 'true' }} env: diff --git a/.github/workflows/tax-ci.yaml b/.github/workflows/tax-ci.yaml index 92025b28bb..986d2df3dc 100644 --- a/.github/workflows/tax-ci.yaml +++ b/.github/workflows/tax-ci.yaml @@ -29,6 +29,11 @@ jobs: - uses: ./.github/workflows/actions - name: Run Maven Build Command run: mvn clean install -DskipTests -f tax + - name: Run Maven Checkstyle + run: mvn checkstyle:checkstyle -f tax + - uses: jwgmeligmeyling/checkstyle-github-action@master + with: + path: '**/checkstyle-result.xml' - name: Run Maven Test run: mvn test -f tax - name: Unit Test Results diff --git a/README.md b/README.md index c6a4acfa06..dc7ff163c1 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,25 @@ YAS is a pet project aim to practice building a typical microservice application 2. docker-compose.search.yml for search service 3. docker-compose.o11y.yml for observability services +## Code Style Configuration: + Checkstyle configuration that checks the Google coding conventions from Google Java Style + that can be found at https://google.github.io/styleguide/javaguide.html + + Checkstyle is very configurable. Be sure to read the documentation at + http://checkstyle.org (or in your downloaded distribution). + + To completely disable a check, just comment it out or delete it from the file. + To suppress certain violations please review suppression filters. + + +Using google_checks.xml version 9.3: +https://github.com/checkstyle/checkstyle/blob/checkstyle-9.3/src/main/resources/google_checks.xml + +For IntelliJ IDEA: +1. File -> Setting -> Editor -> Code Style -> Java +2. Import Scheme -> Checkstyle configuration +3. Apply file checkstyle/checkstyle.xml to import + ## Deploy to Kubernetes https://github.com/nashtech-garage/yas/tree/main/k8s/deploy diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml new file mode 100644 index 0000000000..9ba5aae33c --- /dev/null +++ b/checkstyle/checkstyle.xml @@ -0,0 +1,364 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml new file mode 100644 index 0000000000..09ecfcfd5b --- /dev/null +++ b/checkstyle/suppressions.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/pom.xml b/pom.xml index e22d9dd7ac..10480f8c12 100644 --- a/pom.xml +++ b/pom.xml @@ -190,6 +190,38 @@ + + org.owasp + dependency-check-maven + + + + check + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.4.0 + + + checkstyle + validate + + check + + + + + /checkstyle/checkstyle.xml + /checkstyle/suppressions.xml + true + false + false + + From b086ec3a48eba99bbfb12ad86eeedd7eebeb8ce8 Mon Sep 17 00:00:00 2001 From: Thien Nguyen Le Quynh Date: Wed, 7 Aug 2024 14:45:26 +0700 Subject: [PATCH 2/4] adjust indent and column lenght --- checkstyle/checkstyle.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml index 9ba5aae33c..8caf7c6469 100644 --- a/checkstyle/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -42,7 +42,7 @@ - + @@ -247,11 +247,11 @@ - - + + - + @@ -361,4 +361,4 @@ - \ No newline at end of file + From 631dfbdc42c644c9188eb16ef61db5e36fc18f41 Mon Sep 17 00:00:00 2001 From: Thien Nguyen Le Quynh Date: Wed, 7 Aug 2024 14:51:03 +0700 Subject: [PATCH 3/4] suppress JavadocMethod --- checkstyle/suppressions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index 09ecfcfd5b..e08958bdd9 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -4,5 +4,5 @@ "https://checkstyle.org/dtds/suppressions_1_2.dtd"> - + From bf193e83c16b7444f106520b485db24f83a8938e Mon Sep 17 00:00:00 2001 From: Thien Nguyen Le Quynh Date: Wed, 7 Aug 2024 16:47:14 +0700 Subject: [PATCH 4/4] suppress JavaDoc --- checkstyle/suppressions.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index e08958bdd9..ad89981ab1 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -5,4 +5,7 @@ + + +