Commit graph

31 commits

Author SHA1 Message Date
ali
f95a06afe6
fix: pass language to format_generated_code for correct temp file extension
format_generated_code was called without the language parameter in
process_review(), defaulting to "python". This created temp files with
.py extension when formatting JS/TS code, causing prettier to fail.

Trace IDs: 11e9745d, 1578f081, 7e8abab2 (73 affected logs total)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 18:05:28 +02:00
Mohamed Ashraf
fa9d32f1c4 Merge branch 'main' into omni-java
Resolve 7 merge conflicts from main's modular refactoring + JS improvements:

- aiservice.py: combine multi-language metadata (omni-java) with main's structure
- cmd_init.py: adopt main's modular split (init_config, init_auth, github_workflow) + add Java import
- code_replacer.py: main's clean early-return style + omni-java's non-Python single-block fallback
- version.py, test_support_dispatch.py, test_javascript_test_runner.py: take main's versions
- uv.lock: regenerated

Port Java into main's modular structure:
- Fix init_java.py lazy imports to point to new modules (init_config, init_auth, github_workflow)
- Add Java workflow support to github_workflow.py (detection, template, customization)
- Fix broken Java imports (function_optimizer, line_profiler) after main's module moves

Add safety tests for merge-critical functions:
- test_add_language_metadata.py: 10 tests covering per-language payload correctness
- test_code_replacer_matching.py: 8 tests covering fallback chain

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 00:15:19 +00:00
Kevin Turcios
f43ee06859 refactor: restructure codebase for locality and faster CLI startup
Move files closer to their consumers:
- function_context.py merged into code_context_extractor.py
- FunctionOptimizer base class to languages/function_optimizer.py
- test_runner, instrument_codeflash_capture, parse_line_profile to languages/python/
- oauth_handler.py to cli_cmds/

Split cmd_init.py (1993 lines) into focused modules:
- init_config.py: config types, validation, writing, shared UI
- init_auth.py: API key management + GitHub app installation
- github_workflow.py: GitHub Actions workflow generation
- cmd_init.py: init orchestrator + Python setup (639 lines)

Defer heavy imports (cmd_init, posthog, sentry) from module-level to
usage sites, reducing CLI startup from ~600ms to ~250ms. Replace
set_defaults(func=) with direct args.command dispatch in main().
2026-03-07 08:21:27 -05:00
Kevin Turcios
eceac13fc3 Merge remote-tracking branch 'origin/main' into omni-java
# Conflicts:
#	.claude/rules/architecture.md
#	.claude/rules/code-style.md
#	.github/workflows/claude.yml
#	.github/workflows/duplicate-code-detector.yml
#	codeflash/api/aiservice.py
#	codeflash/cli_cmds/console.py
#	codeflash/cli_cmds/logging_config.py
#	codeflash/code_utils/deduplicate_code.py
#	codeflash/discovery/discover_unit_tests.py
#	codeflash/languages/base.py
#	codeflash/languages/code_replacer.py
#	codeflash/languages/javascript/mocha_runner.py
#	codeflash/languages/javascript/support.py
#	codeflash/languages/python/support.py
#	codeflash/optimization/function_optimizer.py
#	codeflash/verification/parse_test_output.py
#	codeflash/verification/verification_utils.py
#	codeflash/verification/verifier.py
#	packages/codeflash/package-lock.json
#	packages/codeflash/package.json
#	tests/languages/javascript/test_support_dispatch.py
#	tests/test_codeflash_capture.py
#	tests/test_languages/test_javascript_test_runner.py
#	tests/test_multi_file_code_replacement.py
2026-03-04 01:52:32 -05:00
Mohamed Ashraf
fc26b4b1e3 fix: update failing unit tests to match current behavior
Fixed two test failures in omni-java:

1. test_formatter_cmds_non_existent:
   - Default formatter-cmds changed from ["black $file"] to [] (commit c587c475)
   - Updated test expectation to match new default
   - Formatter detection now handled by project detector
   - Empty list prevents "Could not find formatter: black" errors for Java projects

2. test_float_values_slightly_different:
   - Python comparator now uses math.isclose(rel_tol=1e-9) for numeric comparison (commit 98a5a438)
   - Updated test to expect equivalent=True for values within epsilon tolerance
   - Added test_float_values_significantly_different to verify detection of actual differences
   - Test added before epsilon-based comparison was implemented, causing mismatch

Both tests now pass and accurately reflect current codebase behavior.

