Skip to content

Commit 56417be

Browse files
filter ** paths
1 parent abf6f23 commit 56417be

File tree

6 files changed

+25
-14
lines changed

6 files changed

+25
-14
lines changed

lib/analysis-paths.js

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

lib/analysis-paths.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/analysis-paths.test.js

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

lib/analysis-paths.test.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/analysis-paths.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ test("emptyPaths", async t => {
1616

1717
test("nonEmptyPaths", async t => {
1818
let config = new configUtils.Config();
19-
config.paths.push('path1', 'path2');
20-
config.pathsIgnore.push('path3', 'path4');
19+
config.paths.push('path1', 'path2', '**/path3');
20+
config.pathsIgnore.push('path4', 'path5', 'path6/**');
2121
analysisPaths.includeAndExcludeAnalysisPaths(config, []);
2222
t.is(process.env['LGTM_INDEX_INCLUDE'], 'path1\npath2');
23-
t.is(process.env['LGTM_INDEX_EXCLUDE'], 'path3\npath4');
24-
t.is(process.env['LGTM_INDEX_FILTERS'], 'include:path1\ninclude:path2\nexclude:path3\nexclude:path4');
23+
t.is(process.env['LGTM_INDEX_EXCLUDE'], 'path4\npath5');
24+
t.is(process.env['LGTM_INDEX_FILTERS'], 'include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**');
2525
});

src/analysis-paths.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@ function isInterpretedLanguage(language): boolean {
66
return language === 'javascript' || language === 'python';
77
}
88

9+
// Builds an environment variable suitable for LGTM_INDEX_INCLUDE or LGTM_INDEX_EXCLUDE
10+
function buildIncludeExcludeEnvVar(paths: string[]): string {
11+
return paths.filter(p => p.indexOf('**') === -1).join('\n');
12+
}
13+
914
export function includeAndExcludeAnalysisPaths(config: configUtils.Config, languages: string[]) {
1015
// The 'LGTM_INDEX_INCLUDE' and 'LGTM_INDEX_EXCLUDE' environment variables
1116
// control which files/directories are traversed when scanning.
1217
// This allows including files that otherwise would not be scanned, or
1318
// excluding and not traversing entire file subtrees.
1419
// It does not understand double-globs because that would require it to
1520
// traverse the entire file tree to determine which files are matched.
21+
// Any paths containing "**" are not included in these.
1622
if (config.paths.length !== 0) {
17-
core.exportVariable('LGTM_INDEX_INCLUDE', config.paths.join('\n'));
23+
core.exportVariable('LGTM_INDEX_INCLUDE', buildIncludeExcludeEnvVar(config.paths));
1824
}
1925
if (config.pathsIgnore.length !== 0) {
20-
core.exportVariable('LGTM_INDEX_EXCLUDE', config.pathsIgnore.join('\n'));
26+
core.exportVariable('LGTM_INDEX_EXCLUDE', buildIncludeExcludeEnvVar(config.pathsIgnore));
2127
}
2228

2329
// The 'LGTM_INDEX_FILTERS' environment variable controls which files are

0 commit comments

Comments
 (0)