Skip to content

Commit

Permalink
fix: sonarqube issues
Browse files Browse the repository at this point in the history
- remove unused imports
- remove void casts
- do not use index as key in lists
  • Loading branch information
cgawron committed Sep 30, 2024
1 parent d8f95ce commit 3e28fd5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
12 changes: 6 additions & 6 deletions backend/src/controller/google_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const googleCallback = (req: Request, res: Response): void => {
const code = <string>req.query.code;
const user = <string>req.query.state;
if (code) {
void oAuth2Client.getToken(code)
oAuth2Client.getToken(code)
.then(token => {
saveTokens(user, token);
res.redirect(`${process.env.CLIENT_URL}${process.env.BASE_PATH}/integration/select`);
Expand Down Expand Up @@ -149,7 +149,7 @@ export function insertEventToGoogleCal(req: Request, res: Response) {
.process(req.body.event.description as string)
*/

void UserModel.findOne({ _id: req.params.user_id })
UserModel.findOne({ _id: req.params.user_id })
.then(user => {

const event: Schema$Event = {
Expand Down Expand Up @@ -196,7 +196,7 @@ export function insertEventToGoogleCal(req: Request, res: Response) {

oAuth2Client.setCredentials(user.google_tokens);
console.log('insert: event=%j', event)
void google.calendar({ version: "v3" }).events
google.calendar({ version: "v3" }).events
.insert({
auth: oAuth2Client,
calendarId: user.push_calendar,
Expand Down Expand Up @@ -230,7 +230,7 @@ export const revokeScopes = (req: Request, res: Response): void => {
const userid = req['user_id'];
let tokens = null;
const query = UserModel.findOne({ _id: userid });
void query.exec()
query.exec()
.then((user: User) => {
tokens = user.google_tokens;
if (tokens.expiry_date <= Date.now()) {
Expand Down Expand Up @@ -316,7 +316,7 @@ export const events = (user_id: string, timeMin: string, timeMax: string): Promi
}

function deleteTokens(userid: string) {
void UserModel.findOneAndUpdate(
UserModel.findOneAndUpdate(
{ _id: userid },
{ $unset: { google_tokens: "" } }
).then(res => {
Expand All @@ -338,7 +338,7 @@ function saveTokens(user: string, token) {
google_tokens[key] = <string>token.tokens[key];
}
});
void UserModel.findOneAndUpdate({ _id: user }, { google_tokens }, { new: true })
UserModel.findOneAndUpdate({ _id: user }, { google_tokens }, { new: true })

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
.then(user => {
console.log('saveTokens: %o', user)
})
Expand Down
22 changes: 11 additions & 11 deletions client/public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@
"whole_acidic_parrot_promise": "Termin buchen",
"clear_close_racoon_pat": "{{value, dateTime}}",
"cuddly_spare_felix_stir": "Schritt {{val}}",
"sunny_great_halibut_empower": "Noch keine Events, erstelle eines",
"orange_grand_racoon_fall": "So funktioniert Bookme",
"male_patient_hedgehog_ask": "Bookme ist ein einfaches, leicht zu bedienendes Terminbuchungssystem. Es ermöglicht Ihnen, Veranstaltungen zu erstellen, Ihren Link zu teilen und Nutzer Termine bei Ihnen buchen zu lassen.",
"factual_moving_hawk_belong": "Geben Sie an, wo BookMe Ihre Termine hinzufügt und wo es prüft, ob Sie beschäftigt sind.",
"pink_polite_racoon_earn": "Schritt 2: Ereignisse erstellen",
"happy_wise_mantis_laugh": "\"Fügen Sie Ihre verfügbaren Zeiten hinzu und Sie sind\ngut zu gehen!\"",
"careful_misty_bullock_splash": "Schritt 3: Teilen Sie Ihren Link",
"extra_misty_panda_grip": "Über diesen Link können Nutzer Termine buchen.",
"game_frail_vole_treasure": "Erledigt! Glückwunsch!",
"still_helpful_koala_trust": "Sobald ein Benutzer einen Termin bucht, wird das Ereignis Ihrem Kalender hinzugefügt.",
"Name": "Name",
"Please provide your name": "Bitte geben Sie Ihren Namen an",
"Email": "E-Mail-Adresse",
Expand All @@ -65,5 +55,15 @@
"minutes": "Minuten",
"Choose date": "Datum wählen",
"Choose time": "Uhrzeit wählen",
"Provide details": "Details angeben"
"Provide details": "Details angeben",
"extra_misty_panda_grip": "Über diesen Link können Nutzer Termine buchen.",
"sunny_great_halibut_empower": "Noch keine Events, erstelle eines",
"orange_grand_racoon_fall": "So funktioniert Appoint",
"male_patient_hedgehog_ask": "Bookme ist ein einfaches, leicht zu bedienendes Terminbuchungssystem. Es ermöglicht Ihnen, Veranstaltungen zu erstellen, Ihren Link zu teilen und Nutzer Termine bei Ihnen buchen zu lassen.",
"factual_moving_hawk_belong": "Geben Sie an, wo BookMe Ihre Termine hinzufügt und wo es prüft, ob Sie beschäftigt sind.",
"pink_polite_racoon_earn": "Schritt 2: Ereignisse erstellen",
"happy_wise_mantis_laugh": "\"Fügen Sie Ihre verfügbaren Zeiten hinzu und Sie sind\ngut zu gehen!\"",
"careful_misty_bullock_splash": "Schritt 3: Teilen Sie Ihren Link",
"game_frail_vole_treasure": "Erledigt! Glückwunsch!",
"still_helpful_koala_trust": "Sobald ein Benutzer einen Termin bucht, wird das Ereignis Ihrem Kalender hinzugefügt."
}
6 changes: 3 additions & 3 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
"whole_acidic_parrot_promise": "Book appointment",
"clear_close_racoon_pat": "{{value, dateTime}}",
"cuddly_spare_felix_stir": "Step {{val}}",
"extra_misty_panda_grip": "Users can use this link to book appointments.",
"sunny_great_halibut_empower": "No events yet, create one",
"orange_grand_racoon_fall": "How Bookme works",
"male_patient_hedgehog_ask": "Bookme is a simple, easy to use, appointment booking system. It\n allows you to create events, share your link and let users book\n appointments with you.",
"orange_grand_racoon_fall": "How Appoint works",
"male_patient_hedgehog_ask": "Appoint is a simple, easy to use, appointment booking system. It allows you to create events, share your link and let users book appointments with you.",
"factual_moving_hawk_belong": "Specify where BookMe adds your appointments and where it checks whether you are busy.",
"pink_polite_racoon_earn": "Step 2: Create events",
"happy_wise_mantis_laugh": "\"Add your available times and you're\n good to go!\"",
"careful_misty_bullock_splash": "Step 3: Share your link",
"extra_misty_panda_grip": "Users can use this link to book appointments.",
"game_frail_vole_treasure": "Done! Congrats!",
"still_helpful_koala_trust": "Once a user books an appointment, the event is added to your calendar."
}
8 changes: 4 additions & 4 deletions client/src/components/EventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {

import Grid from '@mui/material/Grid2';

import { Add, Delete, VerticalAlignCenter } from "@mui/icons-material";
import { Add, Delete } from "@mui/icons-material";
import { EventFormProps } from "../pages/EditEvent";
import { Day, DayNames, Event, Slot } from "common";
import { t } from "i18next";
Expand Down Expand Up @@ -130,18 +130,18 @@ const EditSlot = (props: EditSlotProps) => {
value={slot.start}
/>
</Grid>
<Grid item xs={2} textAlign="center">
<Grid xs={2} textAlign="center">
</Grid>
<Grid item xs={4} textAlign="start">
<Grid xs={4} textAlign="start">
<Input
type="time"
placeholder="Endtime"
onChange={changeTime("end", index)}
value={slot.end}
/>
</Grid>
<Grid item xs={2}>
<Grid xs={2}>
<Button onClick={deleteSlot(index)}>
<Delete />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/EventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const EventList = (props: EventListProps) => {
) : (
events.map((event, index) => (
<EventCard
key={index}
key={event._id}
event={event}
url={props.url}
setActive={(active) => {
Expand Down
3 changes: 0 additions & 3 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import { deDE } from '@mui/x-date-pickers/locales';
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFnsV3";
import { de } from 'date-fns/locale/de';
import 'dayjs/locale/de';

import { I18nextProvider } from 'react-i18next';
import i18n from './i18n';
import { GoogleOAuthProvider } from '@react-oauth/google';


Expand Down

0 comments on commit 3e28fd5

Please sign in to comment.