fix: address self-review findings on PR #90
- Remove unused error return from BuildPositionToLineMap (always nil) - Add comment explaining intentional CommitID drop in PostReview - Refactor TestAdapter_PostReview_WithComments to route by URL path - Add TestAdapter_GetFileContent_RefRouting test - Acknowledge maxPosition O(n) with code comment - Remove redundant TestAdapter_CompileTimeCheck (compile-time var _ exists) - Fix GetPullRequestFiles comment (Patch field is omitted, not 'set to empty') - Acknowledge translateEvent fallback as intentional design
This commit is contained in:
+3
-2
@@ -53,6 +53,7 @@ func (pm *PositionMap) Translate(file string, position int) (int, error) {
|
||||
}
|
||||
|
||||
// maxPosition returns the highest position number for a file.
|
||||
// O(n) per call — acceptable since deletion-line fallback is rare and n is small (typical hunk size).
|
||||
func (pm *PositionMap) maxPosition(file string) int {
|
||||
max := 0
|
||||
for pos := range pm.files[file] {
|
||||
@@ -72,7 +73,7 @@ func (pm *PositionMap) maxPosition(file string) int {
|
||||
// - A new @@ hunk within the same file continues incrementing (does not reset)
|
||||
// - Position maps to the new file line number for additions and context lines
|
||||
// - Deletion lines have a position but no new-file line number (stored as -1)
|
||||
func BuildPositionToLineMap(diff string) (*PositionMap, error) {
|
||||
func BuildPositionToLineMap(diff string) *PositionMap {
|
||||
pm := &PositionMap{files: make(map[string]map[int]int)}
|
||||
|
||||
lines := strings.Split(diff, "\n")
|
||||
@@ -153,7 +154,7 @@ func BuildPositionToLineMap(diff string) (*PositionMap, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return pm, nil
|
||||
return pm
|
||||
}
|
||||
|
||||
// parseHunkStart extracts the new-file starting line number from a hunk header.
|
||||
|
||||
Reference in New Issue
Block a user