From 9bd6604a239ce8dd1f05c4cf69ee946183d15434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmed=20Esad=20AK=C3=87AM?= Date: Wed, 16 Jul 2025 22:22:23 +0200 Subject: [PATCH 1/4] Add linting in build phase for client --- client/package.json | 2 +- client/src/contexts/userContext.tsx | 1 + client/src/setupTests.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/client/package.json b/client/package.json index 8d051cb..26b58c7 100644 --- a/client/package.json +++ b/client/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "npx vite build", + "build": "npm run lint && npx vite build", "lint": "eslint .", "preview": "vite preview", "test": "vitest", diff --git a/client/src/contexts/userContext.tsx b/client/src/contexts/userContext.tsx index c11c458..37ee839 100644 --- a/client/src/contexts/userContext.tsx +++ b/client/src/contexts/userContext.tsx @@ -19,6 +19,7 @@ export const UserContextProvider: React.FC<{ children: ReactNode }> = ({ ); }; +// eslint-disable-next-line react-refresh/only-export-components export const useUser = (): UserContextType => { const context = useContext(UserContext); if (!context) { diff --git a/client/src/setupTests.ts b/client/src/setupTests.ts index 12b6cc9..81bccd7 100644 --- a/client/src/setupTests.ts +++ b/client/src/setupTests.ts @@ -2,6 +2,7 @@ import "@testing-library/jest-dom"; import { vi } from "vitest"; // Configure React to run in development mode for tests +// eslint-disable-next-line @typescript-eslint/no-explicit-any (globalThis as any).IS_REACT_ACT_ENVIRONMENT = true; // Mock window.matchMedia From e7423ef2fe748d545d1f7d460fd29055b6249be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmed=20Esad=20AK=C3=87AM?= Date: Wed, 16 Jul 2025 22:42:07 +0200 Subject: [PATCH 2/4] Add linting for server --- .github/workflows/ci-cd.yml | 6 +++++- server/build.gradle.kts | 7 +++++++ server/config/checkstyle.xml | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 server/config/checkstyle.xml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 8d812c9..18f057c 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -63,7 +63,7 @@ jobs: pip install flake8 flake8 . || exit 1 working-directory: genai - + - name: Run Tests run: | pytest --maxfail=1 --disable-warnings -q @@ -98,6 +98,10 @@ jobs: run: chmod +x gradlew working-directory: server + - name: Lint Java code + run: ./gradlew check + working-directory: server + - name: Build API Gateway microservice run: ./gradlew :api-gw:build working-directory: server diff --git a/server/build.gradle.kts b/server/build.gradle.kts index facc223..fb43338 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -3,6 +3,7 @@ plugins { id("io.spring.dependency-management") version "1.1.4" apply false id("com.google.cloud.tools.jib") version "3.4.1" apply false id("java") + id("checkstyle") } subprojects { @@ -10,6 +11,7 @@ subprojects { apply(plugin = "org.springframework.boot") apply(plugin = "io.spring.dependency-management") apply(plugin = "com.google.cloud.tools.jib") + apply(plugin = "checkstyle") group = "com.continuousdisappointment" version = "0.0.1-SNAPSHOT" @@ -22,6 +24,11 @@ subprojects { mavenCentral() } + checkstyle { + toolVersion = "10.26.1" + configFile = rootProject.file("config/checkstyle.xml") + } + dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-actuator") diff --git a/server/config/checkstyle.xml b/server/config/checkstyle.xml new file mode 100644 index 0000000..0b23925 --- /dev/null +++ b/server/config/checkstyle.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + \ No newline at end of file From e03e76e733df3c8e45ab9d61839f6153a447fcd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmed=20Esad=20AK=C3=87AM?= Date: Wed, 16 Jul 2025 22:42:25 +0200 Subject: [PATCH 3/4] Refactor config --- server/config/checkstyle.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/config/checkstyle.xml b/server/config/checkstyle.xml index 0b23925..99323d9 100644 --- a/server/config/checkstyle.xml +++ b/server/config/checkstyle.xml @@ -4,10 +4,7 @@ "https://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - - - From 96f964ecd93d2af2c0a10033e9c44452283cb863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmed=20Esad=20AK=C3=87AM?= Date: Wed, 16 Jul 2025 22:44:41 +0200 Subject: [PATCH 4/4] Refactor logs --- .../continiousdisappointment/chat/service/GenAiService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/chat/src/main/java/com/continiousdisappointment/chat/service/GenAiService.java b/server/chat/src/main/java/com/continiousdisappointment/chat/service/GenAiService.java index e221482..6299aad 100644 --- a/server/chat/src/main/java/com/continiousdisappointment/chat/service/GenAiService.java +++ b/server/chat/src/main/java/com/continiousdisappointment/chat/service/GenAiService.java @@ -31,11 +31,12 @@ public String generateAssistantReply(String query, List messages, GenAiRequest genAiRequest = new GenAiRequest(query, messages, userId); HttpEntity entity = new HttpEntity<>(genAiRequest, headers); + log.info("Calling GenAI service"); ResponseEntity response = restTemplate.postForEntity( getGenAiServiceUrl() + "/genai/generate", entity, GenAiResponse.class); - log.info("GenAI service is called with response {} ", response.getBody().response()); + log.info("GenAI service call successful"); return response.getBody().response(); } catch (Exception e) {