Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The 2012-03-14 OpenMRS University  focused focused on code reviews. The presentation, at http://www.youtube.com/watch?v=lVVlDIElkuA , gives a good introduction to the process. 

...

The pieces of code that need review are governed by the tickets in JIRA that have the status of "Code Review (Initial)" or "Code Review (Pre-Commit)" or "Code Review (Post Commit)". To enter the queue, move your code through the workflow to get that status.

...

If you do not have a ticket yet, create one, attach your patch or link to your branch, and then move the ticket through the workflow.

  • If using Git/Github and you don't have admin status:
    1. issue Issue a pull request with a full link to your ticket in the description.
    2. click Click the "Request Review" option on the ticket to move into the "Code Review (pre-commit)" state.
    3. Add a comment linking to your pull request by its urlURL
  • If using Git/Github and you do have admin status:
    1. Commit/push to your fork, issue a pull request, and merge the request. (put a full link to your ticket in the description)
    2. Click "Committed Code" in the ticket to move into the "Code Review (post-commit)"

Now you can either ask someone to review the ticket, or you wait for someone in the Community Development Swim Lane to review it.

...

Go through the code SLOWLY with a mind towards toward the Goals of Code Review (see below) and the Code Review Checklist

...

  • Finding bugs
    • Bugs found in code review require much less effort to find & fix than bugs found in QA/testing.
  • Coding style. Ensure that our Java Conventions are followed.
  • Improving code quality
  • Teaching best practices
  • Code consistency (can't tell the author from the code)
  • Learning code
  • Efficiency (getting pull requests reviewed quickly)
  • Ensuring that the pull request guidelines are followed.

Tips for Code Review

  • 60 minutes or less – never review for more than an hour at a time.
    • Reviewer effectiveness drops precipitously after one hour.
  • "Lines Of Code (LOC) for a review should be under 200, not to exceed 400."
  • Slow down!  "The longer you take in review, the more defects you’ll find."
    • Inspection An inspection rate of < 250 lines/hour is good, < 400 lines/hour is okay, and above 400 lines/hour will miss many defects
  • "The more defects the better!"

...

  1. Where is the asynchronous code review application?
    1. https://github.com/OpenMRS
  2. What should I do if I find something wrong during a personal or asynchronous code review?
    1. Assuming that this review is happening in Github, add a comment to the review at that line.
    2. We need to make sure that this is a constructive process. The reviewer should not slam or even poke fun at the developer. Code reviews are meant to be both constructive and instructive. Not all of us have the same level of understanding of the code, so please be kind. In addition, the developer should not be defensive about his/her code. If the developer disagrees with the reviewer (which is totally reasonable), that developer should state their case and ask other developers for their opinion.
    3. Clarify it. Send an email to the developer asking for clarification
  3. How do I request a code review?
    1. Go to the ticket on the JIRA board, click on request review, and Add the link to your pull request in the description section. Make sure you have claimed the issue first before you can do this. Set the status of the ticket to "Code Review (Pre-Commit)". (A ticket that's ready for work must be assigned to you first, so first make sure you click "Claim Ticket" to assign it to yourself.)
  4. What types of issues are we looking to capture during code review?
    1. See the Code Review Checklist.
  5. How much code should be reviewed in a single code review session?
    1. Ideally, less than 90 minutes without a break and less than 300 lines of code in one sitting