Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ignore the tools directory as well and remove the warning.
Chris Gavin committed Oct 1, 2020

Unverified

No user is associated with the committer email.
1 parent dbecf76 commit 62f25fd
Showing 9 changed files with 26 additions and 24 deletions.
9 changes: 6 additions & 3 deletions lib/analysis-paths.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analysis-paths.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions lib/analysis-paths.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analysis-paths.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js.map
7 changes: 3 additions & 4 deletions src/analysis-paths.test.ts
@@ -2,7 +2,6 @@ import test from "ava";
import * as path from "path";

import * as analysisPaths from "./analysis-paths";
import { getRunnerLogger } from "./logging";
import { setupTests } from "./testing-utils";
import * as util from "./util";

@@ -20,7 +19,7 @@ test("emptyPaths", async (t) => {
toolCacheDir: tmpDir,
codeQLCmd: "",
};
analysisPaths.includeAndExcludeAnalysisPaths(config, getRunnerLogger(true));
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
t.is(process.env["LGTM_INDEX_EXCLUDE"], undefined);
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
@@ -39,7 +38,7 @@ test("nonEmptyPaths", async (t) => {
toolCacheDir: tmpDir,
codeQLCmd: "",
};
analysisPaths.includeAndExcludeAnalysisPaths(config, getRunnerLogger(true));
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
t.is(process.env["LGTM_INDEX_EXCLUDE"], "path4\npath5");
t.is(
@@ -62,7 +61,7 @@ test("exclude temp dir", async (t) => {
toolCacheDir,
codeQLCmd: "",
};
analysisPaths.includeAndExcludeAnalysisPaths(config, getRunnerLogger(true));
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
t.is(process.env["LGTM_INDEX_EXCLUDE"], "codeql-runner-temp");
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
17 changes: 9 additions & 8 deletions src/analysis-paths.ts
@@ -38,10 +38,7 @@ export function printPathFiltersWarning(
}
}

export function includeAndExcludeAnalysisPaths(
config: configUtils.Config,
logger: Logger
) {
export function includeAndExcludeAnalysisPaths(config: configUtils.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
@@ -52,15 +49,19 @@ export function includeAndExcludeAnalysisPaths(
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);
}
2 changes: 1 addition & 1 deletion src/analyze.ts
@@ -50,7 +50,7 @@ async function createdDBForScannedLanguages(
) {
// Insert the LGTM_INDEX_X env vars at this point so they are set when
// we extract any scanned languages.
analysisPaths.includeAndExcludeAnalysisPaths(config, logger);
analysisPaths.includeAndExcludeAnalysisPaths(config);

const codeql = getCodeQL(config.codeQLCmd);
for (const language of config.languages) {

0 comments on commit 62f25fd

Please sign in to comment.