Add API call for languages if java in input

If a user explicitly includes java in their language inputs, always
make an api call to check for kotlin in the repo.

Also, add some suggestions from code reviews.
This commit is contained in:
Andrew Eisenberg 2022-11-24 11:06:29 -08:00
parent ad7ca9bf21
commit eb19ecbad1
12 changed files with 112 additions and 92 deletions

17
lib/util.js generated
View file

@ -728,17 +728,26 @@ async function shouldBypassToolcache(featuresEnablement, codeqlUrl, languagesInp
if (await featuresEnablement.getValue(feature_flags_1.Feature.BypassToolcacheEnabled)) {
return true;
}
let bypass = false;
// Check if the toolcache is disabled for kotlin and swift.
if (await featuresEnablement.getValue(feature_flags_1.Feature.BypassToolcacheKotlinSwiftEnabled)) {
// Now check to see if kotlin or swift is one of the languages being analyzed.
const { rawLanguages } = await (0, config_utils_1.getRawLanguages)(languagesInput, repository, logger);
const bypass = rawLanguages.some((lang) => languages_1.KOTLIN_SWIFT_BYPASS.includes(lang));
const { rawLanguages, autodetected } = await (0, config_utils_1.getRawLanguages)(languagesInput, repository, logger);
bypass = rawLanguages.some((lang) => languages_1.KOTLIN_SWIFT_BYPASS.includes(lang));
if (bypass) {
logger.info(`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`);
}
return bypass;
else if (!autodetected && rawLanguages.includes(languages_1.Language.java)) {
// special case: java was explicitly specified, but there might be
// some kotlin in the repository, so we need to make a request for that.
const langsInRepo = await (0, config_utils_1.getLanguagesInRepo)(repository, logger);
if (langsInRepo.includes("kotlin")) {
logger.info(`Bypassing toolcache for kotlin.`);
bypass = true;
}
}
}
return false;
return bypass;
}
exports.shouldBypassToolcache = shouldBypassToolcache;
//# sourceMappingURL=util.js.map