feat(DEP0206): remove provably redundant `Hmac.digest()` calls

Aperta
#557 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
tooling

Direzione di ricerca

Start by reading the repository’s existing codemod entry points and fixture conventions; this issue does not name specific files. Use the adjacent argument-free call example as the initial supported case, and add fixtures for the listed edge cases. Done means only provably redundant standalone calls are removed, consumed results are reported for manual review, and the transform is idempotent.

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

Descrizione

good first issue human help wanted

Node.js 27.0.0-alpha.0.0.0 introduces a runtime deprecation warning when Hmac.digest() is called on an already-finalized Hmac instance. This behavior is tracked by DEP0206; the repeated call has not yet been removed.

Add a narrowly scoped codemod that removes a redundant call only when the instance is provably already finalized and the repeated call's return value is unused.

Start with straight-line local code using an unmodified Hmac instance created through crypto.createHmac(). Support CommonJS and ESM bindings, aliases, and both crypto and node:crypto specifiers.

Additional Information

  • The initial automatic transformation should handle adjacent calls on the same stable local binding: the first call finalizes the Hmac, and the following argument-free hmac.digest(); is a standalone expression statement.
  • Do not transform unresolved receivers, reassignments, escaped instances, overridden methods, or cases with uncertain control flow.
  • Do not remove a repeated call with arguments that may have side effects or cause an encoding error. These cases are outside the initial scope.
  • When the repeated result is consumed, report the call for manual review. Reusing the first digest changes behavior: a repeated call currently returns an empty Buffer or encoded empty string, not the original digest.
  • Do not replace repeated results with cached digests or empty values automatically.
  • Leave the first digest and unrelated methods unchanged. The transform must be idempotent.
  • Include fixtures for the supported adjacent-call pattern, consumed results, aliases, shadowed bindings, invalid encodings, and calls in different branches.

Examples

Supported automatic cleanup:

 import { createHmac } from 'node:crypto';

 const hmac = createHmac('sha256', 'secret');
 hmac.update('message');
 const digest = hmac.digest('hex');
-hmac.digest();
 console.log(digest);

Keep unchanged and report for manual review:

const first = hmac.digest('hex');
const second = hmac.digest('hex');
consume(first, second);

The codemod cannot assume that second should equal first.

Refs

Lingua principale
TypeScript
Stelle
85
Fork
58
Merge medio
2g 4h
PR unite (30g)
6

Preparare l'ambiente

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 nodejs/userland-migrations

Tutte le issue di nodejs/userland-migrations

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.