Reduce cyclomatic complexity

pull/59/head
MillenniumEarl 2020-12-15 14:09:16 +01:00
parent f0caf0f669
commit 46a0afca70
3 changed files with 8 additions and 8 deletions

View File

@ -119,17 +119,16 @@ module.exports.getGameData = async function (name, mod) {
} }
// Gets the search results of the game/mod being searched for // Gets the search results of the game/mod being searched for
let urls = []; const urls = mod ?
if(mod) urls = await searcher.searchMod(name); await searcher.searchMod(name) :
else urls = await searcher.searchGame(name); await searcher.searchGame(name);
// Process previous partial results // Process previous partial results
const results = []; const results = [];
for (const url of urls) { for (const url of urls) {
// Start looking for information // Start looking for information
const info = await scraper.getGameInfo(url); const info = await scraper.getGameInfo(url);
if(!info) continue; if (info) results.push(info);
results.push(info);
} }
return results; return results;
}; };

View File

@ -10,6 +10,10 @@ class Credentials {
this.token = null; this.token = null;
} }
/**
* @public
* Fetch and save the token used to log in to F95Zone.
*/
async fetchToken() { async fetchToken() {
this.token = await getF95Token(); this.token = await getF95Token();
} }

View File

@ -29,9 +29,6 @@ class PrefixParser {
* @returns {String[]} * @returns {String[]}
*/ */
_toUpperCaseArray(a) { _toUpperCaseArray(a) {
// If the array is empty, return
if (a.length === 0) return [];
/** /**
* Makes a string uppercase. * Makes a string uppercase.
* @param {String} s * @param {String} s