MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / clampCommentToValidRange

Function clampCommentToValidRange

code-scan-action/src/github.ts:129–146  ·  view source on GitHub ↗

* Clamp a comment's line numbers to valid diff ranges. * Returns the adjusted comment, or null if lines cannot be clamped.

(comment: Comment, validRanges: FileLineRanges)

Source from the content-addressed store, hash-verified

127 * Returns the adjusted comment, or null if lines cannot be clamped.
128 */
129function clampCommentToValidRange(comment: Comment, validRanges: FileLineRanges): Comment | null {
130 if (!comment.file || comment.line == null) {
131 return comment;
132 }
133
134 const clamped = clampCommentLines(comment.file, comment.startLine, comment.line, validRanges);
135
136 if (!clamped) {
137 // File not in diff - return null to convert to general comment
138 return null;
139 }
140
141 return {
142 ...comment,
143 startLine: clamped.startLine,
144 line: clamped.line,
145 };
146}
147
148/**
149 * Validate review-comment locations against the current PR diff.

Callers 1

Calls 1

clampCommentLinesFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…