Skip to content

Add file fixes generation for code coverage uploads#2125

Merged
CarlosNietoP merged 6 commits intomasterfrom
carlos.nietopetinal/file-fixes-cli
Feb 25, 2026
Merged

Add file fixes generation for code coverage uploads#2125
CarlosNietoP merged 6 commits intomasterfrom
carlos.nietopetinal/file-fixes-cli

Conversation

@CarlosNietoP
Copy link
Contributor

@CarlosNietoP CarlosNietoP commented Feb 24, 2026

Identifies non-executable lines (comments, blank lines, brackets, etc.) in tracked source files and uploads them alongside coverage reports so the backend can exclude them from coverage calculations.

What and why?

Code coverage reports sometimes flag non-executable lines (comments, blank lines, closing brackets, etc.) as "uncovered", creating false negatives. This PR adds file fixes — a bitmap per source file marking which lines are non-executable — so the backend can exclude them from coverage calculations.

How?

During datadog-ci coverage upload, the CLI:

  1. Lists all git-tracked files (git ls-files) and filters to supported languages (Go, Kotlin, C/C++, Swift, ObjC, PHP)
  2. For each file, scans lines against language-specific regex patterns (empty lines, comments, block comments, brackets, etc.)
  3. Encodes matches as a 1-bit-per-line bitmap (base64-encoded) per file
  4. Uploads the result as a gzipped JSON payload (file_fixes.json.gz) alongside the coverage report

File discovery uses two strategies:

  • Default (git ls-files): fast, respects .gitignore, only tracked files. Used when running inside a git repo without --file-fixes-search-path.
  • Filesystem walk fallback: recursive directory traversal, skipping common non-source folders (node_modules, .git, .venv, etc.). Used when git is not available or --file-fixes-search-path is provided. This is useful in monorepos to scope the scan to a specific subdirectory.

Files are processed concurrently (8 async workers).

New CLI flags:

  • --disable-file-fixes — skip file fixes generation entirely
  • --file-fixes-search-path — override the root directory used to scan source files (defaults to repo root). Triggers the filesystem walk instead of git ls-files.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)

@CarlosNietoP CarlosNietoP requested a review from a team as a code owner February 24, 2026 09:48
@datadog-datadog-prod-us1-2
Copy link

datadog-datadog-prod-us1-2 bot commented Feb 24, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c2beb00 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@CarlosNietoP CarlosNietoP marked this pull request as draft February 24, 2026 09:51
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a54abc659d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Drarig29 Drarig29 added the software-delivery Related to [coverage, deployment, dora, junit, measure, tag, trace] label Feb 24, 2026
@CarlosNietoP CarlosNietoP force-pushed the carlos.nietopetinal/file-fixes-cli branch 2 times, most recently from e7747c4 to 4be1df9 Compare February 24, 2026 13:59
File fixes identifies non-executable lines (comments, blank lines, brackets,
etc.) so the backend can exclude them from coverage calculations, reducing
false negatives. This brings parity with Codecov's file fixes feature.

Supported languages: Go, Kotlin, C/C++/Swift/ObjC, PHP.

Key implementation details:
- Uses git ls-files by default for fast tracked-file enumeration
- Falls back to filesystem walk when --file-fixes-search-path is provided
- Processes files concurrently with bounded parallelism (8 workers)
- Encodes results as compact bitmaps (one bit per line)
- Adds --disable-file-fixes and --file-fixes-search-path CLI flags
- Includes debug-level timing log (visible with --verbose)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CarlosNietoP CarlosNietoP force-pushed the carlos.nietopetinal/file-fixes-cli branch from 4be1df9 to 35c45af Compare February 24, 2026 14:06
@CarlosNietoP CarlosNietoP marked this pull request as ready for review February 24, 2026 14:14
@CarlosNietoP
Copy link
Contributor Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35c45af977

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@Drarig29 Drarig29 left a comment

Choose a reason for hiding this comment

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

LGTM, you'll need to fix the formatting to pass CI

@CarlosNietoP CarlosNietoP merged commit 2ed0e82 into master Feb 25, 2026
26 checks passed
@CarlosNietoP CarlosNietoP deleted the carlos.nietopetinal/file-fixes-cli branch February 25, 2026 14:26
@vishal-joshi-datadog vishal-joshi-datadog mentioned this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

software-delivery Related to [coverage, deployment, dora, junit, measure, tag, trace]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants