Saltar al contenido ForoHackers

Code review: start here

Revisión de código
#3357 · · Citar · Denunciar

Code review is having someone other than the author read a change before it is merged. It catches bugs and design problems early, spreads knowledge of the codebase, and keeps style consistent. Done well it is a conversation about the code, never about the person, and it is a skill for the reviewer as much as for the author.

Key concepts

  • Small changes: a review of a few hundred lines gets real attention; a huge one gets a rubber stamp.
  • What to look for: correctness, tests, design, naming, security, and whether the change does what it claims.
  • Automate the rest: formatters, linters and CI handle style so humans can think about meaning.
  • Tone: ask questions, explain the reason, separate "must fix" from "nit", and praise what is good.
  • Author's duty: describe the why, review your own diff first, and answer comments without defensiveness.

Vocabulary

  • Pull request: a proposed change, with its discussion, before it is merged.
  • Nit: a minor, optional remark about style.
  • LGTM: "looks good to me", an approval.
  • Linter: a tool that flags suspicious or non-idiomatic code.

What to study, in order

  1. Review your own diff line by line before asking anyone, and note what you would flag.
  2. Read reviews on a well-run open source project and note how they are worded.
  3. Write a checklist for your language: error handling, resource cleanup, concurrency, input validation.
  4. Set up a formatter and a linter so the checklist shrinks.
  5. Practise reviewing for design: does this belong here, and will the next person understand it?

Related tags

#version-control #testing #open-source #secure-coding

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder