Skip to content

Commit 341d55d

Browse files
committed
CDS extractor support paths-ignore CodeQL config
Read `paths-ignore` patterns from `.github/codeql/codeql-config.{yml,yaml}` and apply them at two levels: - CDS file discovery: filter out ignored files and skip entire projects whose directory matches a pattern (avoids unnecessary compilation) - JS extraction handoff: append `exclude:` entries to LGTM_INDEX_FILTERS so compiled .cds.json output is also excluded Uses js-yaml for config parsing and minimatch for glob matching, consistent with CodeQL's documented paths-ignore semantics (**, *, directory prefixes). Results are cached per source root to avoid repeated YAML reads.
1 parent fd6beae commit 341d55d

14 files changed

Lines changed: 10027 additions & 359 deletions

extractors/cds/tools/dist/cds-extractor.bundle.js

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

extractors/cds/tools/dist/cds-extractor.bundle.js.map

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

extractors/cds/tools/dist/compile-test-cds-lib.cjs

Lines changed: 4450 additions & 46 deletions
Large diffs are not rendered by default.

extractors/cds/tools/dist/compile-test-cds-lib.cjs.map

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

extractors/cds/tools/package-lock.json

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

extractors/cds/tools/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"child_process": "^1.0.2",
2727
"fs": "^0.0.1-security",
2828
"glob": "^13.0.6",
29+
"js-yaml": "^4.1.1",
30+
"minimatch": "^10.2.4",
2931
"os": "^0.1.2",
3032
"path": "^0.12.7",
3133
"tmp": "^0.2.5"
@@ -36,6 +38,8 @@
3638
"@eslint/js": "^9.39.2",
3739
"@types/glob": "^9.0.0",
3840
"@types/jest": "^30.0.0",
41+
"@types/js-yaml": "^4.0.9",
42+
"@types/minimatch": "^5.1.2",
3943
"@types/mock-fs": "^4.13.4",
4044
"@types/node": "^25.2.3",
4145
"@types/tmp": "^0.2.6",

extractors/cds/tools/src/cds/parser/functions.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { sync } from 'glob';
66
import { CdsFilesToCompile, CdsImport, PackageJson } from './types';
77
import { modelCdsJsonFile } from '../../constants';
88
import { cdsExtractorLog } from '../../logging';
9+
import { filterIgnoredPaths, getPathsIgnorePatterns } from '../../paths-ignore';
910

1011
/**
1112
* Determines the list of CDS files to be parsed for the specified project directory.
@@ -49,7 +50,23 @@ export function determineCdsFilesForProjectDir(
4950
});
5051

5152
// Convert absolute paths to paths relative to sourceRootDir
52-
return cdsFiles.map(file => relative(sourceRootDir, file));
53+
const relativePaths = cdsFiles.map(file => relative(sourceRootDir, file));
54+
55+
// Apply paths-ignore filtering from CodeQL config
56+
const pathsIgnorePatterns = getPathsIgnorePatterns(sourceRootDir);
57+
if (pathsIgnorePatterns.length > 0) {
58+
const filtered = filterIgnoredPaths(relativePaths, pathsIgnorePatterns);
59+
const ignoredCount = relativePaths.length - filtered.length;
60+
if (ignoredCount > 0) {
61+
cdsExtractorLog(
62+
'info',
63+
`Filtered ${ignoredCount} CDS file(s) matching paths-ignore patterns in project ${relative(sourceRootDir, projectDir) || '.'}`,
64+
);
65+
}
66+
return filtered;
67+
}
68+
69+
return relativePaths;
5370
} catch (error: unknown) {
5471
cdsExtractorLog('error', `Error finding CDS files in ${projectDir}: ${String(error)}`);
5572
return [];

0 commit comments

Comments
 (0)