develop branch without a formal review, it’s still advised to have these changes reviewed to uphold our quality standards.
Types of Reviews
We have three ways to review code at Trew Knowledge:- External Reviews look at plugins from outside sources we’re thinking of using.
- Internal Reviews check our own code before it goes live.
- In-Depth Reviews take a closer look at complicated features.
- We’re tougher on code quality in internal reviews but focus more on checking for security and how well something runs in external reviews.
- Even though we trust our internal code more, we still don’t compromise on checking its security and performance.
Factors to Review
Security
Security tops the list when we review code. Every piece of code, whether for production or staging, needs to be ironclad in terms of security. For detailed instructions on how to keep your code secure, refer to our frontend security and backend security standards.Performance
Performance matters a lot because of the size of the sites we handle. Figuring out if something is performing well can be tricky, and usually, it’s up to the person who wrote the code. But, checking performance is also important for the reviewer, especially with external plugins that might not be built for speed. To get more details on what to look for, check our guidelines on frontend performance and backend performance standards.Accessibility
Our work should be usable and accessible for as many users as possible. Reviewers should check for obviously inaccessible patterns. For specific guidelines, consult the accessibility best practices.Style
Code reviews should usually check that coding style matches our coding style guidelines. If someone is intentionally ignoring a guideline, that’s fine too. Internal reviews are typically the only ones that need style checking, as we’re not responsible for external plugins. The exception to this is if we’re specifically asked for it. Style checks should mostly be automated, as it’s easy to miss when writing or during a review.Behaviour and Logic
When it comes to code reviews, we’re usually not looking at the code’s actual behavior. The idea is to check the work, not redo it. But, if you’ve got some complex logic and want a second pair of eyes, just say so in your pull request. It’s way better to be safe than sorry, especially if there’s a chance something might not work as intended. The best people to ask for these thorough checks are your teammates working on the same project. They’re more likely to quickly understand if the code does what it’s supposed to. If you’re making changes to how things look on the site, throw in a before & after screenshot or a screen recording in your pull request description. It helps the reviewers see what’s changing and keeps everyone in the loop about new features or user interactions. For screen recordings, if you’re on a Mac, you’ve already got the tool built-in.Automated code reviews.
- All projects should use the WordPress-VIP PHPCS standard. The easiest way to install phpcs and the ruleset is using Composer.
- Some projects use CircleCI or Github Actions to run coding standards checks.
- All automated checks should pass before requesting a code review from a human.
Requesting a Review from a Human
When your code is ready for review, it’s up to you to request the review. Generally is handled via aNeeds Review or a Review & Merge label.
Reviewers are expected to approve, reject, or comment on the pull request. Try to keep all communication in the pull request itself, so everyone can see what’s going on. If the reviewer is not sure about something, they will ask for clarification.
Use Needs Review when you’re ready for a review but don’t want to merge yet. Use Review & Merge when you’re ready for a review and want to merge as soon as it’s approved.