cleancode.in

Clean code checklist

20 questions to ask of any change before you call it done, on names, functions, comments, errors, layout and tests. Keep it beside your editor, or print it from your browser.

Are the names clear?

  • Does each name say what it holds?
  • Do yes or no values read as questions, like is_paid?
  • Is one word kept for one idea: fetch or get, not both?
  • Are type tags and words like data or manager gone?

Do the functions do one thing?

  • Does each function do one thing, and say which?
  • Does it fit on one screen?
  • Three parameters or fewer?
  • Does it change something or answer something, not both?

Do the comments earn their place?

  • Does each comment say why, not what?
  • Does any comment contradict the code?
  • Is commented out code deleted?

Are errors handled?

  • Is each error handled where it happens?
  • Does each error say what failed, and with what?
  • Does nothing fail in silence?

Is the layout consistent?

  • Does the formatter pass with no changes?
  • Does it match the rest of the project?
  • Are bare numbers named as constants?

Is it tested?

  • Does a test fail without this change?
  • Does each test check one behaviour?
  • Are the tests fast enough to run every time?

Where do the rules come from?

These questions are ours. For your language’s own rules, quoted, start from clean code by language.