MCPcopy Index your code
hub / github.com/simstudioai/sim / readAnnotation

Function readAnnotation

scripts/check-migrations-safety.ts:163–180  ·  view source on GitHub ↗

* Mirror of the api-validation annotation reader, for `--` SQL comments: * scans up to three consecutive non-empty preceding lines for the prefix. * `allowed` when a non-empty reason follows; `missingReason` flags a dangling * annotation so it fails rather than silently passing.

(
  lines: string[],
  startLine: number
)

Source from the content-addressed store, hash-verified

161 * annotation so it fails rather than silently passing.
162 */
163function readAnnotation(
164 lines: string[],
165 startLine: number
166): { allowed: boolean; missingReason: boolean } {
167 let inspected = 0
168 for (let i = startLine - 2; i >= 0 && inspected < 3; i--) {
169 const trimmed = lines[i]?.trim() ?? ''
170 if (trimmed.length === 0) continue
171 inspected++
172 if (!trimmed.startsWith('--')) return { allowed: false, missingReason: false }
173 const idx = trimmed.indexOf(ANNOTATION_PREFIX)
174 if (idx === -1) continue
175 const reason = trimmed.slice(idx + ANNOTATION_PREFIX.length).trim()
176 if (reason.length === 0) return { allowed: false, missingReason: true }
177 return { allowed: true, missingReason: false }
178 }
179 return { allowed: false, missingReason: false }
180}
181
182interface RawMatch {
183 kind: 'error' | 'annotate' | 'warn'

Callers 1

lintSqlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected