Code Review Guidelines for better code quality
Mohammed Samgan Khan

Mohammed Samgan Khan @msamgan

About: Love to code with a DRY KISS

Location:
USA
Joined:
Apr 23, 2019

Code Review Guidelines for better code quality

Publish Date: Oct 18 '20
8 0

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.

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

Comments 0 total

    Add comment