From 12a73a1fc70a2bffecba0beb90c6796e7da4a9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Mac=C3=ADas?= Date: Mon, 29 Apr 2024 15:48:39 +0200 Subject: [PATCH] unnecessary logs removed and sonarcloud fix --- gatewayservice/gateway-service.test.js | 1 - users/userservice/user-service.js | 1 - webapp/src/components/Game/Answer.tsx | 1 - webapp/src/components/Game/Game.tsx | 3 ++- webapp/src/services/auth-service.ts | 2 -- wikidataservice/index.js | 2 -- wikidataservice/test/question-service.test.js | 1 - 7 files changed, 2 insertions(+), 9 deletions(-) diff --git a/gatewayservice/gateway-service.test.js b/gatewayservice/gateway-service.test.js index 71e217d..e9ddefa 100644 --- a/gatewayservice/gateway-service.test.js +++ b/gatewayservice/gateway-service.test.js @@ -263,7 +263,6 @@ describe('Gateway Service', () => { it('should retrieve the specified user', async () => { const response = await request(app).post('/getUser').send({username: "tomas"}); expect(response.status).toBe(200); - console.log(response.body); checkCorrectUserFields(response.body); }, 6000); diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index 33b489a..be0c254 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -30,7 +30,6 @@ router.get('/getUser', async (req, res) => { console.error('Error finding user:', err); } else { res.status(200).json(result); - console.log('User:', result); } }); diff --git a/webapp/src/components/Game/Answer.tsx b/webapp/src/components/Game/Answer.tsx index 0a4b8e5..06bf494 100644 --- a/webapp/src/components/Game/Answer.tsx +++ b/webapp/src/components/Game/Answer.tsx @@ -18,7 +18,6 @@ const Answer = (props: props) => { const [clickedAnswer, setClickedAnswer] = useState(''); const handleClick = () => { - console.log('clicked answer'); setClickedAnswer(props.answer); props.setAnswered(true); props.setCorrectSelected(props.correctAnswer); diff --git a/webapp/src/components/Game/Game.tsx b/webapp/src/components/Game/Game.tsx index 4b6eac2..7e45f9c 100644 --- a/webapp/src/components/Game/Game.tsx +++ b/webapp/src/components/Game/Game.tsx @@ -86,7 +86,8 @@ export default function Game(props: Props) { const saveAnswer = (answer: string) => { answerSelected.push(answer); - setAnswerSelected(answerSelected); + const newAnswerSelected = [...answerSelected]; + setAnswerSelected(newAnswerSelected); } useEffect(() => { diff --git a/webapp/src/services/auth-service.ts b/webapp/src/services/auth-service.ts index 70d60fd..0712ae4 100644 --- a/webapp/src/services/auth-service.ts +++ b/webapp/src/services/auth-service.ts @@ -24,7 +24,6 @@ export const login = async (username: string, password: string)=> { const response = await axios.post(`${API_URL}/login`, { username, password }); //const response = await axios.post("http://localhost:8002/auth/login", { username, password }); const token = response.data.token; - console.log('token:', token); localStorage.setItem('token', token); // store the token in local storage loginWithToken(); return true; @@ -37,7 +36,6 @@ export const login = async (username: string, password: string)=> { export const register = async (email:string, username: string, password: string) => { try { const response = await axios.post(`${API_URL}/adduser`, { username, password, email }); - console.log('response:', response); const name = response.data; return {error:false,message:name}; } catch (error: any) { diff --git a/wikidataservice/index.js b/wikidataservice/index.js index ca588cc..759271c 100644 --- a/wikidataservice/index.js +++ b/wikidataservice/index.js @@ -76,7 +76,6 @@ init().then(([jsonCountryQuestions, jsonElementsQuestions, jsonMovieQuestions, questions.push(generateQuestions(jsonChemistryQuestion[i].questionText, jsonChemistryQuestion[i].jsonResult.results.bindings, 1)[0]); } - console.log(questions) // Shuffle the questions let shuffled = questions .map(value => ({ value, sort: Math.random() })) @@ -95,7 +94,6 @@ init().then(([jsonCountryQuestions, jsonElementsQuestions, jsonMovieQuestions, const randomIndex = Math.floor(Math.random() * jsonHistoryQuestions.length); let itemData = jsonHistoryQuestions[randomIndex]; const questions = generateQuestions(itemData.questionText, itemData.jsonResult.results.bindings, 1); - console.log(questions) res.status(200).json(questions); } catch (error) { next(error); diff --git a/wikidataservice/test/question-service.test.js b/wikidataservice/test/question-service.test.js index 1be2a79..f4e6ce2 100644 --- a/wikidataservice/test/question-service.test.js +++ b/wikidataservice/test/question-service.test.js @@ -36,7 +36,6 @@ describe('Wikidata Service - Question Retrieval', () => { } expect(response.status).toBe(200); - console.log(response._body); expect(response._body.length).toBe(retrieved); expect(response._body[0]).toHaveProperty("text"); expect(response._body[0]).toHaveProperty("correctAnswer");