From b64e67fd842799b2e172c1b7c746eca5f0cd114b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20G=C3=B3mez=20=28KB=29?= <79912231+Pigamer37@users.noreply.github.com> Date: Tue, 26 Aug 2025 19:00:12 +0200 Subject: [PATCH] Fix to pass Codacy Static Code Analysis Some things like parenthesis in arrow funcs are not respected like 5 lines above my additions but oh well --- addon/lib/getMeta.js | 14 ++++++++------ addon/utils/parseProps.js | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/addon/lib/getMeta.js b/addon/lib/getMeta.js index e8adb08..275e5c2 100644 --- a/addon/lib/getMeta.js +++ b/addon/lib/getMeta.js @@ -44,13 +44,15 @@ const buildLinks = (imdbRating, imdbId, title, type, genres, credits, language, ...Utils.parseCollection(collObj) //empty if no collection ]; -fetchCollectionData = async (tmdbId, language) => { +const fetchCollectionData = async (tmdbId, language) => { return await moviedb.collectionInfo({ id: tmdbId, language - }).then(res => { - if (!res.parts) return null; - res.parts = res.parts.filter(part => part.id != tmdbId); //remove self from collection + }).then((res) => { + if (!res.parts) { + return null; + } + res.parts = res.parts.filter((part) => part.id !== tmdbId); //remove self from collection return res; }); }; @@ -72,7 +74,7 @@ const buildMovieResponse = async (res, type, language, tmdbId, rpdbkey, config = return null; }), getCachedImdbRating(res.external_ids?.imdb_id, type), - (res.belongs_to_collection && res.belongs_to_collection.id) ? fetchCollectionData(res.belongs_to_collection.id, language).catch(e => { + (res.belongs_to_collection && res.belongs_to_collection.id) ? fetchCollectionData(res.belongs_to_collection.id, language).catch((e) => { console.warn(`Error fetching collection data for movie ${tmdbId} and collection ${res.belongs_to_collection.id}:`, e.message); return null; }) : null //should be the same as Promise.resolve(null) @@ -142,7 +144,7 @@ const buildTvResponse = async (res, type, language, tmdbId, rpdbkey, config = {} console.warn(`Error fetching episodes for series ${tmdbId}:`, e.message); return []; }), - (res.belongs_to_collection && res.belongs_to_collection.id) ? fetchCollectionData(res.belongs_to_collection.id, language).catch(e => { + (res.belongs_to_collection && res.belongs_to_collection.id) ? fetchCollectionData(res.belongs_to_collection.id, language).catch((e) => { console.warn(`Error fetching collection data for movie ${tmdbId} and collection ${res.belongs_to_collection.id}:`, e.message); return null; }) : null //should be the same as Promise.resolve(null) diff --git a/addon/utils/parseProps.js b/addon/utils/parseProps.js index feb09f2..4707f54 100644 --- a/addon/utils/parseProps.js +++ b/addon/utils/parseProps.js @@ -240,7 +240,9 @@ async function checkIfExists(rpdbImage) { } function parseCollection(collObj) { - if (!collObj || !collObj.parts || collObj.parts.length === 0) return []; + if (!collObj || !collObj.parts || collObj.parts.length === 0) { + return []; + } return collObj.parts.map((el) => { return { name: el.title, //the link has the name of the entry