From f033790420607df2ecc66560388f4c452adf024f Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 1 Apr 2023 11:22:32 +0000 Subject: [PATCH 1/2] refactor: Replace template strings with regular string literals Template literals are useful when you need: 1. [Interpolated strings](https://en.wikipedia.org/wiki/String_interpolation). --- src/clients/discord/discord.voice.service.ts | 6 +++--- src/clients/jellyfin/jellyfin.playstate.service.ts | 4 ++-- src/clients/jellyfin/jellyfin.search.service.ts | 2 +- src/clients/jellyfin/jellyfin.websocket.service.ts | 2 +- src/commands/play/play.comands.ts | 2 +- src/commands/playlist/playlist.interaction-collector.ts | 2 +- src/commands/volume/volume.command.ts | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/clients/discord/discord.voice.service.ts b/src/clients/discord/discord.voice.service.ts index fe86177..56bef4a 100644 --- a/src/clients/discord/discord.voice.service.ts +++ b/src/clients/discord/discord.voice.service.ts @@ -219,7 +219,7 @@ export class DiscordVoiceService { if (this.audioPlayer === undefined) { this.logger.debug( - `Initialized new instance of AudioPlayer because it has not been defined yet`, + "Initialized new instance of AudioPlayer because it has not been defined yet", ); this.audioPlayer = createAudioPlayer({ debug: process.env.DEBUG?.toLowerCase() === 'true', @@ -265,7 +265,7 @@ export class DiscordVoiceService { return; } - this.logger.debug(`Audio player finished playing old resource`); + this.logger.debug("Audio player finished playing old resource"); const playlist = this.playbackService.getPlaylistOrDefault(); const finishedTrack = playlist.getActiveTrack(); @@ -280,7 +280,7 @@ export class DiscordVoiceService { ); if (!hasNextTrack) { - this.logger.debug(`Reached the end of the playlist`); + this.logger.debug("Reached the end of the playlist"); return; } diff --git a/src/clients/jellyfin/jellyfin.playstate.service.ts b/src/clients/jellyfin/jellyfin.playstate.service.ts index 2d75cd2..465322c 100644 --- a/src/clients/jellyfin/jellyfin.playstate.service.ts +++ b/src/clients/jellyfin/jellyfin.playstate.service.ts @@ -60,7 +60,7 @@ export class JellyinPlaystateService { private async onPlaybackFinished(track: Track) { if (!track) { this.logger.error( - `Unable to report playback because finished track was undefined`, + "Unable to report playback because finished track was undefined", ); return; } @@ -78,7 +78,7 @@ export class JellyinPlaystateService { if (!track) { this.logger.error( - `Unable to report changed playstate to Jellyfin because no track was active`, + "Unable to report changed playstate to Jellyfin because no track was active", ); return; } diff --git a/src/clients/jellyfin/jellyfin.search.service.ts b/src/clients/jellyfin/jellyfin.search.service.ts index ffe755e..0a4b62f 100644 --- a/src/clients/jellyfin/jellyfin.search.service.ts +++ b/src/clients/jellyfin/jellyfin.search.service.ts @@ -37,7 +37,7 @@ export class JellyfinSearchService { if (includeItemTypes.length === 0) { this.logger.warn( - `Included item types are empty. This may lead to unwanted results`, + "Included item types are empty. This may lead to unwanted results", ); } diff --git a/src/clients/jellyfin/jellyfin.websocket.service.ts b/src/clients/jellyfin/jellyfin.websocket.service.ts index 4d22d37..49ff445 100644 --- a/src/clients/jellyfin/jellyfin.websocket.service.ts +++ b/src/clients/jellyfin/jellyfin.websocket.service.ts @@ -123,7 +123,7 @@ export class JellyfinWebSocketService implements OnModuleDestroy { this.handleSendPlaystateCommandRequest(sendPlaystateCommandRequest); break; case SessionMessageType[SessionMessageType.UserDataChanged]: - this.logger.debug(`Received update for user session data`); + this.logger.debug("Received update for user session data"); break; default: this.logger.warn( diff --git a/src/commands/play/play.comands.ts b/src/commands/play/play.comands.ts index 0e72eb4..85ab999 100644 --- a/src/commands/play/play.comands.ts +++ b/src/commands/play/play.comands.ts @@ -70,7 +70,7 @@ export class PlayItemCommand { embeds: [ this.discordMessageService.buildMessage({ title: 'No results found', - description: `- Check for any misspellings\n- Grant me access to your desired libraries\n- Avoid special characters`, + description: "- Check for any misspellings\n- Grant me access to your desired libraries\n- Avoid special characters", }), ], ephemeral: true, diff --git a/src/commands/playlist/playlist.interaction-collector.ts b/src/commands/playlist/playlist.interaction-collector.ts index 462ad16..75ba468 100644 --- a/src/commands/playlist/playlist.interaction-collector.ts +++ b/src/commands/playlist/playlist.interaction-collector.ts @@ -80,7 +80,7 @@ export class PlaylistInteractionCollector { return current - 1; default: this.logger.error( - `Unable to map button interaction from collector to target page`, + "Unable to map button interaction from collector to target page", ); return undefined; } diff --git a/src/commands/volume/volume.command.ts b/src/commands/volume/volume.command.ts index 3bbe4ab..a777d9c 100644 --- a/src/commands/volume/volume.command.ts +++ b/src/commands/volume/volume.command.ts @@ -36,7 +36,7 @@ export class VolumeCommand { await interaction.editReply({ embeds: [ this.discordMessageService.buildMessage({ - title: `Unable to change your volume`, + title: "Unable to change your volume", description: 'The bot is not playing any music or is not straming to a channel', }), From 128cf2fd3d7384faa155f5fee166ca6054daccca Mon Sep 17 00:00:00 2001 From: Manuel Date: Sat, 1 Apr 2023 13:27:02 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20deepsource=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clients/discord/discord.voice.service.ts | 9 ++++----- src/clients/jellyfin/jellyfin.websocket.service.ts | 2 -- src/commands/play/play.comands.ts | 10 +++++----- src/models/shared/Playlist.ts | 2 +- src/updates/updates.service.spec.ts | 2 +- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/clients/discord/discord.voice.service.ts b/src/clients/discord/discord.voice.service.ts index 56bef4a..870dfb4 100644 --- a/src/clients/discord/discord.voice.service.ts +++ b/src/clients/discord/discord.voice.service.ts @@ -9,7 +9,6 @@ import { joinVoiceChannel, NoSubscriberBehavior, VoiceConnection, - VoiceConnectionStatus, } from '@discordjs/voice'; import { Injectable } from '@nestjs/common'; @@ -18,11 +17,11 @@ import { EventEmitter2, OnEvent } from '@nestjs/event-emitter'; import { GuildMember } from 'discord.js'; +import { GenericTryHandler } from '../../models/generic-try-handler'; +import { Track } from '../../models/shared/Track'; +import { PlaybackService } from '../../playback/playback.service'; import { JellyfinStreamBuilderService } from '../jellyfin/jellyfin.stream.builder.service'; import { JellyfinWebSocketService } from '../jellyfin/jellyfin.websocket.service'; -import { GenericTryHandler } from '../../models/generic-try-handler'; -import { PlaybackService } from '../../playback/playback.service'; -import { Track } from '../../models/shared/Track'; import { DiscordMessageService } from './discord.message.service'; @@ -93,7 +92,7 @@ export class DiscordVoiceService { this.jellyfinWebSocketService.initializeAndConnect(); - if (this.voiceConnection == undefined) { + if (this.voiceConnection === undefined) { this.voiceConnection = getVoiceConnection(member.guild.id); } diff --git a/src/clients/jellyfin/jellyfin.websocket.service.ts b/src/clients/jellyfin/jellyfin.websocket.service.ts index 49ff445..45fe2d2 100644 --- a/src/clients/jellyfin/jellyfin.websocket.service.ts +++ b/src/clients/jellyfin/jellyfin.websocket.service.ts @@ -1,13 +1,11 @@ import { PlaystateCommand, SessionMessageType, - UserItemDataDto, } from '@jellyfin/sdk/lib/generated-client/models'; import { Injectable, Logger, OnModuleDestroy } from '@nestjs/common'; import { EventEmitter2 } from '@nestjs/event-emitter'; import { Cron } from '@nestjs/schedule'; -import { Session } from 'inspector'; import { WebSocket } from 'ws'; diff --git a/src/commands/play/play.comands.ts b/src/commands/play/play.comands.ts index 85ab999..3c5fd2e 100644 --- a/src/commands/play/play.comands.ts +++ b/src/commands/play/play.comands.ts @@ -20,14 +20,14 @@ import { InteractionReplyOptions, } from 'discord.js'; -import { PlaybackService } from '../../playback/playback.service'; -import { formatMillisecondsAsHumanReadable } from '../../utils/timeUtils'; import { DiscordMessageService } from '../../clients/discord/discord.message.service'; import { DiscordVoiceService } from '../../clients/discord/discord.voice.service'; import { JellyfinSearchService } from '../../clients/jellyfin/jellyfin.search.service'; import { SearchHint } from '../../models/search/SearchHint'; +import { PlaybackService } from '../../playback/playback.service'; +import { formatMillisecondsAsHumanReadable } from '../../utils/timeUtils'; -import { SearchType, PlayCommandParams } from './play.params.ts'; +import { PlayCommandParams, SearchType } from './play.params.ts'; @Injectable() @Command({ @@ -105,8 +105,8 @@ export class PlayItemCommand { this.playbackService.getPlaylistOrDefault().enqueueTracks(tracks); const remoteImage: RemoteImageInfo | undefined = tracks - .flatMap((x) => x.getRemoteImages()) - .find((x) => true); + .flatMap((track) => track.getRemoteImages()) + .find(() => true); await interaction.followUp({ embeds: [ diff --git a/src/models/shared/Playlist.ts b/src/models/shared/Playlist.ts index c16a5b5..76cfbab 100644 --- a/src/models/shared/Playlist.ts +++ b/src/models/shared/Playlist.ts @@ -1,4 +1,4 @@ -import { EventEmitter2, OnEvent } from '@nestjs/event-emitter'; +import { EventEmitter2 } from '@nestjs/event-emitter'; import { Track } from './Track'; diff --git a/src/updates/updates.service.spec.ts b/src/updates/updates.service.spec.ts index 911aa04..74f25ab 100644 --- a/src/updates/updates.service.spec.ts +++ b/src/updates/updates.service.spec.ts @@ -33,7 +33,7 @@ describe('UpdatesService', () => { } as DiscordMessageService; } - if (token === Client || token == '__inject_discord_client__') { + if (token === Client || token === '__inject_discord_client__') { return { guilds: { cache: [