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
This commit is contained in:
Lucas Gómez (KB)
2025-08-26 19:00:12 +02:00
parent cd1f850e40
commit b64e67fd84
2 changed files with 11 additions and 7 deletions
+8 -6
View File
@@ -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)
+3 -1
View File
@@ -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