Code Inspector
Jul 1 · 4 min read

How you can continuously improve your software quality through automatic code review in your continuous integration pipeline.

Automatic Code Review from Code Inspector

Today, Code Inspector integrates even better with Github and surfaces code issues (defects and duplicates) from Pull Requests. When a Pull Request is being sent, Code Inspector compares the head and base branches and reports added or removed defects by the new code.

Validation results (positive or negative impact upon merge) are surfaced in the GitHub interface, as shown below. Any failure is explicitly shown in the Pull Request page and a detail link brings you on Code Inspector to see what are the defect being added or removed.

Code Quality Checks surfaced by Code Inspector in Github Pull Requests

Merge code only without defect by combining Code Inspector and Mergify

This new integration on Github brings the ability to integrate Code Inspector with Mergify, a Github application that automatically merge your code according to your rules (code is accepted by X developers, lints are passing, etc). Code Inspector can be a new rule for Mergify so that you stop automatically merging defective code.

For example, if you specify that Mergify should merge all code if the code contains less violations or duplicates, Mergify will then merge all code as soon as these requirements are met. No need to manually merge external contributions, Code Inspector and Mergify will make sure that only code without more defect is being shipped.

Code Inspector and Mergify integration: code without more defect is automatically merged

On the Pull Request page, you can see all the checks that have run and also notice that Mergify automatically merged the Pull Request. No more manual work needs to be done when contributions pass your quality requirements.

Automatic Merge of a Code Change by mergify once no duplicate or violation is detected

On the contrary, if any merging rule specified to Mergify is not met, Mergify will not merge the code and wait for the check to pass before merging. However, maintainers can override this workflow and decide to manually merge the new code.

Code Inspector and Mergify integration: if code has any defect, Mergify blocks the merge, ensuring only code with less defects than before is shipped.

How to use it?

Want to start shipping good quality code now? Follow these simple steps.

Add Project on Code Inspector

Start using Code Inspector and log on the platform using Github.

Create a project on Code-Inspector and add the github repository you want to use with Mergify. When adding the repository, Code-Inspector will install webhooks on your repository to be notified when a push or a pull request event is triggered.

That is all what you need: once the repository is added, Code Inspector will analyze your master branch when new code is pushed (to show quality trends of your code base) and analyze the quality of each pull request.

Sign up on Mergify

Install Mergify on your Github account and add the repository you want to automate.

Once Mergify is installed, add a mergify.yml file at the root of your repository. The full syntax of the file is available on mergify documentation, the basics of the file should look like the following block:

pull_request_rules:                         
- name: automatic merge when all checks pass
conditions:
- status-success=code-inspector/violations
- status-success=code-inspector/duplicates
- "#approved-reviews-by>=1"
actions:
merge:
method: merge

In the code block above, we automatically merge the code when the following conditions are met:

  1. There are no additional code violation introduced by the new code
  2. There are no additional code duplicate introduced by the new code
  3. The code has been approved by at least one person

Once all these conditions are met, Mergify will automatically merge your code.

Wrapping Up

Code Inspector is now integrating with more tools to help developers ship better code. The integration with Mergify is a huge win for maintainers: they can now focus on important issues (e.g. such as architecture problem and design decision) while other trivial aspects (syntax, coding violations, security issues, code duplicate) are automated with Code Inspector.

Keep in mind Code Inspector is still in beta — if you notice an issue, please contact us! We still have a ton of new exciting features coming in the next few months and we can’t wait to announce them soon!

Code Inspector Blog

Everything you need to know to improve the quality of your code and reduce your technical debt. Join the movement of high quality code: https://www.code-inspector.com

Thanks to Julien Danjou

Code Inspector

Written by

The best platform to find and manage #technicaldebt easily! Launch in 2019.

Code Inspector Blog

Everything you need to know to improve the quality of your code and reduce your technical debt. Join the movement of high quality code: https://www.code-inspector.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade