Skip to content

Commit

Permalink
Fixed sonarcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
algarfer committed Apr 20, 2024
1 parent ae85f34 commit 55c8799
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 30 deletions.
2 changes: 1 addition & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require("./routes/authRoutes")(app, axios)
require("./routes/historyRoutes")(app, axios, authTokenMiddleware)

// Open API
openapiPath='./GatewayAPI.yaml'
const openapiPath='./GatewayAPI.yaml'
if (fs.existsSync(openapiPath)) {
const file = fs.readFileSync(openapiPath, 'utf8');

Expand Down
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ sonar.host.url=https://sonarcloud.io
sonar.language=js
sonar.projectName=wiq_es05b

sonar.coverage.exclusions=**/*.test.js
sonar.cpd.exclusions=**/*.test.js
sonar.coverage.exclusions=**/*.test.js,**/*.draft.js
sonar.cpd.exclusions=**/*.test.js,**/*.draft.js
sonar.sources=users/authservice,users/userservice,gatewayservice,webapp/src,userhistory,jordi
sonar.sourceEncoding=UTF-8
sonar.exclusions=node_modules/**
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/__test__/components/CustomForm.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render, fireEvent, screen } from "@testing-library/react";
import { render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import CustomForm from "../../views/components/CustomForm";
import '@testing-library/jest-dom';
Expand Down
1 change: 0 additions & 1 deletion webapp/src/__test__/components/ErrorSnackBar.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import { render, fireEvent, screen } from "@testing-library/react";
import ErrorSnackBar from "../../views/components/ErrorSnackBar";
import { Snackbar } from "@mui/material";
import '@testing-library/jest-dom';

describe("ErrorSnackBar component", () => {
Expand Down
16 changes: 1 addition & 15 deletions webapp/src/__test__/components/Nav.draft.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
/*
import React from "react";
import {render, screen, fireEvent, act} from "@testing-library/react";
import Nav from "../../views/components/Nav";
import {AuthContext} from "../../views/context/AuthContext";
import {MemoryRouter} from "react-router";
import Menu from "../../views/Menu";
import { useAuth } from "../../App.jsx";
import axios from "axios";
import { ConfigContext } from '../../views/context/ConfigContext';

jest.mock('axios');
jest.mock('../../views/context/AuthContext');

const localStorageMock = (() => {
let store = {};
return {
getItem: key => store[key],
setItem: (key, value) => { store[key] = value },
removeItem: key => { delete store[key] },
clear: () => { store = {} }
};
})();
require("../utils/localStorageMock");

Object.defineProperty(window, 'localStorage', { value: localStorageMock });
jest.mock('../../App.jsx', () => ({
useAuth: jest.fn().mockReturnValue({
getUser: jest.fn().mockReturnValue({
Expand Down Expand Up @@ -70,4 +57,3 @@ describe("Nav component", () => {
expect(logoutMenuItem).toBeInTheDocument();
});
});
*/
21 changes: 12 additions & 9 deletions webapp/src/views/Game.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,18 @@ const Game = () => {
.catch(e => setHistorialError(e.response.data.error))
}

const createSave = () => {
axios
.post("/history/create", {
token: getUser().token,
category: category,
userId: getUser().userId
})
.then(response => saveId.current = response.data.id)
.catch(err => setHistorialError(err.response.data.error))
const createSave = async () => {
try {
const response = await axios
.post("/history/create", {
token: getUser().token,
category: category,
userId: getUser().userId
})
saveId.current = response.data.id
} catch (err) {
setHistorialError(err.response.data.error)
}
}

useEffect( () => {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/views/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Container } from "@mui/material";
export default function Footer() {
return (
<Container sx={{height: "7rem"}}>
<AppBar role="navigation" color="primary" sx={{ top: "auto", bottom: 0, position: "fixed" }}>
<AppBar color="primary" sx={{ top: "auto", bottom: 0, position: "fixed" }}>
<Toolbar role="toolbar" sx={{ justifyContent: "center" }}>
<Typography>&copy; {new Date().getFullYear()} ASW - WIQ05b</Typography>
</Toolbar>
Expand Down

0 comments on commit 55c8799

Please sign in to comment.