#code quality

Code Review Guidelines for better code quality

As all of us know that there is no certain rules when it comes to code review. From my experience I have derived the below mentioned points for enhancing the code quality before the PR submission.

  1. Please follow the PSR standards for nomenclature. (https://www.php-fig.org/psr/)
  2. Please use clean code practices for writing a piece of logic (https://github.com/jupeter/clean-code-php)
  3. Though you will find this rule in PSR but still please use space before and after any operator.
  4. Don’t break indentation.
  5. Rules for declaring a function
  6. Small (not more than 20 lines).
  7. Do specifically one thing.
  8. Use descriptive names as per PSR.
  9. Prefer fewer arguments.
  10. Don’t use flag arguments. Split method into several independent methods that can be called from the client without the flag.
  11. Rules for Commenting
  12. Always try to explain yourself in code.
  13. Don’t be redundant.
  14. Don’t add obvious noise.
  15. Don’t comment out code. Just remove. If it is a working piece of code, please write a proper comment that this is working.
  16. Use as explanation of intent.
  17. Use as clarification of code.
  18. Use as warning of consequences.
  19. Declare variables close to their usage.
  20. Dependent functions should be close.
  21. Similar functions should be close.
  22. Place functions in the downward direction but if it’s a relation please make it on the top of the model file.
  23. Keep lines short.
  24. Return on Negative conditions. Instead of writing the entire section of code in a if condition, return on “!if” condition.
  25. In case of a merge conflict please put a message in the group asking the individuals worked on the same files.
  26. Try to optimize code before creating a PR
  27. Reduce no. of lines of code
  28. Reduce unnecessary variable declaration
  29. If possible break in reusable functions
  30. Below are mentioned the parameters for the code review.
  31. make sure that there are no conflicts
  32. there must not be any debug function open in the updated code.
  33. no (non-usable) commented code
  34. check for non-significant variable name declaration
  35. check for unused parameters in the function declarations.
  36. Check for unused parameters in a function call.
  37. check for unwanted functions declarations
  38. check for PSR rule violations
  39. Always try and search for existing functions before creating a new one.
  40. All the changes are to be made via Git. Under no circumstances FTP is to be used for making required changes.