From 5df853c0d5abcd6bb50a0725e184dc4bdb5f9862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domantelio=E2=9C=A8?= Date: Sun, 31 Dec 2023 03:37:41 +0200 Subject: [PATCH 1/3] add sonarlist --- .github/workflows/tests.yaml | 1 + .gitignore | 5 ++++- README.md | 6 +++--- build.gradle | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a057267..c891cc3 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -17,3 +17,4 @@ jobs: - uses: matt-ball/newman-action@master with: collection: postman_collection.json + - run: gradle sonarlintMain diff --git a/.gitignore b/.gitignore index a0b4819..180fc62 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ gradlew .idea/ -.DS_Store \ No newline at end of file +.DS_Store + +# Secrets # +.env diff --git a/README.md b/README.md index dda7e26..ffc9f9f 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ __Build tool__: Gradle (run with `gradle bootRun`) -__IDE__: IntelliJ IDEA CE (it's free btw) +__IDE__: IntelliJ IDEA CE (it's free btw), with these plugins: +- Sonarlint __Java version__: OpenJDK 17 __Others useful tools__: - - Online OpenApi viewer - -## Building & Running +- Sonarlint - can be used via an IntelliJ plugin, gradle with `gradle solarlintMain` and is used in CI ## Testing diff --git a/build.gradle b/build.gradle index ef075b0..172bfa1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'org.springframework.boot' version '3.2.0' id 'io.spring.dependency-management' version '1.1.4' id "com.google.protobuf" version "0.9.4" - id 'com.bmuschko.docker-spring-boot-application' version '6.7.0' + id "name.remal.sonarlint" version "3.4.1" } group = 'com.spaghettininjas' From 396d3675c94eaee9f1b4fc20a9994c00ec700a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domantelio=E2=9C=A8?= Date: Sun, 31 Dec 2023 03:52:58 +0200 Subject: [PATCH 2/3] fix sonarlint code smells --- .github/workflows/tests.yaml | 8 +++++--- .../yaposs/controllers/CustomersController.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c891cc3..0120a75 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -2,7 +2,7 @@ name: tests run-name: Tests on: [pull_request] jobs: - postman-tests: + tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -14,7 +14,9 @@ jobs: - uses: gradle/gradle-build-action@v2 - run: gradle bootJar - run: java -jar build/libs/yaposs-0.0.1-SNAPSHOT.jar 2>&1 & - - uses: matt-ball/newman-action@master + - name: Postman tests + uses: matt-ball/newman-action@master with: collection: postman_collection.json - - run: gradle sonarlintMain + - name: Sonarlint + run: gradle sonarlintMain diff --git a/src/main/java/com/spaghettininjas/yaposs/controllers/CustomersController.java b/src/main/java/com/spaghettininjas/yaposs/controllers/CustomersController.java index 8cfa75a..f3bfa01 100644 --- a/src/main/java/com/spaghettininjas/yaposs/controllers/CustomersController.java +++ b/src/main/java/com/spaghettininjas/yaposs/controllers/CustomersController.java @@ -10,7 +10,7 @@ @RequestMapping("/api/Customers") public class CustomersController { - @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/{id}", produces=MediaType.APPLICATION_JSON_VALUE) Customer get(@PathVariable int id) { return Customer.newBuilder() .setId(id) From bd9587baf466a4ed11c58615044bc106b21334d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domantelio=E2=9C=A8?= Date: Mon, 1 Jan 2024 21:39:19 +0200 Subject: [PATCH 3/3] sonarlint wont run postman now --- build.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 172bfa1..3702bf2 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,9 @@ protobuf { tasks.register('postman') { dependsOn 'bootJar' - exec { - commandLine 'newman', 'run', 'postman_collection.json' + doLast { + exec { + commandLine 'newman', 'run', 'postman_collection.json' + } } } \ No newline at end of file