Improve variable naming

This commit is contained in:
Henry Mercer 2023-08-01 19:21:17 +01:00
parent f93fb8df6e
commit 92c848eb82
3 changed files with 24 additions and 24 deletions

22
lib/setup-codeql.js generated
View file

@ -421,17 +421,17 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
const dest = path.join(tempDir, (0, uuid_1.v4)()); const dest = path.join(tempDir, (0, uuid_1.v4)());
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers); const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
const toolsDownloadStart = perf_hooks_1.performance.now(); const toolsDownloadStart = perf_hooks_1.performance.now();
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders); const archivedBundlePath = await toolcache.downloadTool(codeqlURL, dest, authorization, finalHeaders);
const toolsDownloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart); const toolsDownloadDurationMs = Math.round(perf_hooks_1.performance.now() - toolsDownloadStart);
logger.debug(`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`); logger.debug(`Finished downloading CodeQL bundle to ${archivedBundlePath} (${toolsDownloadDurationMs} ms).`);
logger.debug("Extracting CodeQL bundle."); logger.debug("Extracting CodeQL bundle.");
const extractionStart = perf_hooks_1.performance.now(); const extractionStart = perf_hooks_1.performance.now();
const codeqlExtracted = await toolcache.extractTar(codeqlPath); const extractedBundlePath = await toolcache.extractTar(archivedBundlePath);
const extractionMs = Math.round(perf_hooks_1.performance.now() - extractionStart); const extractionMs = Math.round(perf_hooks_1.performance.now() - extractionStart);
logger.debug(`Finished extracting CodeQL bundle to ${codeqlExtracted} (${extractionMs} ms).`); logger.debug(`Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionMs} ms).`);
logger.debug("Cleaning up CodeQL bundle archive."); logger.debug("Cleaning up CodeQL bundle archive.");
try { try {
await (0, del_1.default)(codeqlPath, { force: true }); await (0, del_1.default)(archivedBundlePath, { force: true });
logger.debug("Deleted CodeQL bundle archive."); logger.debug("Deleted CodeQL bundle archive.");
} }
catch (e) { catch (e) {
@ -443,7 +443,7 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
`URL ${codeqlURL}.`); `URL ${codeqlURL}.`);
return { return {
toolsVersion: maybeCliVersion ?? "unknown", toolsVersion: maybeCliVersion ?? "unknown",
codeqlFolder: codeqlExtracted, codeqlFolder: extractedBundlePath,
toolsDownloadDurationMs, toolsDownloadDurationMs,
}; };
} }
@ -466,12 +466,12 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
? `${maybeCliVersion}-${bundleVersion}` ? `${maybeCliVersion}-${bundleVersion}`
: convertToSemVer(bundleVersion, logger); : convertToSemVer(bundleVersion, logger);
logger.debug("Caching CodeQL bundle."); logger.debug("Caching CodeQL bundle.");
const codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion); const toolcachedBundlePath = await toolcache.cacheDir(extractedBundlePath, "CodeQL", toolcacheVersion);
// Safety check to make sure that we don't delete the bundle we're about to use. // Defensive check: we expect `cacheDir` to copy the bundle to a new location.
if (codeqlFolder !== codeqlExtracted) { if (toolcachedBundlePath !== extractedBundlePath) {
logger.debug("Cleaning up downloaded CodeQL bundle."); logger.debug("Cleaning up downloaded CodeQL bundle.");
try { try {
await (0, del_1.default)(codeqlPath, { force: true }); await (0, del_1.default)(archivedBundlePath, { force: true });
logger.debug("Deleted CodeQL bundle from temporary directory."); logger.debug("Deleted CodeQL bundle from temporary directory.");
} }
catch (e) { catch (e) {
@ -480,7 +480,7 @@ async function downloadCodeQL(codeqlURL, maybeBundleVersion, maybeCliVersion, ap
} }
return { return {
toolsVersion: maybeCliVersion ?? toolcacheVersion, toolsVersion: maybeCliVersion ?? toolcacheVersion,
codeqlFolder, codeqlFolder: toolcachedBundlePath,
toolsDownloadDurationMs, toolsDownloadDurationMs,
}; };
} }

File diff suppressed because one or more lines are too long

View file

@ -560,7 +560,7 @@ export async function downloadCodeQL(
); );
const toolsDownloadStart = performance.now(); const toolsDownloadStart = performance.now();
const codeqlPath = await toolcache.downloadTool( const archivedBundlePath = await toolcache.downloadTool(
codeqlURL, codeqlURL,
dest, dest,
authorization, authorization,
@ -571,20 +571,20 @@ export async function downloadCodeQL(
); );
logger.debug( logger.debug(
`Finished downloading CodeQL bundle to ${codeqlPath} (${toolsDownloadDurationMs} ms).`, `Finished downloading CodeQL bundle to ${archivedBundlePath} (${toolsDownloadDurationMs} ms).`,
); );
logger.debug("Extracting CodeQL bundle."); logger.debug("Extracting CodeQL bundle.");
const extractionStart = performance.now(); const extractionStart = performance.now();
const codeqlExtracted = await toolcache.extractTar(codeqlPath); const extractedBundlePath = await toolcache.extractTar(archivedBundlePath);
const extractionMs = Math.round(performance.now() - extractionStart); const extractionMs = Math.round(performance.now() - extractionStart);
logger.debug( logger.debug(
`Finished extracting CodeQL bundle to ${codeqlExtracted} (${extractionMs} ms).`, `Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionMs} ms).`,
); );
logger.debug("Cleaning up CodeQL bundle archive."); logger.debug("Cleaning up CodeQL bundle archive.");
try { try {
await del(codeqlPath, { force: true }); await del(archivedBundlePath, { force: true });
logger.debug("Deleted CodeQL bundle archive."); logger.debug("Deleted CodeQL bundle archive.");
} catch (e) { } catch (e) {
logger.warning("Failed to delete CodeQL bundle archive."); logger.warning("Failed to delete CodeQL bundle archive.");
@ -600,7 +600,7 @@ export async function downloadCodeQL(
); );
return { return {
toolsVersion: maybeCliVersion ?? "unknown", toolsVersion: maybeCliVersion ?? "unknown",
codeqlFolder: codeqlExtracted, codeqlFolder: extractedBundlePath,
toolsDownloadDurationMs, toolsDownloadDurationMs,
}; };
} }
@ -631,17 +631,17 @@ export async function downloadCodeQL(
: convertToSemVer(bundleVersion, logger); : convertToSemVer(bundleVersion, logger);
logger.debug("Caching CodeQL bundle."); logger.debug("Caching CodeQL bundle.");
const codeqlFolder = await toolcache.cacheDir( const toolcachedBundlePath = await toolcache.cacheDir(
codeqlExtracted, extractedBundlePath,
"CodeQL", "CodeQL",
toolcacheVersion, toolcacheVersion,
); );
// Safety check to make sure that we don't delete the bundle we're about to use. // Defensive check: we expect `cacheDir` to copy the bundle to a new location.
if (codeqlFolder !== codeqlExtracted) { if (toolcachedBundlePath !== extractedBundlePath) {
logger.debug("Cleaning up downloaded CodeQL bundle."); logger.debug("Cleaning up downloaded CodeQL bundle.");
try { try {
await del(codeqlPath, { force: true }); await del(archivedBundlePath, { force: true });
logger.debug("Deleted CodeQL bundle from temporary directory."); logger.debug("Deleted CodeQL bundle from temporary directory.");
} catch (e) { } catch (e) {
logger.warning( logger.warning(
@ -652,7 +652,7 @@ export async function downloadCodeQL(
return { return {
toolsVersion: maybeCliVersion ?? toolcacheVersion, toolsVersion: maybeCliVersion ?? toolcacheVersion,
codeqlFolder, codeqlFolder: toolcachedBundlePath,
toolsDownloadDurationMs, toolsDownloadDurationMs,
}; };
} }