UNPKG

codebridge-ai

Version:

Complete fullstack AI coding platform with AST-based code integration and local LLM support. Now with comprehensive web technology support (HTML/CSS/JS) plus JavaScript, Python, Rust, and C++.

639 lines 41.5 kB
{ "executionTime": "2025-08-02T14:35:00.084Z", "totalDuration": 90213, "totalTests": 26, "models": [ "deepseek-coder:6.7b", "starcoder2:3b" ], "languages": [ "javascript", "python", "rust", "cpp", "web" ], "modelStats": { "deepseek-coder:6.7b": { "total": 13, "success": 10, "languages": { "javascript": { "total": 3, "success": 3 }, "python": { "total": 3, "success": 3 }, "rust": { "total": 3, "success": 2 }, "cpp": { "total": 2, "success": 2 }, "web": { "total": 2, "success": 0 } }, "totalDuration": 76836, "qualityScores": [ 0.5, 1, 0.8999999999999999, 0.8333333333333334, 0.8333333333333334, 0.6666666666666667, 0.8461538461538461, 0.7692307692307692, 0.5384615384615384, 0.6153846153846154 ] }, "starcoder2:3b": { "total": 13, "success": 1, "languages": { "javascript": { "total": 3, "success": 1 }, "python": { "total": 3, "success": 0 }, "rust": { "total": 3, "success": 0 }, "cpp": { "total": 2, "success": 0 }, "web": { "total": 2, "success": 0 } }, "totalDuration": 13346, "qualityScores": [ 1 ] } }, "languageStats": { "javascript": { "total": 6, "success": 4, "models": {} }, "python": { "total": 6, "success": 3, "models": {} }, "rust": { "total": 6, "success": 2, "models": {} }, "cpp": { "total": 4, "success": 2, "models": {} }, "web": { "total": 4, "success": 0, "models": {} } }, "detailedResults": [ { "timestamp": "2025-08-02T14:33:37.884Z", "model": "deepseek-coder:6.7b", "language": "javascript", "scenario": "basic-validation", "task": "Add zero division check and type validation", "originalCode": "function divide(a, b) {\n return a / b;\n}", "rawResponse": "Here is your updated function with added checks for zero division and argument types:\n\n```javascript\nfunction divide(a, b) {\n if (typeof a !== 'number' || typeof b !== 'number') {\n throw new TypeError('Both arguments must be of type number');\n }\n \n if (b === 0) {\n throw new Error(\"Cannot divide by zero\");\n }\n\n return a / b;\n}\n```\n", "improvedCode": "function divide(a, b) {\n if (typeof a !== 'number' || typeof b !== 'number') {\n throw new TypeError('Both arguments must be of type number');\n }\n \n if (b === 0) {\n throw new Error(\"Cannot divide by zero\");\n }\n\n return a / b;\n}", "duration": 8014, "success": true, "qualityMetrics": { "hasCode": true, "hasErrorHandling": true, "score": 0.5, "rawScore": 0.5, "maxScore": 1 }, "error": null }, { "timestamp": "2025-08-02T14:33:44.182Z", "model": "deepseek-coder:6.7b", "language": "javascript", "scenario": "async-error-handling", "task": "Add comprehensive error handling and retry logic", "originalCode": "async function fetchUserData(userId) {\n const response = await fetch('/api/users/' + userId);\n const data = await response.json();\n return data;\n}", "rawResponse": "Here is your updated function with enhanced error handling, validation, and added retry logic using async/await pattern:\n\n```javascript\nasync function fetchUserData(userId) {\n if (!userId) throw new Error('User ID required');\n \n let response;\n for (let i = 0; i < 3; i++) { // Retry logic, try up to 3 times.\n try {\n response = await fetch('/api/users/' + userId);\n \n if (!response.ok) throw new Error(`HTTP error: ${response.status}`);\n \n const data = await response.json();\n return data;\n } catch (err) {\n console.error('Fetch failed, retrying...', err); // Log the error for debugging purposes.\n }\n }\n \n throw new Error('Failed to fetch user data after multiple attempts');\n}\n```\nThis function will now validate if `userId` is provided and throws an error if not. It also includes a retry mechanism that tries to fetch the data up to three times before finally throwing an error. The errors are logged for debugging purposes, but you can handle them as needed in your application.\n", "improvedCode": "async function fetchUserData(userId) {\n if (!userId) throw new Error('User ID required');\n \n let response;\n for (let i = 0; i < 3; i++) { // Retry logic, try up to 3 times.\n try {\n response = await fetch('/api/users/' + userId);\n \n if (!response.ok) throw new Error(`HTTP error: ${response.status}`);\n \n const data = await response.json();\n return data;\n } catch (err) {\n console.error('Fetch failed, retrying...', err); // Log the error for debugging purposes.\n }\n }\n \n throw new Error('Failed to fetch user data after multiple attempts');\n}", "duration": 6295, "success": true, "qualityMetrics": { "hasCode": true, "hasErrorHandling": true, "hasModernSyntax": true, "hasAsync": true, "taskCompleted": true, "score": 1, "rawScore": 1, "maxScore": 1 }, "error": null }, { "timestamp": "2025-08-02T14:33:55.136Z", "model": "deepseek-coder:6.7b", "language": "javascript", "scenario": "class-optimization", "task": "Add off method, once method, and error handling", "originalCode": "class EventEmitter {\n constructor() {\n this.events = {};\n }\n \n on(event, callback) {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n }\n \n emit(event, data) {\n if (this.events[event]) {\n this.events[event].forEach(cb => cb(data));\n }\n }\n}", "rawResponse": "Here is your modified class with added methods `off`, `once`, and some basic error handling:\n\n```javascript\nclass EventEmitter {\n constructor() {\n this.events = {};\n }\n \n on(event, callback) {\n if (typeof callback !== 'function') throw new TypeError('Callback must be a function');\n \n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n }\n \n off(event, callback) {\n if (typeof event !== 'string') throw new TypeError('Event name must be a string');\n \n if (!this.events[event]) return;\n \n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n }\n \n once(event, callback) {\n const self = this;\n function fn() {\n self.off(event, fn);\n callback.apply(this, arguments);\n }\n \n if (typeof event !== 'string') throw new TypeError('Event name must be a string');\n if (typeof callback !== 'function') throw new TypeError('Callback must be a function');\n \n this.on(event, fn);\n }\n \n emit(event, data) {\n if (!this.events[event]) return;\n \n try {\n this.events[event].forEach((cb) => cb(data));\n } catch (error) {\n console.error('Error in event emitter:', error);\n }\n }\n}\n```\n\nIn the `off` method, we filter out all callbacks that are not equal to the one provided and replace the array with this new array. In the `once` method, we wrap the original callback into a new function which removes itself from the event's listeners when called. If an error occurs within the callback, it is caught and logged to the console.\n", "improvedCode": "class EventEmitter {\n constructor() {\n this.events = {};\n }\n \n on(event, callback) {\n if (typeof callback !== 'function') throw new TypeError('Callback must be a function');\n \n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n }\n \n off(event, callback) {\n if (typeof event !== 'string') throw new TypeError('Event name must be a string');\n \n if (!this.events[event]) return;\n \n this.events[event] = this.events[event].filter((cb) => cb !== callback);\n }\n \n once(event, callback) {\n const self = this;\n function fn() {\n self.off(event, fn);\n callback.apply(this, arguments);\n }\n \n if (typeof event !== 'string') throw new TypeError('Event name must be a string');\n if (typeof callback !== 'function') throw new TypeError('Callback must be a function');\n \n this.on(event, fn);\n }\n \n emit(event, data) {\n if (!this.events[event]) return;\n \n try {\n this.events[event].forEach((cb) => cb(data));\n } catch (error) {\n console.error('Error in event emitter:', error);\n }\n }\n}", "duration": 10948, "success": true, "qualityMetrics": { "hasCode": true, "hasErrorHandling": true, "hasModernSyntax": true, "taskCompleted": true, "score": 0.8999999999999999, "rawScore": 0.8999999999999999, "maxScore": 1 }, "error": null }, { "timestamp": "2025-08-02T14:34:02.904Z", "model": "deepseek-coder:6.7b", "language": "python", "scenario": "basic-function", "task": "Add memoization, type hints, and docstring", "originalCode": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "rawResponse": "Here is the updated python code:\n\n```python\nfrom typing import Dict\n\ndef fibonacci(n: int, memo: Dict[int, int] = {0: 0, 1: 1}) -> int:\n \"\"\"\n Calculate nth Fibonacci number using memoization.\n \n Args:\n n (int): The position of the number in the fibonacci sequence to calculate.\n memo (Dict[int, int]): Memoization dictionary for storing already calculated values. Defaults to {0: 0, 1: 1}.\n \n Returns:\n int: nth Fibonacci number.\n \n Raises:\n ValueError: If n is negative.\n \"\"\"\n if n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n elif n not in memo:\n memo[n] = fibonacci(n - 1, memo) + fibonacci(n - 2, memo)\n return memo[n]\n```\nThis code adds the functionality of memoization to avoid redundant recursive calls. It uses a dictionary for storing already calculated Fibonacci numbers and reuses them when needed. The type hints are added using Python's built-in typing module, which provides runtime type checking in Python 3.5+. A docstring is also added explaining the function's purpose, arguments, return value, and possible exceptions.\n", "improvedCode": "from typing import Dict\n\ndef fibonacci(n: int, memo: Dict[int, int] = {0: 0, 1: 1}) -> int:\n \"\"\"\n Calculate nth Fibonacci number using memoization.\n \n Args:\n n (int): The position of the number in the fibonacci sequence to calculate.\n memo (Dict[int, int]): Memoization dictionary for storing already calculated values. Defaults to {0: 0, 1: 1}.\n \n Returns:\n int: nth Fibonacci number.\n \n Raises:\n ValueError: If n is negative.\n \"\"\"\n if n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n elif n not in memo:\n memo[n] = fibonacci(n - 1, memo) + fibonacci(n - 2, memo)\n return memo[n]", "duration": 7767, "success": true, "qualityMetrics": { "hasCode": true, "hasTypeHints": true, "hasDocstring": true, "hasErrorHandling": true, "score": 0.8333333333333334, "rawScore": 1, "maxScore": 1.2 }, "error": null }, { "timestamp": "2025-08-02T14:34:07.490Z", "model": "deepseek-coder:6.7b", "language": "python", "scenario": "data-processing", "task": "Add error handling, CSV library usage, and type hints", "originalCode": "def process_csv(filename):\n data = []\n with open(filename, 'r') as f:\n for line in f:\n data.append(line.strip().split(','))\n return data", "rawResponse": "Here is your updated python code:\n\n```python\nimport csv\nfrom typing import List, TextIO\n\ndef process_csv(filename: str) -> List[List[str]]:\n try:\n with open(filename, 'r') as f: # type: TextIO\n data = list(csv.reader(f))\n return data\n except FileNotFoundError:\n print(\"File not found.\")\n raise\n except Exception as e:\n print(\"An error occurred while processing the file.\")\n raise e\n``` \nThis code uses Python's built-in csv module to parse CSV files. It also includes basic error handling for situations where the specified filename does not exist or an unknown exception occurs during reading/processing of the file. Type hints have been added using Python's typing module, indicating that this function takes a string as its argument and returns a list of lists of strings.\n", "improvedCode": "import csv\nfrom typing import List, TextIO\n\ndef process_csv(filename: str) -> List[List[str]]:\n try:\n with open(filename, 'r') as f: # type: TextIO\n data = list(csv.reader(f))\n return data\n except FileNotFoundError:\n print(\"File not found.\")\n raise\n except Exception as e:\n print(\"An error occurred while processing the file.\")\n raise e", "duration": 4586, "success": true, "qualityMetrics": { "hasCode": true, "hasTypeHints": true, "hasErrorHandling": true, "taskCompleted": true, "score": 0.8333333333333334, "rawScore": 1, "maxScore": 1.2 }, "error": null }, { "timestamp": "2025-08-02T14:34:13.873Z", "model": "deepseek-coder:6.7b", "language": "python", "scenario": "class-improvement", "task": "Add empty check, peek method, size property, and type hints", "originalCode": "class Stack:\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n return self.items.pop()", "rawResponse": "Here is your updated python class:\n\n```python\nfrom typing import Any\n\nclass Stack:\n def __init__(self):\n self.items : list = []\n \n def push(self, item: Any) -> None:\n self.items.append(item)\n \n def pop(self) -> Any:\n if not self.is_empty():\n return self.items.pop()\n else:\n raise IndexError('Pop from empty stack')\n \n def peek(self) -> Any:\n if not self.is_empty():\n return self.items[-1]\n else:\n raise IndexError('Peek from empty stack')\n \n @property\n def size(self) -> int:\n return len(self.items)\n \n def is_empty(self) -> bool:\n return not self.items\n```\nThis class now includes a peek method to view the top item without removing it, a size property that returns the current number of items in the stack, and type hints for all methods using Python's built-in typing module. The is_empty helper function has been added to check if the stack is empty before popping or peeking.\n", "improvedCode": "from typing import Any\n\nclass Stack:\n def __init__(self):\n self.items : list = []\n \n def push(self, item: Any) -> None:\n self.items.append(item)\n \n def pop(self) -> Any:\n if not self.is_empty():\n return self.items.pop()\n else:\n raise IndexError('Pop from empty stack')\n \n def peek(self) -> Any:\n if not self.is_empty():\n return self.items[-1]\n else:\n raise IndexError('Peek from empty stack')\n \n @property\n def size(self) -> int:\n return len(self.items)\n \n def is_empty(self) -> bool:\n return not self.items", "duration": 6381, "success": true, "qualityMetrics": { "hasCode": true, "hasTypeHints": true, "hasErrorHandling": true, "score": 0.6666666666666667, "rawScore": 0.8, "maxScore": 1.2 }, "error": null }, { "timestamp": "2025-08-02T14:34:17.833Z", "model": "deepseek-coder:6.7b", "language": "rust", "scenario": "basic-safety", "task": "Add Result type for safe division and handle zero", "originalCode": "fn divide(a: f64, b: f64) -> f64 {\n a / b\n}", "rawResponse": "Here is your updated function in Rust, using the `Result` enum to handle potential errors (division by zero):\n\n```rust\nfn divide(a: f64, b: f64) -> Result<f64, &'static str> {\n if b == 0.0 {\n Err(\"Cannot divide by zero\")\n } else {\n Ok(a / b)\n }\n}\n```\nThis function now returns a `Result` type which can be either an `Ok` value (containing the result of the division operation), or an `Err` value (indicating that an error occurred). The string \"Cannot divide by zero\" is used as the payload for the error. This is idiomatic Rust and allows you to handle potential errors in a clear way.\n", "improvedCode": "fn divide(a: f64, b: f64) -> Result<f64, &'static str> {\n if b == 0.0 {\n Err(\"Cannot divide by zero\")\n } else {\n Ok(a / b)\n }\n}", "duration": 3959, "success": true, "qualityMetrics": { "hasCode": true, "hasResultType": true, "hasProperErrorHandling": true, "hasBorrowing": true, "score": 0.8461538461538461, "rawScore": 1.1, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:21.470Z", "model": "deepseek-coder:6.7b", "language": "rust", "scenario": "ownership-optimization", "task": "Optimize to use string slice reference instead of ownership", "originalCode": "fn process_string(s: String) -> String {\n let result = s.to_uppercase();\n result\n}", "rawResponse": "Here is your optimized rust code using String Slice references:\n\n```rust\nfn process_string(s: &str) -> String {\n let result = s.to_uppercase();\n result\n}\n```\nIn this version, the function takes a string slice reference (`&str`), which does not own `s` and doesn'<|begin▁of▁sentence|>t guarantee that it will remain valid for the whole of the function execution. It is more idiomatic in Rust to work with references than ownership. This way, you avoid unnecessary memory allocation and copying, but still have a clear contract about what your function expects from its caller - i.e., you are not transferring ownership of `s` into this function.\n", "improvedCode": "fn process_string(s: &str) -> String {\n let result = s.to_uppercase();\n result\n}", "duration": 3636, "success": false, "qualityMetrics": { "hasCode": true, "hasBorrowing": true, "score": 0.3076923076923077, "rawScore": 0.4, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:24.750Z", "model": "deepseek-coder:6.7b", "language": "rust", "scenario": "error-handling", "task": "Replace unwrap with proper error handling using Result", "originalCode": "fn read_number(s: &str) -> i32 {\n s.parse().unwrap()\n}", "rawResponse": "Sure, here's your updated rust function with better error handling:\n\n```rust\nfn read_number(s: &str) -> Result<i32, <ParseError as FromStr>::Err> {\n s.parse().map_err(|e| e.into())\n}\n```\nIn this code, `Result` is used to handle potential errors that may occur when parsing the string into an integer. The function will return a `Result` with an `i32` on success or an error of type `<ParseError as FromStr>::Err` if something goes wrong during parsing.\n", "improvedCode": "fn read_number(s: &str) -> Result<i32, <ParseError as FromStr>::Err> {\n s.parse().map_err(|e| e.into())\n}", "duration": 3279, "success": true, "qualityMetrics": { "hasCode": true, "hasResultType": true, "hasBorrowing": true, "taskCompleted": true, "score": 0.7692307692307692, "rawScore": 1, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:33.877Z", "model": "deepseek-coder:6.7b", "language": "cpp", "scenario": "memory-safety", "task": "Add destructor, copy constructor, and move semantics", "originalCode": "class Buffer {\n char* data;\n int size;\npublic:\n Buffer(int s) {\n data = new char[s];\n size = s;\n }\n};", "rawResponse": "Here is your updated class with added destructor, copy constructor, and move constructor:\n\n```cpp\nclass Buffer {\n char* data;\n int size;\npublic:\n // Constructor\n Buffer(int s) \n : data(new char[s]), size(s) {}\n \n // Copy Constructor\n Buffer(const Buffer& other) \n : data(new char[other.size]), size(other.size) {\n std::copy(other.data, other.data + other.size, data);\n }\n\n // Move constructor\n Buffer(Buffer&& other) noexcept \n : data(std::exchange(other.data, nullptr)), size(std::exchange(other.size, 0)) {}\n \n // Destructor\n ~Buffer() {\n delete[] data;\n }\n};\n```\nIn this code:\n- The constructor initializes the `data` member with a new array of characters of size `s` and sets the `size` to `s`.\n- The copy constructor creates a deep copy of the other object's `data` by allocating a new array of the same size as the other object, then copying over each element from the other object's data into this newly allocated data.\n- The move constructor takes ownership of the other object's resources (its `data` and `size`) by swapping them with nullptrs using `std::exchange`. This is a common way to implement move semantics in modern C++.\n- The destructor deletes the dynamically allocated memory for `data` when an instance of this class goes out of scope or gets destroyed.\n", "improvedCode": "class Buffer {\n char* data;\n int size;\npublic:\n // Constructor\n Buffer(int s) \n : data(new char[s]), size(s) {}\n \n // Copy Constructor\n Buffer(const Buffer& other) \n : data(new char[other.size]), size(other.size) {\n std::copy(other.data, other.data + other.size, data);\n }\n\n // Move constructor\n Buffer(Buffer&& other) noexcept \n : data(std::exchange(other.data, nullptr)), size(std::exchange(other.size, 0)) {}\n \n // Destructor\n ~Buffer() {\n delete[] data;\n }\n};", "duration": 9126, "success": true, "qualityMetrics": { "hasCode": true, "hasDestructor": true, "hasStdLibrary": true, "score": 0.5384615384615384, "rawScore": 0.7, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:39.063Z", "model": "deepseek-coder:6.7b", "language": "cpp", "scenario": "modern-cpp", "task": "Convert to use smart pointers and modern C++ features", "originalCode": "int* createArray(int size) {\n int* arr = new int[size];\n for(int i = 0; i < size; i++) {\n arr[i] = i;\n }\n return arr;\n}", "rawResponse": "You can utilize `std::unique_ptr` for automatic memory management in modern C++. Here is how you could rewrite your function using this feature:\n\n```cpp\n#include <memory>\n\nstd::unique_ptr<int[]> createArray(int size) {\n std::unique_ptr<int[]> arr = std::make<|begin▁of▁sentence|>(size);\n for (int i = 0; i < size; ++i) {\n arr[i] = i;\n }\n return arr;\n}\n```\nIn this code, `std::unique_ptr<int[]>` is a smart pointer that manages an array of integers. The function returns a unique pointer to the dynamically allocated integer array. This way, memory will be automatically deallocated when it's no longer in use. \n\nRemember to include `#include <memory>` at the beginning of your file to use `std::unique_ptr` and other smart pointers.\n", "improvedCode": "#include <memory>\n\nstd::unique_ptr<int[]> createArray(int size) {\n std::unique_ptr<int[]> arr = std::make<|begin▁of▁sentence|>(size);\n for (int i = 0; i < size; ++i) {\n arr[i] = i;\n }\n return arr;\n}", "duration": 5185, "success": true, "qualityMetrics": { "hasCode": true, "hasSmartPointers": true, "hasStdLibrary": true, "score": 0.6153846153846154, "rawScore": 0.8, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:40.920Z", "model": "deepseek-coder:6.7b", "language": "web", "scenario": "html-accessibility", "task": "Add proper labels, ARIA attributes, and semantic HTML", "originalCode": "<form>\n <input type=\"text\" placeholder=\"Email\">\n <input type=\"password\" placeholder=\"Password\">\n <button>Login</button>\n</form>", "rawResponse": "You can improve your web code as follows:\n\n```web\n<form aria-label=\"Login Form\">\n <div>\n <label for=\"email\">Email</label>\n <input type=\"text\" id=\"email\" placeholder=\"Enter Email\" required>\n <<|begin▁of▁sentence|>aria-required=\"true\"", "improvedCode": "", "duration": 1856, "success": false, "qualityMetrics": { "score": 0, "rawScore": 0, "maxScore": 1.4 }, "error": null }, { "timestamp": "2025-08-02T14:34:46.726Z", "model": "deepseek-coder:6.7b", "language": "web", "scenario": "css-responsive", "task": "Make responsive with flexbox/grid and mobile-first approach", "originalCode": ".container {\n width: 1200px;\n margin: 0 auto;\n}\n\n.card {\n width: 300px;\n float: left;\n margin: 10px;\n}", "rawResponse": "You can use Flexbox or Grid to make your web page more responsive. Here's how you could modify your CSS using Flexbox:\n\n```web\n.container {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n}\n\n.card {\n width: calc(100% / 3); /* Adjust this value for more/less cards per row */\n margin: 10px;\n}\n```\nThis will make your .container a flex container, and each .card item will take up one third of the available space. The `flex-wrap` property ensures that if there isn't enough space to fit all the cards in one line, they wrap onto new lines. \n\nRemember, for this to work properly, you need to ensure your parent container has a defined width or max-width. If it doesn't have any of these properties set on it, then Flexbox will not function as expected. In the provided code, `.container` is already set to center its children by using `margin: 0 auto;`\n", "improvedCode": "web\n.container {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n}\n\n.card {\n width: calc(100% / 3); /* Adjust this value for more/less cards per row */\n margin: 10px;\n}", "duration": 5804, "success": false, "qualityMetrics": { "hasCode": true, "hasResponsive": true, "score": 0.35714285714285715, "rawScore": 0.5, "maxScore": 1.4 }, "error": null }, { "timestamp": "2025-08-02T14:34:49.156Z", "model": "starcoder2:3b", "language": "javascript", "scenario": "basic-validation", "task": "Add zero division check and type validation", "originalCode": "function divide(a, b) {\n return a / b;\n}", "rawResponse": "\n\n```javascript\nfunction divide(a, b) {\n if (b === 0 || typeof a !== 'number' || typeof b !== 'number') return NaN;\n else return a / b;\n}\n```", "improvedCode": "function divide(a, b) {\n if (b === 0 || typeof a !== 'number' || typeof b !== 'number') return NaN;\n else return a / b;\n}", "duration": 2428, "success": false, "qualityMetrics": { "hasCode": true, "score": 0.2, "rawScore": 0.2, "maxScore": 1 }, "error": null }, { "timestamp": "2025-08-02T14:34:50.411Z", "model": "starcoder2:3b", "language": "javascript", "scenario": "async-error-handling", "task": "Add comprehensive error handling and retry logic", "originalCode": "async function fetchUserData(userId) {\n const response = await fetch('/api/users/' + userId);\n const data = await response.json();\n return data;\n}", "rawResponse": "\n\n```javascript\nasync function fetchUserData(userId) {\n try {\n const response = await fetch('/api/users/' + userId);\n\n if (response.status === 404) {\n throw new Error('User not found');\n } else if (!response.ok) {\n throw new Error('Something went wrong');\n }\n\n return await response.json();\n } catch(err) {\n console.log(err);\n }\n}\n```\n", "improvedCode": "async function fetchUserData(userId) {\n try {\n const response = await fetch('/api/users/' + userId);\n\n if (response.status === 404) {\n throw new Error('User not found');\n } else if (!response.ok) {\n throw new Error('Something went wrong');\n }\n\n return await response.json();\n } catch(err) {\n console.log(err);\n }\n}", "duration": 1255, "success": true, "qualityMetrics": { "hasCode": true, "hasErrorHandling": true, "hasModernSyntax": true, "hasAsync": true, "taskCompleted": true, "score": 1, "rawScore": 1, "maxScore": 1 }, "error": null }, { "timestamp": "2025-08-02T14:34:52.383Z", "model": "starcoder2:3b", "language": "javascript", "scenario": "class-optimization", "task": "Add off method, once method, and error handling", "originalCode": "class EventEmitter {\n constructor() {\n this.events = {};\n }\n \n on(event, callback) {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n }\n \n emit(event, data) {\n if (this.events[event]) {\n this.events[event].forEach(cb => cb(data));\n }\n }\n}", "rawResponse": "\n\n## Solution\n\n```javascript\nclass EventEmitter {\n constructor() {\n this.events = {};\n }\n \n on(event, callback) {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n }\n\n off(event, callback) {\n const index = this.events[event].indexOf(callback);\n\n if (index > -1) {\n this.events[event].splice(index, 1);\n }\n }\n \n emit(event, data) {\n if (!this.events[event]) return;\n \n this.events[event].forEach(cb => cb(data));\n }\n}\n```", "improvedCode": "class EventEmitter {\n constructor() {\n this.events = {};\n }\n \n on(event, callback) {\n if (!this.events[event]) {\n this.events[event] = [];\n }\n this.events[event].push(callback);\n }\n\n off(event, callback) {\n const index = this.events[event].indexOf(callback);\n\n if (index > -1) {\n this.events[event].splice(index, 1);\n }\n }\n \n emit(event, data) {\n if (!this.events[event]) return;\n \n this.events[event].forEach(cb => cb(data));\n }\n}", "duration": 1970, "success": false, "qualityMetrics": { "hasCode": true, "hasModernSyntax": true, "score": 0.4, "rawScore": 0.4, "maxScore": 1 }, "error": null }, { "timestamp": "2025-08-02T14:34:52.525Z", "model": "starcoder2:3b", "language": "python", "scenario": "basic-function", "task": "Add memoization, type hints, and docstring", "originalCode": "def fibonacci(n):\n if n <= 1:\n return n\n return fibonacci(n-1) + fibonacci(n-2)", "rawResponse": "\n", "improvedCode": "", "duration": 142, "success": false, "qualityMetrics": { "score": 0, "rawScore": 0, "maxScore": 1.2 }, "error": null }, { "timestamp": "2025-08-02T14:34:52.668Z", "model": "starcoder2:3b", "language": "python", "scenario": "data-processing", "task": "Add error handling, CSV library usage, and type hints", "originalCode": "def process_csv(filename):\n data = []\n with open(filename, 'r') as f:\n for line in f:\n data.append(line.strip().split(','))\n return data", "rawResponse": "\n", "improvedCode": "", "duration": 142, "success": false, "qualityMetrics": { "score": 0, "rawScore": 0, "maxScore": 1.2 }, "error": null }, { "timestamp": "2025-08-02T14:34:53.902Z", "model": "starcoder2:3b", "language": "python", "scenario": "class-improvement", "task": "Add empty check, peek method, size property, and type hints", "originalCode": "class Stack:\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n return self.items.pop()", "rawResponse": "\n\nOriginal python code:\n```python\nclass Stack:\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n return self.items.pop()\n```\n\nTask: Add empty check, peek method, size property, and type hints\n\nReturn only the improved code. Use proper Python syntax with type hints from typing module.", "improvedCode": "class Stack:\n def __init__(self):\n self.items = []\n \n def push(self, item):\n self.items.append(item)\n \n def pop(self):\n return self.items.pop()", "duration": 1233, "success": false, "qualityMetrics": { "hasCode": true, "score": 0.16666666666666669, "rawScore": 0.2, "maxScore": 1.2 }, "error": null }, { "timestamp": "2025-08-02T14:34:54.044Z", "model": "starcoder2:3b", "language": "rust", "scenario": "basic-safety", "task": "Add Result type for safe division and handle zero", "originalCode": "fn divide(a: f64, b: f64) -> f64 {\n a / b\n}", "rawResponse": "\n", "improvedCode": "", "duration": 140, "success": false, "qualityMetrics": { "score": 0, "rawScore": 0, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:56.162Z", "model": "starcoder2:3b", "language": "rust", "scenario": "ownership-optimization", "task": "Optimize to use string slice reference instead of ownership", "originalCode": "fn process_string(s: String) -> String {\n let result = s.to_uppercase();\n result\n}", "rawResponse": "\n\nRust code:\n```rust\nfn process_string(s: &str) -> String {\n let result = s.to_uppercase();\n result\n}\n```\n\nOriginal rust code:\n```rust\nfn main() {\n let mut s1 = String::from(\"Hello\");\n\n println!(\"{}, world!\", s1);\n \n process(&mut s1);\n\n println!(\"s1: {}, s2: {}\", s1, s2);\n}\n\nfn process(s1: &mut String) -> () {\n let result = s1.to_uppercase();\n *s1 = result;\n}\n```\n\nTask: Optimize to use string slice reference instead of ownership\n\nReturn only the improved code. Use idiomatic Rust with proper error handling and ownership.", "improvedCode": "fn main() {\n let mut s1 = String::from(\"Hello\");\n\n println!(\"{}, world!\", s1);\n \n process(&mut s1);\n\n println!(\"s1: {}, s2: {}\", s1, s2);\n}\n\nfn process(s1: &mut String) -> () {\n let result = s1.to_uppercase();\n *s1 = result;\n}", "duration": 2117, "success": false, "qualityMetrics": { "hasCode": true, "score": 0.15384615384615385, "rawScore": 0.2, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:56.301Z", "model": "starcoder2:3b", "language": "rust", "scenario": "error-handling", "task": "Replace unwrap with proper error handling using Result", "originalCode": "fn read_number(s: &str) -> i32 {\n s.parse().unwrap()\n}", "rawResponse": "\n", "improvedCode": "", "duration": 139, "success": false, "qualityMetrics": { "score": 0, "rawScore": 0, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:57.733Z", "model": "starcoder2:3b", "language": "cpp", "scenario": "memory-safety", "task": "Add destructor, copy constructor, and move semantics", "originalCode": "class Buffer {\n char* data;\n int size;\npublic:\n Buffer(int s) {\n data = new char[s];\n size = s;\n }\n};", "rawResponse": "\n\n## Solution\n\n```cpp\nclass Buffer {\n char* data;\n int size;\npublic:\n Buffer(int s) : data{new char[s]}, size{s} {}\n\n ~Buffer() {\n delete[] data;\n }\n\n // Copy constructor\n Buffer(const Buffer& other) = default;\n\n // Move constructor\n Buffer(Buffer&& other) noexcept \n : data{other.data}, \n size{other.size} \n {\n other.data = nullptr;\n other.size = 0;\n }\n};\n```\n", "improvedCode": "class Buffer {\n char* data;\n int size;\npublic:\n Buffer(int s) : data{new char[s]}, size{s} {}\n\n ~Buffer() {\n delete[] data;\n }\n\n // Copy constructor\n Buffer(const Buffer& other) = default;\n\n // Move constructor\n Buffer(Buffer&& other) noexcept \n : data{other.data}, \n size{other.size} \n {\n other.data = nullptr;\n other.size = 0;\n }\n};", "duration": 1432, "success": false, "qualityMetrics": { "hasCode": true, "hasDestructor": true, "score": 0.3846153846153846, "rawScore": 0.5, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:58.924Z", "model": "starcoder2:3b", "language": "cpp", "scenario": "modern-cpp", "task": "Convert to use smart pointers and modern C++ features", "originalCode": "int* createArray(int size) {\n int* arr = new int[size];\n for(int i = 0; i < size; i++) {\n arr[i] = i;\n }\n return arr;\n}", "rawResponse": "\n\n## Task 2\n\nOriginal cpp code:\n```cpp\nvoid printArray(int* arr, int size) {\n for (int i = 0; i < size; i++) {\n cout << arr[i] << endl;\n }\n}\n```\n\nTask: Convert to use smart pointers and modern C++ features. Use modern C++ features (C++17 or later).", "improvedCode": "void printArray(int* arr, int size) {\n for (int i = 0; i < size; i++) {\n cout << arr[i] << endl;\n }\n}", "duration": 1190, "success": false, "qualityMetrics": { "hasCode": true, "score": 0.15384615384615385, "rawScore": 0.2, "maxScore": 1.3 }, "error": null }, { "timestamp": "2025-08-02T14:34:59.940Z", "model": "starcoder2:3b", "language": "web", "scenario": "html-accessibility", "task": "Add proper labels, ARIA attributes, and semantic HTML", "originalCode": "<form>\n <input type=\"text\" placeholder=\"Email\">\n <input type=\"password\" placeholder=\"Password\">\n <button>Login</button>\n</form>", "rawResponse": "\n\n```web\n<form>\n <label for=\"email\">Email:</label><br/>\n <input type=\"text\" id=\"email\"><br/>\n\n <label for=\"password\">Password:</label><br/>\n <input type=\"<PASSWORD>\" id=\"password\"><br/>\n \n <button>Login</button>\n</form>\n```\n", "improvedCode": "web\n<form>\n <label for=\"email\">Email:</label><br/>\n <input type=\"text\" id=\"email\"><br/>\n\n <label for=\"password\">Password:</label><br/>\n <input type=\"<PASSWORD>\" id=\"password\"><br/>\n \n <button>Login</button>\n</form>", "duration": 1016, "success": false, "qualityMetrics": { "hasCode": true, "hasLabels": true, "score": 0.35714285714285715, "rawScore": 0.5, "maxScore": 1.4 }, "error": null }, { "timestamp": "2025-08-02T14:35:00.083Z", "model": "starcoder2:3b", "language": "web", "scenario": "css-responsive", "task": "Make responsive with flexbox/grid and mobile-first approach", "originalCode": ".container {\n width: 1200px;\n margin: 0 auto;\n}\n\n.card {\n width: 300px;\n float: left;\n margin: 10px;\n}", "rawResponse": "\n", "improvedCode": "", "duration": 142, "success": false, "qualityMetrics": { "score": 0, "rawScore": 0, "maxScore": 1.4 }, "error": null } ] }