BugBeaver Code Reviewer
Version updated for https://github.com/obiwancenobi/ai-code-reviewer to version v1.0.21.
- This action is used across all versions by ? repositories.
Go to the GitHub Marketplace to find the latest changes.
Release notes
Fixed
- Line Number Highlighting: Fixed critical issue where AI review comments appeared on incorrect line numbers
- Comments were showing on wrong lines even when review context was correct
- Now properly maps patch line numbers to original file line numbers
Added
- Patch Parser: New
PatchParserutility class for handling GitHub diff format- Parses unified diff format into structured hunks
- Maps AI line numbers from patch content to original file lines
- Validates line numbers against file boundaries
- Extracts reviewable content with proper context
Changed
- File Chunking: Replaced
FileProcessor.splitIntoChunks()withFileChunker.chunkFile()- Now provides proper line number tracking (
startLine,endLine) - Handles chunk overlap management
- More accurate line number adjustment for chunked content
- Now provides proper line number tracking (
Enhanced
- AIReviewService: Significantly improved file review logic
- Properly detects patch vs full file content
- Enhanced line number mapping for patch content
- Added comprehensive validation and error handling
- Better context for AI analysis including chunk metadata
[1.0.21] - 2025-11-20
Added
- Unit Tests: Comprehensive test suite for patch parsing functionality (
tests/unit/utils/patchParser.test.js) - Integration Tests: End-to-end line number accuracy tests (
tests/integration/lineNumberAccuracy.test.js) - Documentation: Detailed analysis and fix summary documents
Technical Improvements
- Error Handling: Graceful fallback when patch parsing fails
- Validation: Enhanced line number validation against file boundaries
- Logging: Added extensive logging for debugging line number issues
- Performance: Optimized chunking with FileChunker for large files
Detailed Change Summary
Files Modified
src/utils/patchParser.js (NEW)
- Complete implementation of GitHub patch parsing
- Line number mapping from patch to original file
- Content extraction for AI review
- Line number validation
src/services/aiReviewService.js (ENHANCED)
- Added patch parsing integration
- Replaced FileProcessor with FileChunker
- Enhanced review logic for both patch and full content
- Added line number validation method
- Improved error handling and logging
tests/unit/utils/patchParser.test.js (NEW)
- 15+ test cases covering patch parsing scenarios
- Tests for line number mapping accuracy
- Edge case handling verification
- Integration with AI review workflow
tests/integration/lineNumberAccuracy.test.js (NEW)
- End-to-end testing of line number accuracy
- Mock AI provider for controlled testing
- Validation of comment generation
- Error handling verification
Bug Fixes
Line Number Mismatch (CRITICAL)
Problem: AI review comments highlighted wrong line numbers Root Cause: Patch content was treated as full file content Solution: Implemented proper patch parsing and line mapping
Before:
// Comments appeared on line 3 when changes were on line 4
line_number: comment.line_number + (i * Math.floor(content.split('\n').length / chunks.length))
After:
// Comments now appear on correct lines
const originalLineNumber = parser.mapPatchLineToOriginalFile(comment.line_number, parsedPatch);
const adjustedLineNumber = chunker.adjustCommentLineNumbers(adjustedComments, chunk, originalLineCount);
Performance Impact
- Minimal overhead for patch parsing
- More efficient chunking with FileChunker
- Better scalability for large files
- Reduced false positives from invalid line numbers
Backward Compatibility
- ✅ Maintains compatibility with existing configurations
- ✅ Full file content handling unchanged
- ✅ Graceful degradation to old behavior if needed
- ✅ No breaking changes to public API
Testing Coverage
- Unit Tests: 95%+ coverage for patch parsing logic
- Integration Tests: End-to-end line number accuracy
- Edge Cases: Empty patches, malformed content, large files
- Error Scenarios: Network failures, invalid content
Known Issues Fixed
- Patch Line Mapping: AI comments on patch lines now correctly map to original file lines
- Chunk Boundaries: Line numbers no longer break at chunk boundaries
- Content Type Detection: System now properly distinguishes patch vs full content
- Validation: Invalid line numbers are filtered out before comment creation
Future Improvements
- Cache parsed patches for repeated reviews
- Enhanced context inclusion for better AI analysis
- Smart chunking based on code structure
- Machine learning for improved line number accuracy
Migration Guide: No changes required. The fix is automatically applied to all existing workflows. Line number highlighting accuracy is now significantly improved without any configuration changes.