Misleading comments and small redundancies in the core path

Aperta Adatta ai principianti
#329 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
Mezza giornata
Idoneità per principianti
75/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
cli, networking

Direzione di ricerca

Inizia dalle sette righe citate: i commenti JSON obsoleti in internal/output/writer.go e internal/tui/model.go, la chiamata di log resolveWithLog in internal/dns/resolver.go, la chiamata duplicata a validateArgs tra main_session.go e main.go, e i due avvisi fmt.Fprintf in tuiOptions. È completato quando i commenti descrivono l'output in streaming, -v non stampa più Error: <nil> per un risultato NODATA, la validazione duplicata è stata eliminata e gli avvisi della TUI passano da diag. Verifica con make test usando -simulate o il server di test locale, non un dominio reale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

good first issue severity: low tech-debt

Summary

A checklist of small items: three comments that still say JSON output is buffered, a verbose log line that labels a definitive negative as a failure with Error: <nil>, a validation call that runs twice, and two TUI warnings that bypass the diagnostics writer.

Where

  • internal/output/writer.go:28
  • internal/tui/model.go:329
  • internal/tui/model.go:346
  • internal/dns/resolver.go:479
  • main_session.go:288
  • main.go:304
  • main_session.go:230

Details

Checklist, each item read at the cited line:

  • writer.go:28: "FormatJSON buffers results and emits a single JSON array at completion". Since #181 it streams each element (writeJSONElement, writer.go:255-284); the comment on Emit at 175-178 says so correctly.
  • tui/model.go:329-330 and 346-347: "finalize structured output so buffered JSON/CSV is written" and "buffered JSON array emitted": same stale description of JSON.
  • resolver.go:478-479: l.Logf("Failed to resolve: %s (Error: %v) in %s", domain, err, elapsed) also runs when the lookup succeeded with no records of the requested types (err == nil, the NODATA case Resolve handles at 500-505), so -v prints Failed to resolve: x (Error: <nil>) for a definitive negative.
  • main_session.go:288 calls validateArgs, and validateFlags (called at 318) calls it again as its first statement (main.go:304). The second call can never fail.
  • main_session.go:230 and 240: tuiOptions writes its two warnings straight to stderr with fmt.Fprintf, bypassing the diag writer built ten lines earlier (main_session.go:162), so -tui -log-format json emits plain text lines among JSON ones.

Impact

Readers are told JSON output is held in memory when it is not (relevant to anyone reasoning about memory or partial output), verbose logs label negatives as failures, and two small inconsistencies add noise. None changes results.

Suggested fix

Reword the three comments to "streamed as array elements; Finish closes the array". In resolveWithLog, branch on err == nil and log "No records: %s (%s) in %s". Drop the validateArgs call from validateFlags or from configure. Route the two TUI warnings through diag.Notice.

Acceptance criteria

  • Each checklist item under Details is fixed
  • -v no longer prints Error: <nil>

Getting started

  • Relevant files: internal/output/writer.go, internal/tui/model.go, internal/dns/resolver.go, main_session.go
  • How to run tests: make test (or go test ./...). Tests must stay hermetic: use -simulate, -simulate-zone or the local DNS test server, never a live domain.
  • Related docs: docs/DEVELOPER_GUIDE.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at d0c56f0. Severity: low. Effort: S. audit-key: tech-debt|internal/output/writer.go|comments

Lingua principale
Go
Stelle
1
Fork
1
Merge medio
6h 42m
PR unite (30g)
7

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TMHSDigital/subenum

Tutte le issue di TMHSDigital/subenum

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.