Commit graph

6124 commits

Author SHA1 Message Date
Mohamed Ashraf
2fc46418cb refine: reduce false positives in keyword validation
- Exclude method declarations from type pattern matching
- Focus on Java 9+ module keywords for type declarations
- Prevents false positives on valid code like 'void testMethod()'
- Still catches all actual keyword usage issues
2026-02-05 16:40:43 +00:00
Mohamed Ashraf
05761b768d fix: validate Java class names against reserved keywords in test generation
When the AI service generates Java tests, it sometimes uses Java reserved
keywords as class names or type identifiers, resulting in code that fails
to compile.

This change adds comprehensive keyword validation that checks for:
- Reserved keywords used as class names in import statements
- Reserved keywords used in class declarations
- Reserved keywords used as type names in variable declarations

The validation catches all Java reserved keywords including:
- Core keywords (class, if, while, etc.)
- Java 9+ module system keywords (provides, requires, exports, etc.)
- Reserved literals (true, false, null)

When reserved keywords are detected, the validation fails with a detailed
error message indicating which keyword was used and where, allowing the
retry mechanism to regenerate valid code.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 16:35:28 +00:00
claude[bot]
170bbd8bfc style: auto-fix formatting issues 2026-02-04 19:36:19 +00:00
HeshamHM28
d11f5a3ef9
[Chore ] Improve Java syntax validation (#2367)
Improve Java syntax validation to handle strings, comments, and proper
   nesting

   Problem:
   The old validate_java_syntax() function had several limitations:
   - Counted braces/parentheses inside string literals as actual code
   - Counted braces/parentheses inside comments as actual code
   - Did not validate bracket [] balance (arrays)
   - Did not verify proper nesting order of delimiters

   Solution:
- Add _remove_strings_and_comments() helper that strips string literals,
character literals, single-line comments (//), and multi-line comments
     (/* */) before validation
   - Add bracket [] validation alongside braces {} and parentheses ()
   - Use stack-based approach to verify proper nesting order
   - Handle escape sequences in strings and char literals
2026-02-04 11:34:53 -08:00
HeshamHM28
8e90c9e140
Add Java code optimization demo with Gradle and JUnit 4/5 (#2369)
## Summary
Added Java code optimization demonstration project to
`cli/code-to-optimize/`

- Set up Gradle build system with dual JUnit support (JUnit 4 and JUnit
5)
- Created three classes with common optimization opportunities:
- **StringProcessor**: String concatenation and manipulation
inefficiencies
- **CollectionProcessor**: Collection operations with performance issues
  - **DataCalculator**: Algorithm optimization opportunities
- Added comprehensive test suite with 20+ tests
- All tests passing with `./gradlew test`

## Code Optimization Opportunities

### StringProcessor
- String concatenation in loops (O(n²) → O(n) with StringBuilder)
- Multiple intermediate String objects
- Repeated substring operations

### CollectionProcessor
- ArrayList.contains() lookups (O(n²) → O(n) with HashSet)
- Multiple collection passes (can be single pass)
- Inefficient recursive implementations

### DataCalculator
- Fibonacci without memoization (O(2ⁿ) → O(n) with DP)
- Prime checking inefficiency (O(n) → O(√n))
- Simple power modulo (can use fast exponentiation)

## Project Structure
```
cli/code-to-optimize/
├── build.gradle (JUnit 4 & 5 configured)
├── settings.gradle
├── README.md
├── gradlew (executable)
├── gradle/wrapper/
└── src/
    ├── main/java/com/example/optimization/
    │   ├── StringProcessor.java
    │   ├── CollectionProcessor.java
    │   └── DataCalculator.java
    └── test/java/com/example/optimization/
        ├── StringProcessorTest.java (JUnit 5)
        ├── CollectionProcessorTest.java (JUnit 4)
        └── DataCalculatorTest.java (JUnit 5)
```

## Test Coverage
- JUnit 5 tests for StringProcessor and DataCalculator (with
parameterized tests)
- JUnit 4 tests for CollectionProcessor
- Both frameworks working together via JUnit Vintage Engine
- 20+ test cases covering all optimization scenarios

## Running Tests
```bash
cd cli/code-to-optimize
./gradlew test      # Run all tests
./gradlew build     # Build the project
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Ubuntu <ubuntu@ip-172-31-39-200.ec2.internal>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 11:03:54 -08:00
Saurabh Misra
7cdfe8d8e2
Update django/aiservice/languages/java/testgen.py
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-02-01 15:44:46 -08:00
Saurabh Misra
ae63b4fb3f
Merge pull request #2344 from codeflash-ai/fix-java-testgen-syntax
fix: add Java syntax rules and abstract class handling guidelines
2026-02-01 12:32:57 -08:00
Saurabh Misra
b691c8fdda
Update django/aiservice/languages/java/testgen.py
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-02-01 12:32:40 -08:00
HeshamHM28
3e769dd192
Merge branch 'omni-java' into fix-java-testgen-syntax 2026-02-01 05:43:28 -08:00
Saurabh Misra
0d929073cd fix: add Java syntax rules and abstract class handling guidelines
- Add CRITICAL Java syntax rules warning that import aliasing is invalid
  (Java doesn't support "import X as Y" syntax like Python)
- Add guidelines for handling abstract classes/interfaces - use factory
  methods instead of creating incomplete mock classes
- Add validation to detect invalid import aliasing syntax in generated tests

These changes prevent compilation errors in generated Java tests caused by
invalid syntax patterns that work in Python but not in Java.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 00:32:57 +00:00
Saurabh Misra
ea84d3a944
Merge pull request #2342 from codeflash-ai/java-junit4-support
feat: add JUnit 4 test generation support for Java
2026-01-31 02:00:55 -08:00
Saurabh Misra
9a44d546a9
Update django/aiservice/languages/java/testgen.py
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-01-31 02:00:46 -08:00
Saurabh Misra
e1bae76484 feat: add JUnit 4 test generation support for Java
- Add separate prompts for JUnit 4 vs JUnit 5 test generation
- Update build_java_prompt() to accept test_framework parameter
- Update testgen_java() to detect and pass the test framework
- Improve package extraction from non-standard Maven paths
- Add better logging for package/class extraction debugging

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 09:58:41 +00:00
misrasaurabh1
701c7e73e0 e2e working java 2026-01-30 10:53:37 -08:00
misrasaurabh1
8b7f793864 wip java support 2026-01-30 00:37:58 -08:00
HeshamHM28
c24f350719
Fix Prevent log code for paid org in the optimization feature "AI service " (#2325)
Fixes Cf-1038
2026-01-29 19:28:30 +00:00
Kevin Turcios
04197195e8
Store instrumented performance tests in feature logging (#2330)
## Summary
- Add `instrumented_perf_test` field to `OptimizationFeatures` model
- Update `log_features` function to accept and store performance
instrumented tests

---------

Co-authored-by: Sarthak Agarwal <sarthak.saga@gmail.com>
2026-01-29 03:09:47 -05:00
Saurabh Misra
8f7657da0d
Merge pull request #2247 from codeflash-ai/multi-language
codeflash-omni
2026-01-28 14:25:32 -08:00
ali
c19d9f4450
fix unit tests 2026-01-28 23:20:48 +02:00
ali
f0480fac39
use treesitter for validating js & ts code syntax 2026-01-28 23:15:30 +02:00
ali
db3f269b37
linting and formatting 2026-01-28 22:41:27 +02:00
ali
ec97ebd4e7
more cleanup 2026-01-28 22:23:54 +02:00
ali
31091350c9
cleanup 2026-01-28 22:19:40 +02:00
ali
dcac02b3f2
abstraction 2026-01-28 21:53:51 +02:00
ali
373d4c6574
Merge branch 'main' of github.com:codeflash-ai/codeflash-internal into multi-language 2026-01-28 20:47:57 +02:00
mashraf-222
d9a8aa8811
enhance LLM response view & adding ranker details in observability (#2326)
<img width="1755" height="1017" alt="image"
src="https://github.com/user-attachments/assets/9d398362-48b0-45b3-82a7-acf1174f1684"
/>
<img width="1901" height="1043" alt="image"
src="https://github.com/user-attachments/assets/a3ea7ef4-4b62-4f72-874e-80b28d513b8d"
/>

---------

Co-authored-by: Codeflash Bot <bot@codeflash.ai>
Co-authored-by: Kevin Turcios <106575910+KRRT7@users.noreply.github.com>
2026-01-28 13:20:00 -05:00
HeshamHM28
f909642ce1
feat: Add Line Profiler visualization to webapp (#2268)
## Summary
Adds a line-by-line performance profiler visualization to the webapp,
allowing users to compare execution times between original and optimized
code.

  ## Changes

  ### New Line Profiler View
- **`LineProfilerView.tsx`**: Side-by-side comparison component showing:
    - Line-by-line execution times with heat map visualization
    - Syntax highlighting using `prism-react-renderer`
    - Collapsible function blocks
    - Light/dark mode support
    - Heat legend (cold → hot based on % time)

- **`lineProfilerParser.ts`**: Parser utilities for line profiler data:
- `parseLineProfilerResults()` - parses markdown table output from
Python's line_profiler
- `formatTime()` - converts timer units to human-readable format (ns,
µs, ms, s)
    - `getHeatLevel()` - determines heat coloring based on % time

- **`/review-optimizations/[traceId]/profiler/page.tsx`**: New route for
the profiler view

  ### API Changes
- **`create-pr.ts`**: Adds "📊 Performance Profile" link to PR
description when profiler data exists
- **`github-app.ts`**: Removes line profiler data from metadata when PR
is closed/merged
- **`create-staging.ts`**, **`suggest-pr-changes.ts`**: Handle line
profiler data in staging
- **`staging-storage-strategy.ts`**: Interface updates for line profiler
fields

  ### Webapp Integration
- **`page.tsx`**: Added "Performance Profile" button (only visible when
profiler data exists)
- **`action.ts`**: Sends line profiler data when creating PR from webapp
  Fixes CF-1018
  


https://codeflash-ai.slack.com/files/U08MSR1UN6L/F0A9YVDJY75/screen_recording_2026-01-21_at_10.03.18___pm.mov
https://github.com/HeshamHM28/my-best-repo/pull/21

linked to https://github.com/codeflash-ai/codeflash/pull/1139

---------

Co-authored-by: Aseem Saxena <aseem.bits@gmail.com>
2026-01-28 08:36:54 -08:00
Kevin Turcios
5ab169076c
Merge branch 'main' into multi-language 2026-01-28 08:19:52 -05:00
Kevin Turcios
8a66c78220
refactor: consolidate CST utilities and simplify add_missing_imports (#2324)
## Summary
- Consolidate shared CST utilities into `aiservice/common/cst_utils.py`
- Simplify `add_missing_imports` by removing redundant abstractions
- Require CST modules instead of strings in postprocessing pipeline
2026-01-28 08:05:45 -05:00
ali
d7e7125220
Merge branch 'multi-language' of github.com:codeflash-ai/codeflash-internal into multi-language 2026-01-28 13:41:55 +02:00
ali
557fb11939
remove jest globals check (client handles it now) 2026-01-28 13:41:06 +02:00
misrasaurabh1
b0a1d6c09f Remove instrumentation of js tests from aiservice and into client 2026-01-27 16:10:35 -08:00
ali
39de6a3bce
Merge branch 'multi-language' of github.com:codeflash-ai/codeflash-internal into multi-language 2026-01-27 23:30:11 +02:00
ali
72cb589948
some instrumentation fixes 2026-01-27 23:30:03 +02:00
mohammed ahmed
0c9cc6afe4
Merge branch 'main' into multi-language 2026-01-27 19:44:57 +02:00
snyk-io[bot]
f7f3e7f0bd
[Snyk] Security upgrade diff from 8.0.2 to 8.0.3 (#2305)
![snyk-top-banner](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)

### Snyk has created this PR to fix 1 vulnerabilities in the npm
dependencies of this project.

#### Snyk changed the following file(s):

- `js/VSC-Extension/package.json`




#### Vulnerabilities that will be fixed with an upgrade:

|  | Issue | Score | 

:-------------------------:|:-------------------------|:-------------------------
![medium
severity](https://res.cloudinary.com/snyk/image/upload/w_20,h_20/v1561977819/icon/m.png
'medium severity') | Regular Expression Denial of Service (ReDoS)
<br/>[SNYK-JS-DIFF-14917201](https://snyk.io/vuln/SNYK-JS-DIFF-14917201)
| &nbsp;&nbsp;**708**&nbsp;&nbsp;




---

> [!IMPORTANT]
>
> - Check the changes in this PR to ensure they won't cause issues with
your project.
> - Max score is 1000. Note that the real score may have changed since
the PR was raised.
> - This PR was automatically created by Snyk using the credentials of a
real user.

---

**Note:** _You are seeing this because you or someone else with access
to this repository has authorized Snyk to open fix PRs._

For more information: <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI1YmZkM2I3OC1iNmQ1LTRmNTYtODBhNC1iZDg4YmMzMTA4NDAiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjViZmQzYjc4LWI2ZDUtNGY1Ni04MGE0LWJkODhiYzMxMDg0MCJ9fQ=="
width="0" height="0"/>
🧐 [View latest project
report](https://app.snyk.io/org/sarthak-aNe3RTvxtiDtBRn3AkWpLk/project/9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233?utm_source&#x3D;github-cloud-app&amp;utm_medium&#x3D;referral&amp;page&#x3D;fix-pr)
📜 [Customise PR
templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=github-cloud-app&utm_content=fix-pr-template)
🛠 [Adjust project
settings](https://app.snyk.io/org/sarthak-aNe3RTvxtiDtBRn3AkWpLk/project/9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233?utm_source&#x3D;github-cloud-app&amp;utm_medium&#x3D;referral&amp;page&#x3D;fix-pr/settings)
📚 [Read about Snyk's upgrade
logic](https://docs.snyk.io/scan-with-snyk/snyk-open-source/manage-vulnerabilities/upgrade-package-versions-to-fix-vulnerabilities?utm_source=github-cloud-app&utm_content=fix-pr-template)

---

**Learn how to fix vulnerabilities with free interactive lessons:**

🦉 [Regular Expression Denial of Service
(ReDoS)](https://learn.snyk.io/lesson/redos/?loc&#x3D;fix-pr)

[//]: #
'snyk:metadata:{"breakingChangeRiskLevel":null,"FF_showPullRequestBreakingChanges":false,"FF_showPullRequestBreakingChangesWebSearch":false,"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"diff","from":"8.0.2","to":"8.0.3"}],"env":"prod","issuesToFix":["SNYK-JS-DIFF-14917201"],"prId":"5bfd3b78-b6d5-4f56-80a4-bd88bc310840","prPublicId":"5bfd3b78-b6d5-4f56-80a4-bd88bc310840","packageManager":"npm","priorityScoreList":[708],"projectPublicId":"9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233","projectUrl":"https://app.snyk.io/org/sarthak-aNe3RTvxtiDtBRn3AkWpLk/project/9d3b7f4a-fb81-42ff-ac9e-3cf1a6bff233?utm_source=github-cloud-app&utm_medium=referral&page=fix-pr","prType":"fix","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":["updated-fix-title","priorityScore"],"type":"auto","upgrade":["SNYK-JS-DIFF-14917201"],"vulns":["SNYK-JS-DIFF-14917201"],"patch":[],"isBreakingChange":false,"remediationStrategy":"vuln"}'

Co-authored-by: snyk-io[bot] <141718529+snyk-io[bot]@users.noreply.github.com>
2026-01-27 17:37:39 +05:30
Sarthak Agarwal
ccdebe5782
fix for cf-api route issue and process exit (#2315) 2026-01-27 17:35:48 +05:30
Kevin Turcios
1b2105e6d3
Merge branch 'main' into multi-language 2026-01-27 01:25:52 -05:00
Kevin Turcios
3fabea495f fix: install uv in fix-formatting workflow
The ty-check hook requires uv to be available. Add astral-sh/setup-uv
step before running prek.
2026-01-27 01:25:19 -05:00
Kevin Turcios
bf3890fdbf fix: use interactive mode for Claude @mentions
Remove prompt parameter from claude-mention job so Claude runs in
interactive mode and naturally receives @mention context. Move prek
formatting instructions to CLAUDE.md where Claude reads them for any
request.
2026-01-27 01:24:07 -05:00
Kevin Turcios
d26871b355
Merge branch 'main' into multi-language 2026-01-27 01:18:25 -05:00
Kevin Turcios
d80321da9f one more cc debug 2026-01-27 01:17:48 -05:00
Kevin Turcios
35e5e37f7e
Merge branch 'main' into multi-language 2026-01-27 01:08:17 -05:00
Kevin Turcios
a741523b1f debug
- Add standalone fix-formatting.yml workflow for `/fix-formatting` command
- Uses prek's native --from-ref to only format changed files
- Properly handles prek exit codes and reports errors
- Enable show_full_output in claude-mention job for debugging
2026-01-27 01:07:55 -05:00
Kevin Turcios
646a480769
Merge branch 'main' into multi-language 2026-01-27 00:57:23 -05:00
Kevin Turcios
f558f882bb Create fix-formatting.yml 2026-01-27 00:55:25 -05:00
Kevin Turcios
a22672d504 fix: improve Claude Code prompt for prek formatting fixes
Update the prompt to explicitly mention "pre-k" and "prek" triggers
and provide step-by-step instructions for running the formatter,
committing, and pushing changes.
2026-01-27 00:51:59 -05:00
Kevin Turcios
e464bcaae2
Merge branch 'main' into multi-language 2026-01-27 00:44:56 -05:00
Kevin Turcios
98b6577bc8 one more fix for CC 2026-01-27 00:43:52 -05:00
Kevin Turcios
e141c7e4fd
Merge branch 'main' into multi-language 2026-01-27 00:32:09 -05:00