Ignore the tools directory as well and remove the warning.

This commit is contained in:
Chris Gavin 2020-10-01 09:29:13 +01:00
parent dbecf76db8
commit 62f25fda9b
No known key found for this signature in database
GPG key ID: 07F950B80C27E4DA
9 changed files with 26 additions and 24 deletions

9
lib/analysis-paths.js generated
View file

@ -32,7 +32,7 @@ function printPathFiltersWarning(config, logger) {
}
}
exports.printPathFiltersWarning = printPathFiltersWarning;
function includeAndExcludeAnalysisPaths(config, logger) {
function includeAndExcludeAnalysisPaths(config) {
// The 'LGTM_INDEX_INCLUDE' and 'LGTM_INDEX_EXCLUDE' environment variables
// control which files/directories are traversed when scanning.
// This allows including files that otherwise would not be scanned, or
@ -43,13 +43,16 @@ function includeAndExcludeAnalysisPaths(config, logger) {
if (config.paths.length !== 0) {
process.env["LGTM_INDEX_INCLUDE"] = buildIncludeExcludeEnvVar(config.paths);
}
// If the temporary directory is in the working directory ignore that too.
// If the temporary or tools directory is in the working directory ignore that too.
const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir);
const toolsRelativeToWorking = path.relative(process.cwd(), config.toolCacheDir);
let pathsIgnore = config.pathsIgnore;
if (!tempRelativeToWorking.startsWith("..")) {
logger.warning("Storing the CodeQL Runner in the directory being analyzed is not recommended.");
pathsIgnore = pathsIgnore.concat(tempRelativeToWorking);
}
if (!toolsRelativeToWorking.startsWith("..")) {
pathsIgnore = pathsIgnore.concat(toolsRelativeToWorking);
}
if (pathsIgnore.length !== 0) {
process.env["LGTM_INDEX_EXCLUDE"] = buildIncludeExcludeEnvVar(pathsIgnore);
}