Skip to content

Add paths-ignore support to CDS extractor and update dependencies#327

Open
data-douser wants to merge 5 commits intomainfrom
dd/paths-ignore/1
Open

Add paths-ignore support to CDS extractor and update dependencies#327
data-douser wants to merge 5 commits intomainfrom
dd/paths-ignore/1

Conversation

@data-douser
Copy link
Collaborator

What This PR Contributes

Resolves #326

Summary of Changes

This pull request adds support for respecting CodeQL paths-ignore patterns throughout the CDS extractor tooling. It introduces a new paths-ignore utility module, updates the dependency graph and file discovery logic to filter out ignored files and projects, and ensures that these patterns are also applied to the JavaScript extractor via environment variables. Additionally, the environment and test setup are updated to support and verify this new behavior.

Outline of Changes

Key changes include:

Support for CodeQL paths-ignore patterns:

  • Added a new module paths-ignore.ts that locates, parses, and caches paths-ignore glob patterns from a CodeQL config file, and provides utilities to filter or match paths against these patterns.
  • Updated the CDS file and project discovery logic in parser/functions.ts and parser/graph.ts to filter out files and projects matching paths-ignore patterns, with logging to indicate when files or projects are skipped. [1] [2] [3] [4]

Integration with JavaScript extractor environment:

  • Added applyPathsIgnoreToLgtmFilters in environment.ts to append exclude: rules for each paths-ignore pattern to the LGTM_INDEX_FILTERS environment variable, so the JavaScript extractor also honors these exclusions. [1] [2]
  • Updated codeql.ts to call this new function before running extraction. [1] [2]

Dependency and test updates:

  • Updated dependencies in package.json to include js-yaml and minimatch for YAML parsing and glob matching, and added their type definitions.
  • Added comprehensive unit tests for the new filtering logic and environment variable handling in environment.test.ts. [1] [2] [3]

These changes ensure that the extractor and associated tools consistently obey user-specified ignore patterns, improving accuracy and alignment with CodeQL configuration.

Future Works

N/A

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.
Bumps to latest available minor versions for CDS extractor NodeJS
dependencies, where a full version upgrade of such (e.g. eslint)
dependencies is currently blocked due to conflicts with transitive
dependencies.
@data-douser data-douser self-assigned this Mar 11, 2026
@data-douser data-douser marked this pull request as ready for review March 11, 2026 22:54
@data-douser data-douser requested a review from Copilot March 11, 2026 22:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds CodeQL paths-ignore support to the CDS extractor so that file/project discovery and downstream JavaScript extraction consistently skip user-ignored paths, aligning extractor behavior with CodeQL configuration.

Changes:

  • Introduces a paths-ignore utility to locate and parse CodeQL config, cache patterns, and match/filter paths.
  • Applies paths-ignore filtering during CDS project/file discovery and propagates excludes to the JavaScript extractor via LGTM_INDEX_FILTERS.
  • Updates dependencies and adds/updates Jest tests to validate filtering and environment behavior.

Reviewed changes

Copilot reviewed 9 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
extractors/cds/tools/src/paths-ignore.ts New module to find CodeQL config, read/cache paths-ignore, and filter/match paths.
extractors/cds/tools/src/cds/parser/functions.ts Filters discovered .cds files using paths-ignore patterns.
extractors/cds/tools/src/cds/parser/graph.ts Skips entire CDS projects that match paths-ignore and skips projects emptied by filtering.
extractors/cds/tools/src/environment.ts Adds helper to append paths-ignore patterns as exclude: rules in LGTM_INDEX_FILTERS.
extractors/cds/tools/src/codeql.ts Calls the new environment helper before running JavaScript extraction.
extractors/cds/tools/test/src/paths-ignore.test.ts New unit tests for config discovery, parsing, caching, and glob matching/filtering behavior.
extractors/cds/tools/test/src/environment.test.ts Adds tests for applyPathsIgnoreToLgtmFilters and mocks paths-ignore.
extractors/cds/tools/test/src/codeql.test.ts Updates mocks to include the new environment helper.
extractors/cds/tools/package.json Adds js-yaml/minimatch and updates dev tooling versions.
extractors/cds/tools/package-lock.json Lockfile updates for added/updated dependencies.
Files not reviewed (1)
  • extractors/cds/tools/package-lock.json: Language not supported

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDS extractor should respect paths-ignore from CodeQL config

2 participants