0Pricing
DevOps Bootcamp · Lesson

Code Reviews & Approvals

Explore best practices for conducting thorough code reviews and utilizing GitHub's approval features.

Code Reviews & Approvals is a free DevOps Bootcamp lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Code Reviews Matter

Code reviews are a cornerstone of modern software development. They are a systematic examination of source code by peers to find and fix mistakes overlooked in the initial development phase.

The main goals include:

  • Improving Code Quality: Catching bugs, security vulnerabilities, and design flaws early.
  • Knowledge Sharing: Spreading understanding of the codebase across the team.
  • Mentorship: Senior developers can guide juniors, and everyone learns from different perspectives.

The Code Review Process

On GitHub, the code review process typically follows these steps:

  1. An author creates a Pull Request (PR) with their changes.
  2. The author assigns or requests reviewers.
  3. Reviewers examine the code, leaving comments and suggestions.
  4. The author addresses feedback, pushing new commits to the PR branch.
  5. Once satisfied, reviewers approve the changes.
  6. Finally, the PR is merged into the main branch.

Elements of a Great Review

A good code review isn't just about finding bugs; it's about improving the overall health of the project. When reviewing, consider:

  • Correctness: Does the code do what it's supposed to? Are there edge cases?
  • Readability: Is it easy to understand? Are variable names clear?
  • Maintainability: Can others easily modify or extend this code later?
  • Performance: Are there obvious inefficiencies?
  • Security: Does it introduce any vulnerabilities?

Reviewer: Constructive Feedback

As a reviewer, your feedback should always be constructive and respectful. Remember, you're reviewing the code, not the person who wrote it.

Tips for giving feedback:

  • Be specific: Point to exact lines of code.
  • Explain the 'Why': Don't just say 'change this,' explain *why* it should be changed.
  • Suggest solutions: Offer alternative approaches or code snippets.
  • Be kind: Use polite language and assume good intent.

Using GitHub's Review Tools

GitHub provides powerful tools to streamline the review process:

  • Line Comments: Click on a line in the 'Files changed' tab to add a comment directly.
  • Suggestions: You can propose specific code changes that the author can apply with a single click.
  • Summary Review: At the end, you can submit a summary review with a 'Comment', 'Approve', or 'Request changes' status.

Suggestions are especially useful for small, clear improvements:

// Original Code
- const count = 0;
+ const initialCount = 0; // Better name

Author: Responding to Feedback

If you're the author of a Pull Request, responding to feedback is crucial. It shows you're engaged and committed to improving the code.

When addressing comments:

  • Acknowledge: Reply to each comment, even if just to say 'Good point!' or 'Done'.
  • Make Changes: Push new commits to your PR branch. GitHub automatically updates the PR.
  • Resolve Conversations: Once a comment is addressed, mark it as 'Resolved' on GitHub.
  • Ask Questions: If you don't understand a suggestion, ask for clarification.

GitHub's Approval System

The 'Approve' status is a clear signal that a reviewer is satisfied with the changes in a Pull Request. Many repositories are configured to require at least one (or more) approvals before a PR can be merged.

An approval indicates that the reviewer believes the code:

  • Meets the requirements.
  • Is well-written and maintainable.
  • Has addressed all significant concerns.

It's the green light for integration!

Requesting Changes

Sometimes, a Pull Request needs more work before it can be merged. In such cases, a reviewer can choose 'Request changes' as their review status.

This status clearly communicates that:

  • There are blocking issues that need to be resolved.
  • The PR cannot be merged until these changes are made and the reviewer gives a new approval.

Use this option when the issues are significant and prevent the code from being acceptable.

Code Review Best Practices

To make the most out of code reviews, both authors and reviewers should follow some best practices:

  • Keep PRs Small: Smaller PRs are easier and faster to review.
  • Clear Descriptions: Authors should provide detailed PR descriptions and context.
  • Be Prompt: Reviewers should try to review quickly; authors should respond promptly.
  • Automate What You Can: Use linters and automated tests to catch simple issues before review.
  • Learn from Reviews: See every review as an opportunity to learn and improve.

Quick Check: Good Review Practices

Based on what we've learned, which of the following are considered good practices for participating in code reviews?

Recap: Mastering Code Reviews

You've explored the world of code reviews and GitHub's approval features! We covered why reviews are vital for code quality and knowledge sharing, the typical review flow, and key elements of good review practices.

Remember to always provide constructive feedback, utilize GitHub's tools like suggestions, and follow best practices for both reviewing and responding to feedback. Approvals and 'Request changes' are crucial signals for managing your PRs effectively.

Keep practicing these skills to become a valuable collaborator!

Frequently asked questions

Is the “Code Reviews & Approvals” lesson free?

Yes — the full text of “Code Reviews & Approvals” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.

What will I learn in “Code Reviews & Approvals”?

Explore best practices for conducting thorough code reviews and utilizing GitHub's approval features. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Code Reviews & Approvals” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Creating & Reviewing Pull Requests
  2. Forking Workflows on GitHub
  3. Code Reviews & Approvals
  4. Draft PRs and Pull Request Templates
← Back to DevOps Bootcamp