Skip to content

Conversation

@Saga4
Copy link
Contributor

@Saga4 Saga4 commented Feb 5, 2026

No description provided.

@codeflash-ai
Copy link
Contributor

codeflash-ai bot commented Feb 5, 2026

⚡️ Codeflash found optimizations for this PR

📄 11% (0.11x) speedup for fix_import_path_for_test_location in codeflash/languages/javascript/instrument.py

⏱️ Runtime : 4.49 milliseconds 4.03 milliseconds (best of 174 runs)

A new Optimization Review has been created.

🔗 Review here

Static Badge

@codeflash-ai codeflash-ai deleted a comment from claude bot Feb 6, 2026
@claude
Copy link

claude bot commented Feb 6, 2026

PR Review Summary

Prek Checks

✅ All checks pass — ruff check and ruff format both clean.

Mypy

⚠️ 198 mypy errors found in changed files, but all are pre-existing on main (same files have the same errors on the base branch). No new type errors introduced by this PR.

Code Review

Key changes in this PR:

  1. .js.mjs config rename (vitest_runner.py): Renames codeflash.vitest.config.js to codeflash.vitest.config.mjs — correct fix since the config uses ESM import syntax, which requires .mjs when the project doesn't have "type": "module" in package.json.
  2. fix_import_path_for_test_location (instrument.py): New function to rewrite AI-generated import paths to be relative to the test file location.
  3. Vitest perf state reset (capture.js): Resets perf state in beforeEach for Vitest (no external loop runner), correctly checking CODEFLASH_PERF_CURRENT_BATCH to distinguish from Jest.
  4. Extensive debug logging across parse.py, vitest_runner.py, function_optimizer.py, test_runner.py, support.py.

Outstanding issue (from previous review):

  • instrument.py:994-995: The endswith(source_name) match in should_fix_path() is still broad — common names like utils.ts or index.ts could match unrelated imports. Consider adding path segment matching.

No new critical issues found.

Test Coverage

File Main PR Diff
instrument.py 78% 69% ⚠️ -9%
parse.py 51% 49% -2%
support.py 74% 74% 0%
vitest_runner.py 69% 67% -2%
function_optimizer.py 18% 18% 0%
test_runner.py 62% 62% 0%
verifier.py 44% 43% -1%
Overall 79.47% 79.34% -0.13%

Notes:

  • ⚠️ instrument.py dropped 9% due to the new fix_import_path_for_test_location function (~60 lines) having no test coverage. Consider adding unit tests for this function.
  • Most other changes are debug logging (logger.debug) which are not exercised in unit tests — acceptable for logging-only changes.
  • Overall coverage decrease is minimal (-0.13%).

Last updated: 2026-02-09T15:15Z

Comment on lines +993 to +995
return True
if import_path.endswith((source_name, "/" + source_name)):
return True
Copy link

Choose a reason for hiding this comment

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

Low risk, but worth noting: The endswith(source_name) match on the stem alone is quite broad. If the source file is named something common like utils.ts or index.ts, this could match unrelated imports (e.g., some/other/utils would also get rewritten to the relative path of this source file).

Consider either:

  • Adding a check that the import path shares more path segments with the source, or
  • Requiring a stricter match (e.g., matching the last 2 path segments)

@Saga4 Saga4 merged commit cd1f353 into main Feb 9, 2026
30 of 32 checks passed
@Saga4 Saga4 deleted the fix/path_resolution_for_esm branch February 9, 2026 15:34
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.

2 participants