Conversation
| def process_data(data): | ||
| """Process data and return result. | ||
|
|
||
| Low severity: Doesn't handle empty input gracefully. | ||
| """ | ||
| total = 0 | ||
| for item in data: | ||
| total += item["value"] # Will crash if data is empty or item has no "value" |
There was a problem hiding this comment.
🤖 Code Review Finding: Division by zero when processing empty data
Severity: MEDIUM
Category: correctness
Impact: Any call to process_data([]) will crash the application with a ZeroDivisionError. This is a runtime bug that will cause unexpected failures.
Recommendation: Add a guard clause to handle empty input gracefully, either by returning a default value or raising a meaningful exception.
| def process_data(data): | |
| """Process data and return result. | |
| Low severity: Doesn't handle empty input gracefully. | |
| """ | |
| total = 0 | |
| for item in data: | |
| total += item["value"] # Will crash if data is empty or item has no "value" | |
| def process_data(data): | |
| """Process data and return result. | |
| Low severity: Doesn't handle empty input gracefully. | |
| """ | |
| if not data: | |
| return 0 | |
| total = 0 | |
| for item in data: | |
| total += item["value"] # Will crash if data is empty or item has no "value" | |
| return total / len(data) |
| def find_duplicates(items): | ||
| """Find duplicate items in a list. | ||
|
|
||
| Medium severity: O(n²) algorithm when O(n) with set is possible. | ||
| """ | ||
| duplicates = [] | ||
| for i in range(len(items)): | ||
| for j in range(i + 1, len(items)): | ||
| if items[i] == items[j] and items[i] not in duplicates: | ||
| duplicates.append(items[i]) | ||
| return duplicates |
There was a problem hiding this comment.
🤖 Code Review Finding: Quadratic time complexity in duplicate detection
Severity: MEDIUM
Category: performance
Impact: For large input lists, this function will become extremely slow. A list of 10,000 items could require up to 100 million comparisons, causing performance degradation in production.
Recommendation: Use a set-based approach to achieve O(n) time complexity.
| def find_duplicates(items): | |
| """Find duplicate items in a list. | |
| Medium severity: O(n²) algorithm when O(n) with set is possible. | |
| """ | |
| duplicates = [] | |
| for i in range(len(items)): | |
| for j in range(i + 1, len(items)): | |
| if items[i] == items[j] and items[i] not in duplicates: | |
| duplicates.append(items[i]) | |
| return duplicates | |
| def find_duplicates(items): | |
| """Find duplicate items in a list. | |
| Medium severity: O(n²) algorithm when O(n) with set is possible. | |
| """ | |
| seen = set() | |
| duplicates = set() | |
| for item in items: | |
| if item in seen: | |
| duplicates.add(item) | |
| else: | |
| seen.add(item) | |
| return list(duplicates) |
Summary
Test PR to verify that inline comments are posted even when the review is APPROVED (no HIGH severity findings).
This file contains intentional issues:
Expected behavior
🤖 Generated with Claude Code