-
Notifications
You must be signed in to change notification settings - Fork 0
Code reviews
In this document, we'll cover:
- They make future upkeep easier by ensuring everything adheres to our coding standards
- They can catch potential issues before a client sees them
- They're a great way for you to learn how you can improve your code next time
- You can open a pull request at any time, but please wait to assign a reviewer to your request until you're ready for feedback.
- Try to keep pull requests small - fewer than 400 lines changed if possible.
- You can ask for feedback at any time, and you can continue working while the review is going on as long as your changes are small - things like bug or CodeClimate fixes. Don't add new functionality after assigning someone to review.
- If you need to keep working while waiting for review and you're dependent on that branch to move on, it's okay to make a new branch off the branch that's currently in review.
- Work to resolve CodeClimate issues where possible, but don't go out of your way to resolve issues that are impossible or don't make sense. The reviewer will manually approve issues that you can't resolve.
- If you see a CodeClimate issue that isn't your fault due to WordPress standard, an outside API, Responsive templates, or any other situation that's out of your control, explain the situation and ask your reviewer to manually approve.
- Code reviews can proactively catch bugs, but ultimately it is your responsibility to test your code. When you merge into master, especially on a site that's already launched, that is your promise that you've tested your code thoroughly and it is bug-free and ready for production use. Reviewers are not responsible for testing your functionality.
- Code reviews are very time sensitive and often close to deadlines. Do your best to do the review within the same day or find someone else who is able to review in a timely manner if you can't.
- Code reviews are meant to be relatively quick, but don't rush them. Reviews tend to take anywhere from 5-60 minutes, with most reviews taking around 15 minutes. If your review is taking more than an hour, talk with the designer or developer about reducing the size of their pull request.
- Watch for things a computer can't catch - better ways to do things, things going off standard, and potential bugs or security issues.
- Do your best to get your feedback in a single review. Don't request changes multiple times unless absolutely necessary.
- Be mindful of times where code is out of the developer's control, and manually approve CodeClimate issues where necessary. If the issues are extensive, but entirely due to outside factors, don't worry about approving individual issues, just approve the entire thing.
- When a change is critical and can't go out to a production site, mark your review as "Request changes".
- If you know the UI or meta name has to change due to a client need, mark your review as "Request changes" so the client does not begin entering content into UI that may change and lose their data.
- If you are uncomfortable with a change going out as is, and neither of the above rules are true, consider approving with comments, but encouraging the author to open a new pull request with your suggested changes. You can file an issue as well so they don't forget and link to your original feedback. Always check with the author on deadline and timing before marking "Request changes" on this type of feedback.
- If the code is functional, but there are small style improvements or suggestions for next time, mark your review as "Approved" and leave comments so the author can tackle as many of the improvements as are reasonable for their current timeline.
- If you are happy with everything, mark your review as "Approved". Never leave a comments-only review without explicitly approving or requesting changes.
- It's not required for you to review code outside your realm of expertise, but it's encouraged for you to take a quick look if you have time, especially if it's code that affects your review.
Each code review will be slightly different due to varying project timelines and budgets. If you have any critical items, you should fix those as soon as possible in your theme. You may also have some suggestions, or topics to look at if you run into a similar problem later. These are changes that you can choose to incorporate or ignore at your own discretion. While you may choose not to deal with these items in the theme you're working on now, it's highly recommended you keep them in mind and give them a try next time.
# Code review checklist
This is the checklist we use to do code reviews. If you keep it in mind as you build your theme, you'll have fewer items to fix at the end of the project.
- Images are properly named
- Images have been properly sized and compressed for web
- All assets use https (no http!)
- Code follows Responsive Framework coding standards for Sass
- Making sure to use Sass placeholders instead of includes
- Utilizes built in classes (
col-md-6, col-md-half
) instead of hand-coding widths - Utilizes mixins, includes, and variables properly
- Code is readable, clear, and uses common patterns
- Code is well-formatted
- Comments are properly formatted
- Declarations are ordered consistently and sensibly
- Sass
@extend
and@include
are grouped at top
Tip: You may be able to automate formatting in your code editor. CSSComb is one tool that allows you to do this, and is available for Sublime Text 2. These handy JSON settings will cover all code formatting needs except for grouping @extend and @include and comment formatting.
There appears to be a Coda plugin for CSSComb as well. This hasn't been tested in our environment - explore at your own risk.
- Class and ID names follow all naming conventions
- Sass is nested up to one level deep, except for pseudo-classes
- Code avoids specificity where possible
-
z-index
is managed through variables - Code uses variables appropriately
- Code uses placeholder classes (
@extend
) appropriately (static repeating CSS rules such asclearfix
apply here) - Code uses mixins (
@include
) appropriately (dynamic repeating CSS rules which need flexibility to take a variable, such astransition
, apply here)
- Code is readable and easy to understand
- Code is clearly organized, with like rules grouped together
- Code is divided into well-named partials that make sense for the project needs
- Code effectively uses
@extend
and@include
to reduce repetition and abstract common sets of rules
Whoever is reviewing your code may also choose to make additional suggestions on style, best practices, or architecture at their discretion.
- Code follows Wordpress coding standards for JavaScript
- Code follows Wordpress coding standards for PHP
- Code follows additional Responsive Framework standards for PHP
- Code follows file naming conventions
- Code is appropriately follows
functions.php
guidelines (https://github.com/bu-ist/responsive-framework/wiki/Functions-Guidelines) - Code follows Responsi Framework file naming conventions (link)
- New line issues (don't create new lines after
?>
) - If using CMB2: defaults are set on all metaboxes which aren't checked by an if statement on output
- Coming soon: Appropriate unit tests have been written and theme passes
All of the above, plus:
- CSS generated by plugin or framework uses default responsive breakpoints
- Code is extensible where designers may want custom functionality
- Variables are available in the Sass for this feature for colors, fonts, and other CSS properties a designer is likely to want to change
- All variables that are declared are actually used
- Code / classes are properly scoped: it should be clear from naming there will be no interference with a theme or other plugin CSS
Get started
Configuration
Build child themes
- Customizing CSS in a child theme
- Overriding templates in a child theme
- Code patterns
- Code reviews
- Pulling in Foundation Updates
- Merging and Creating a Pull Request
Sass
Javascript
PHP
- Coding Standards
- PHP Constants
- Temp PHP Code Patterns
- PHP Snippets
- How to Use Hooks
- Action Hooks
- Using Action Hooks To Output Markup
- Filter Hooks
Shortcodes
Templates
GitHub
Tasks
Contribute to the framework
- Framework Development and Release Workflows
- Documentation Template
- Testing your changes
- Creating a new release
- Migration Guide
- Needs Documentation
Code Examples
- Adding Content Container Classes
- Adding News Templates
- Adding Script Dependencies
- Changing Available Layouts and Default Layout
- Displaying a Fancy Gallery
- Loading a Custom Build of Modernizr
- Loading Modernizr in the Footer
- Using Action Hooks To Output Markup
- Understanding get_template_part
BU Developer Resources