Pull Request Review Guidelines
Reviewing other people's code is one of the most valuable contributions you can make to Bahmni (or to any open source code). You do not have to be a senior developer, or a core team member, to make a meaningful code review contribution, and doing a review does not necessarily mean you need to be the one to merge the code. Doing a partial review can still allow the contributor to iterate and improve the PR before a final review and merge happens.
Please see the Submitting Pull Request page for PR guidelines, which will help you to guide the requester
Before you (reviewer) start
- Is there a JIRA card created with description of the feature/issue and acceptance criteria articulated in the card?
- Is the PR marked with the right JIRA card number? When you merge, you must ensure that the JIRA card number is reflected in the commit msg.
- Are you the right person to review this PR? If not, try to direct to the right person. If you have partial context, try to find help from one who knows better.
- Are any checks (travis-ci, codeclimate) failing? If so, immediately request that the contributor look into this.
- Has the submitter signed the CLA? (See the status of the cla-assistant check.) If not, kindly ask them to do so.
- Ask questions, instead of making statements. Avoid “why” - which often seem accusatory, rather try to understand the context and reasoning … “what was the reason for ….”
- For bigger PRs, try to “meet” with the person. Often pairing on the PR review for big PRs is the best way. Bigger PRs are also best to merge onto a branch, run/check locally and then commit.
- You can follow github ‘Command line instructions’ suggestions to merge a PR locally before pushing onto master. Often for large PRs and in cases you can’t assert the correctness of the code without running it locally, this is a preferred approach. Just go the PR link in github; towards the end click “command line instructions” next to the “merge pull request” button and follow the suggestions.
- Lots of handy tools exists for code analysis - e.g. a Static Code analyzer with IntelliJ or Sublime
Guidelines on code
- Coding styles are important but should not be overbearing.
- The code must not break any existing feature during upgrades
- Data migrations if needed must be done so as to persist and keep working with existing transactional data.
- Configuration if introduced must have the previous behavior as the default, with options of extending/changing the behavior. Meaning, using existing configuration with new code does not require updates by any implementation. Configurations are documented and reflected with the release version indicated.
- Feature behaves, as much as possible, like before and is easy to pick up and preferably does not require retraining of end users.
- Unused code
- Don’t carry dead code, including commented off code is not useful and just baggage and often confusing. We use git anyways and all editors show a pretty good diff between versions!
- Duplicate code - maybe create another card?
- Encourage using Java 8 paradigms
- Use of closeable in try-with-resources
- Using streams
- Loops like “names.forEach”
- Lambda expressions
- DRY - don’t repeat yourself please.
- Loops have definite set length and correct termination conditions.
- Is the code performant? Has it been tested with enough representative data? (Ask the contributor to share what they've done, or test it yourself if you have concerns.)
- ROT code? - surely someone has come up against it? Use a known library if you can’t find already plugged in.
- SOLID principle
Essential Reviewer Guidelines
- Code reviews are a discussion not ‘dictation’/“orders”.
- The reviewer is equally responsible to the contributor - for correctness, design, security, readability and maintainability. Do not merge, and feel free to push back if you (reviewer) are not satisfied.
- It's fine if the contributor disagrees with your opinion, as long as he/she provides explanation that is logical.
- Direct the contributor to relevant code sections as examples to follow.
- Are there multiple commits that make it difficult to review or test locally? You may ask the contributor to squash into a single one, but remember that GitHub lets you "squash and merge", so you don't normally need to request this.
- Ensure there are corresponding tests for the PR relevant code
- Unit tests and Integration tests (if applicable) should be present.
- Does the code change something in the product that needs documentation (new or updates) in WIKI? - If so:
- mark the JIRA card accordingly by adding a "needs-doc-update" label
- ask the contributor to add the documentation (and verify that they include appropriate information like ‘applicable from version X’)
- Dependencies:
- Either to a library - ensure that the library is a well known and supported/latest one, is appropriate for the job, and there is no duplication (e.g. No Joda datetime library if it can be solved by Java 8 date APIs).
- To another module: Is the other module released? Discourage snapshot release dependency. In exceptional cases such snapshot dependency maybe allowed but ensure there is a JIRA card existence to resolve such dependency.
- Obvious: no circular dependency of components/services/codes
- If you (reviewer) discover a missing “acceptance criteria”, please update the JIRA card.
What to Review?
See JIRA for cards that need code review in the next release:
The Bahmni documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)