How to do a code review?

In the life of a developer, there comes a time when he begins to conduct a code review. As a rule, this is one of the signs of a programmer's growth: they begin to really listen to his opinion and trust more serious tasks. The exact moment when a developer is asked to do a review depends on the structure of the company: there are teams where more or less everything can be done after some time has elapsed, and there are those where the review process rests entirely with the oldest and most experienced colleagues.


At the same time, few people talk about what principles should be followed to conduct a quality review: what are the main goals of this procedure, what to look for in the first place, how quickly it needs to be carried out.


Therefore, the Google Review Guide looks like a very valuable document, the translation of the first part of which is presented later. Translations of the remaining parts will be released later in separate posts. It is worth noting that this is an adapted translation, not all are translated word-for-word, in the name of more Russian formulations and sentences.


Terminology:


CL : "changelist" - a list of code changes sent to the version control system for review. An analogue of Pull Request in GitHub or Merge Request in GitLab.


1. Standards code review


The main purpose of the review is to improve Google’s code base. All tools and means used to conduct a review are aimed specifically at achieving this goal.


On the way to achieving the stated goal, we have to make a number of compromises.


First, developers should be able to do their tasks. If you do not accept any changes to the code base, then it will never improve. In the case when the reviewer makes any changes too complicated, the developers simply do not go to do anything in the future.


, CL , . , . , .


, . , , , " ".


, , :


CL , , CL .


.


, : CL , , , .


, : , . CL , , CL , , . , , . CL, , , , .


, , , , . , , "Nit: ", .


: CL, . .


1.1.


- , , . , , - . , . , ( ), "Nit: " .


1.2.


  • .
  • style guide .
    , style guide . , .
  • .
    / , . .
    , , , . .
  • , , , , .

1.3.


, , , , : CL .


, : . , CL, .


, β€” , , , . CL "" , .


2.


: - .


2.1. ()


, β€” CL . CL? : ? ? ?


2.2.


CL , ? ? "" ( ), , .


, . , , , , , , .


, CL: , . , .


, β€” CL . , β€” . , , . ( ).


2.3.


CL β€” , , . , -, , -, .


, , , . , , , , . , .


2.4.


, , : , end-to-end . , CL, .
.


β€” , , .
, ? , ? , ? ?


, β€” , . , , .


2.5.


, . , , , , .


2.6.


, ? ? , , , , , : , . , . , , , : , .


, CL: , "TODO", , .


, β€” , . , .


2.7.


Google , . , CL .


, , ("Nit:"). CL .


CL . , . , , , CL β€” , .


2.8.


CL , , , , , README, g3doc (. β€” Google ) . CL , , . , .


2.9.


. , , , , . , - β€” . , .


, , , . Google . , , , , . , , , , .


, , , . , , , , .


2.10.


, , . , , : , , 4 , , 50 .


CL : CL , ?
CL, . , , CL.


2.11.


CL , : , . , , .



:


  • ,
  • ,
  • : , ,
  • ,
  • ,
  • ,
  • ,
  • , , ,
  • , , ( ),
  • (g3doc),
  • -.

You should look at each line of the code, take into account the context , be sure that you are improving the state of the code base and encourage successful developer decisions.


In the next part, we will discuss how to better navigate in the CL and where to start the review.

Source: https://habr.com/ru/post/undefined/


All Articles