Small refactoring of shouldBypassToolcache
This commit is contained in:
parent
eb19ecbad1
commit
102e01da36
6 changed files with 43 additions and 40 deletions
2
lib/config-utils.js
generated
2
lib/config-utils.js
generated
|
|
@ -479,7 +479,7 @@ async function getRawLanguages(languagesInput, repository, logger) {
|
|||
}
|
||||
else {
|
||||
autodetected = true;
|
||||
// Obtain languages as all languages in the repo that can be analysed
|
||||
// Obtain all languages in the repo that can be analysed
|
||||
rawLanguages = (await getLanguagesInRepo(repository, logger));
|
||||
}
|
||||
return { rawLanguages, autodetected };
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
32
lib/util.js
generated
32
lib/util.js
generated
|
|
@ -728,23 +728,23 @@ 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, 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}`);
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (!(await featuresEnablement.getValue(feature_flags_1.Feature.BypassToolcacheKotlinSwiftEnabled))) {
|
||||
return false;
|
||||
}
|
||||
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
||||
const { rawLanguages, autodetected } = await (0, config_utils_1.getRawLanguages)(languagesInput, repository, logger);
|
||||
let bypass = rawLanguages.some((lang) => languages_1.KOTLIN_SWIFT_BYPASS.includes(lang));
|
||||
if (bypass) {
|
||||
logger.info(`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`);
|
||||
}
|
||||
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 bypass;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -973,7 +973,7 @@ export async function getRawLanguages(
|
|||
} else {
|
||||
autodetected = true;
|
||||
|
||||
// Obtain languages as all languages in the repo that can be analysed
|
||||
// Obtain all languages in the repo that can be analysed
|
||||
rawLanguages = (await getLanguagesInRepo(repository, logger)) as string[];
|
||||
}
|
||||
return { rawLanguages, autodetected };
|
||||
|
|
|
|||
43
src/util.ts
43
src/util.ts
|
|
@ -861,30 +861,33 @@ export async function shouldBypassToolcache(
|
|||
return true;
|
||||
}
|
||||
|
||||
let bypass = false;
|
||||
// Check if the toolcache is disabled for kotlin and swift.
|
||||
if (
|
||||
await featuresEnablement.getValue(Feature.BypassToolcacheKotlinSwiftEnabled)
|
||||
!(await featuresEnablement.getValue(
|
||||
Feature.BypassToolcacheKotlinSwiftEnabled
|
||||
))
|
||||
) {
|
||||
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
||||
const { rawLanguages, autodetected } = await getRawLanguages(
|
||||
languagesInput,
|
||||
repository,
|
||||
logger
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
||||
const { rawLanguages, autodetected } = await getRawLanguages(
|
||||
languagesInput,
|
||||
repository,
|
||||
logger
|
||||
);
|
||||
let bypass = rawLanguages.some((lang) => KOTLIN_SWIFT_BYPASS.includes(lang));
|
||||
if (bypass) {
|
||||
logger.info(
|
||||
`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`
|
||||
);
|
||||
bypass = rawLanguages.some((lang) => KOTLIN_SWIFT_BYPASS.includes(lang));
|
||||
if (bypass) {
|
||||
logger.info(
|
||||
`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`
|
||||
);
|
||||
} else if (!autodetected && rawLanguages.includes(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 getLanguagesInRepo(repository, logger);
|
||||
if (langsInRepo.includes("kotlin")) {
|
||||
logger.info(`Bypassing toolcache for kotlin.`);
|
||||
bypass = true;
|
||||
}
|
||||
} else if (!autodetected && rawLanguages.includes(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 getLanguagesInRepo(repository, logger);
|
||||
if (langsInRepo.includes("kotlin")) {
|
||||
logger.info(`Bypassing toolcache for kotlin.`);
|
||||
bypass = true;
|
||||
}
|
||||
}
|
||||
return bypass;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue