Skip to content

Commit 102e01d

Browse files
committed
Small refactoring of shouldBypassToolcache
1 parent eb19ecb commit 102e01d

File tree

6 files changed

+43
-40
lines changed

6 files changed

+43
-40
lines changed

lib/config-utils.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ export async function getRawLanguages(
973973
} else {
974974
autodetected = true;
975975

976-
// Obtain languages as all languages in the repo that can be analysed
976+
// Obtain all languages in the repo that can be analysed
977977
rawLanguages = (await getLanguagesInRepo(repository, logger)) as string[];
978978
}
979979
return { rawLanguages, autodetected };

src/util.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -861,30 +861,33 @@ export async function shouldBypassToolcache(
861861
return true;
862862
}
863863

864-
let bypass = false;
865864
// Check if the toolcache is disabled for kotlin and swift.
866865
if (
867-
await featuresEnablement.getValue(Feature.BypassToolcacheKotlinSwiftEnabled)
866+
!(await featuresEnablement.getValue(
867+
Feature.BypassToolcacheKotlinSwiftEnabled
868+
))
868869
) {
869-
// Now check to see if kotlin or swift is one of the languages being analyzed.
870-
const { rawLanguages, autodetected } = await getRawLanguages(
871-
languagesInput,
872-
repository,
873-
logger
870+
return false;
871+
}
872+
873+
// Now check to see if kotlin or swift is one of the languages being analyzed.
874+
const { rawLanguages, autodetected } = await getRawLanguages(
875+
languagesInput,
876+
repository,
877+
logger
878+
);
879+
let bypass = rawLanguages.some((lang) => KOTLIN_SWIFT_BYPASS.includes(lang));
880+
if (bypass) {
881+
logger.info(
882+
`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`
874883
);
875-
bypass = rawLanguages.some((lang) => KOTLIN_SWIFT_BYPASS.includes(lang));
876-
if (bypass) {
877-
logger.info(
878-
`Bypassing toolcache for kotlin or swift. Languages: ${rawLanguages}`
879-
);
880-
} else if (!autodetected && rawLanguages.includes(Language.java)) {
881-
// special case: java was explicitly specified, but there might be
882-
// some kotlin in the repository, so we need to make a request for that.
883-
const langsInRepo = await getLanguagesInRepo(repository, logger);
884-
if (langsInRepo.includes("kotlin")) {
885-
logger.info(`Bypassing toolcache for kotlin.`);
886-
bypass = true;
887-
}
884+
} else if (!autodetected && rawLanguages.includes(Language.java)) {
885+
// special case: java was explicitly specified, but there might be
886+
// some kotlin in the repository, so we need to make a request for that.
887+
const langsInRepo = await getLanguagesInRepo(repository, logger);
888+
if (langsInRepo.includes("kotlin")) {
889+
logger.info(`Bypassing toolcache for kotlin.`);
890+
bypass = true;
888891
}
889892
}
890893
return bypass;

0 commit comments

Comments
 (0)