Fix some sonarcloud issues

This commit is contained in:
MathieuG-P
2024-07-11 20:57:30 +02:00
parent 116e4d77fa
commit 45bab6ccce
8 changed files with 17 additions and 17 deletions
@@ -77,7 +77,7 @@ export class LocalPlaylistsManagerService {
}
private async getPlaylistsFolder(version?: BSVersion) {
const rootPath = version ? await this.versions.getVersionPath(version) : await this.bsmFs.sharedContentPath();
const rootPath = version ? await this.versions.getVersionPath(version) : this.bsmFs.sharedContentPath();
const fullPath = path.join(rootPath, this.PLAYLISTS_FOLDER);
await ensureDir(fullPath);
@@ -179,7 +179,7 @@ export class LocalPlaylistsManagerService {
const tryExtractPlaylistId = (url: string) => {
const regex = /\/id\/(\d+)\/download/;
const match = url.match(regex);
const match = regex.exec(url);
return match ? Number(match[1]) : undefined;
}
@@ -199,7 +199,7 @@ export class LocalPlaylistsManagerService {
return undefined;
}).filter(Boolean);
if(songsDetails && songsDetails.length){
if(songsDetails?.length){
bpListDetails.duration = songsDetails.reduce((acc, song) => acc + song.duration, 0);
bpListDetails.nbMappers = new Set(songsDetails.map(s => s.uploader.id)).size;
bpListDetails.minNps = Math.min(...songsDetails.map(s => Math.min(...s.difficulties.map(d => d.nps || 0))));
@@ -90,7 +90,7 @@ export class LocalMapsManagerService {
if (version) {
return path.join(await this.localVersion.getVersionPath(version), LocalMapsManagerService.RELATIVE_MAPS_FOLDER);
}
const sharedMapsPath = path.join(await this.installLocation.sharedContentPath(), LocalMapsManagerService.SHARED_MAPS_FOLDER, LocalMapsManagerService.CUSTOM_LEVELS_FOLDER);
const sharedMapsPath = path.join(this.installLocation.sharedContentPath(), LocalMapsManagerService.SHARED_MAPS_FOLDER, LocalMapsManagerService.CUSTOM_LEVELS_FOLDER);
if (!(await pathExist(sharedMapsPath))) {
await ensureFolderExist(sharedMapsPath);
}