Test results: 2 fixed tests passing

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 13:33:52 +00:00
misrasaurabh1
198487bf81 format and lint all 2026-01-29 01:39:48 -08:00
Aseem Saxena
a7e3b3f2c1 None not supported for formatter commands 2025-11-11 22:02:25 -05:00
Aseem Saxena
410ef8e8fe inference test 2025-11-11 20:25:23 -05:00
Aseem Saxena
271b7ed789
Add test for isort skip file functionality 2025-10-15 20:12:10 -07:00
Kevin Turcios
be1ae9332b normalize paths and tmp_dir here too 2025-09-28 05:40:20 +00:00
Kevin Turcios
3c4573e22a Merge branch 'main' into part-1-windows-fixes 2025-09-27 21:02:06 -07:00
Sarthak Agarwal
a2825f95b5
formatting failure msg (#651)
* formatting failure msg

* fix

* make formatter optional in the optimizer only to not break other logic & fix unit tests

* small fix

* fix lint issue

---------

Co-authored-by: saga4 <saga4@codeflashs-MacBook-Air.local>
Co-authored-by: ali <mohammed18200118@gmail.com>
2025-08-17 10:37:41 +04:00
mohammed
3eee162d41
fix markdown context for formatting and more refactoring 2025-08-04 15:35:28 +03:00
mohammed
84324f8491
markdown multi context
Signed-off-by: mohammed <mohammed18200118@gmail.com>
2025-08-01 20:55:04 +03:00
Kevin Turcios
16d21e7464 reinsert 2025-07-29 23:49:22 -07:00
mohammed ahmed
10e8a1379e
Avoid formatting that causes large diffs (CF-637) (#274)
* check large diffs with black, and skipp formatting in such case (after optimizing)

* new line

* better log messages

* remove unnecessary check

* new line

* remove unused comment

* the max lines for formatting changes to 100

* refactoring

* refactoring and improvements

* added black as dev dependency

* made some refactor changes that codeflash suggested

* remove unused function

* formatting & using internal black dep

* fix black import issue

* handle formatting files with no formatting issues

* use user pre-defined formatting commands, instead of using black

* make sure format_code recieves file path as path type not as str

* formatting and linting

* typo

* revert lock file changes

* remove comment

* pass helper functions source code to the formatter for diff checking

* more unit tests

* enhancements

* Update formatter.py

add a todo comment

* Update formatter.py

Fix ruff lint

---------

Co-authored-by: Sarthak Agarwal <sarthak.saga@gmail.com>
2025-06-10 16:04:25 +05:30
Kevin Turcios
d28031f174 ruff check . 2025-02-28 19:21:22 -08:00
Saurabh Misra
fca210e8c2 remove project dependency on black 2024-12-18 12:53:03 -08:00
Kevin Turcios
72793a955c fix tests 2 2024-11-28 19:17:15 -05:00
Saurabh Misra
265ad6aafc Return the original code if the formatter fails. Don't delete the entire file from the PR 2024-11-11 23:23:55 -08:00
Saurabh Misra
d455cdee1a Ruff reformat and fix all the python files
Set minimum libcst version to be 1.0.1
move the stub files to dev dependencies
2024-10-25 15:45:44 -07:00
Kevin Turcios
fae10f6c9c round three 2024-10-12 19:40:07 -05:00
Kevin Turcios
5cd94cdf64 round 1 2024-10-12 17:29:15 -05:00
afik.cohen
e216ef8240 Fix bug with formatter_cmds default not being applied correctly when not present 2024-06-11 14:49:00 -07:00
Saurabh Misra
740162e4a6 Factor out the use of sort_imports away from format_code 2024-06-06 13:45:23 -07:00
Saurabh Misra
585a78829f imports sorting always defaults to isort or is disabled 2024-06-04 19:23:11 -07:00
Saurabh Misra
aaeccd21f8 Allow more complete support for running linters/formatters
We should now support ruff
2024-06-04 16:53:23 -07:00
Saurabh Misra
cf88e2b7d0 Make cli and django all RUFF and TUFF 2024-04-17 19:41:00 -07:00
ihitamandal
7973db5372 Add more test cases and modify import sorting 2024-03-28 16:59:13 -07:00
ihitamandal
fa62286fb6 Reformat import sorting code 2024-03-28 12:04:37 -07:00
ihitamandal
f28f9260a2 Add tests for sorting and deduplicating imports 2024-03-27 15:41:03 -07:00