neurolink icon indicating copy to clipboard operation
neurolink copied to clipboard

FD-022: Add JSDoc Comments to Private Methods

Open murdore opened this issue 1 month ago • 0 comments

Bug Summary

Private methods lack JSDoc comments explaining purpose, parameters, return values. Reduces maintainability.

Root Cause Analysis

Why this bug exists: Written without documentation, likely time pressure. Missing docs make code harder to understand.

Impact:

  • Steeper learning curve
  • Slower code reviews
  • Increased bug risk
  • Poor maintainability

Current Code (Buggy)

```typescript private static async loadContent( // ❌ No JSDoc input: FileInput, detection: FileDetectionResult, options?: FileDetectorOptions, ): Promise<Buffer> { // Implementation... }

private isPNG(buf: Buffer): boolean { // ❌ No JSDoc // Implementation... } ```

Fixed Code

```typescript /**

  • Load file content from various sources
  • @param input - File input (path, URL, Buffer, or data URI)
  • @param detection - Detection result containing source type
  • @param options - Loading options (size limits, timeouts)
  • @returns File content as Buffer
  • @throws Error if file cannot be loaded or exceeds size limit */ private static async loadContent( input: FileInput, detection: FileDetectionResult, options?: FileDetectorOptions, ): Promise<Buffer> { // Implementation... }

/**

  • Check if buffer starts with PNG magic bytes (0x89 0x50 0x4E 0x47)
  • @param buf - Buffer to check
  • @returns true if PNG signature detected */ private isPNG(buf: Buffer): boolean { // Implementation... } ```

Acceptance Criteria

  • [ ] JSDoc for loadContent()
  • [ ] JSDoc for all magic byte methods
  • [ ] JSDoc for helpers
  • [ ] Consistent format
  • [ ] Tests pass

File: src/lib/utils/fileDetector.ts Effort: 2h Good First Issue: Yes

murdore avatar Dec 01 '25 02:12 murdore