Fewer Errors with Continuous Integration and Code Analysis

As experience shows the quality of code degrades slowly and before you know it will be an unmaintainable mess. To prevent this many practices where developed and have proven their usefulness over and over again: test automation, continuous integration and code analysis are just a few of them. Unfortunately those practices still require work and just using them will not automatically keep your project on the happy path. Never less if you don’t apply them your chances are even worse.

Not long ago it was a lot of work to get a basic set of tooling up and running. With help of the cloud and GitHub as a hosting facility this is no longer true. With services like Travis CI continuous integration is just a few clicks away and the same goes for code analysis with Code Climate. And the best of all: If you have a public source code repository at GitHub you can have all this for free.

 

Continuous Integration

To start with Travis CI you need to sign in with your GitHub account. This will allow Travis CI to scan your repositories and with one simple click you can activate continuous integration for your repository. Behind the scenes Travis CI will use a commit hook that will trigger the build as soon as you push your next changes to GitHub.

Start with Travis CI

Inside your repository you need a .travis.yml file like this to configure your build environment:

Examples for Ruby, Python, PHP, Perl, Java, JavaScript and many more languages are explained in the documentation. From now on Travis CI will build your application on every push to GitHub and report a broken build within a few minutes.

broken build

 

Automated Code Review

Even simpler to configure is Code Climate. This service makes an automated code review for your Ruby and JavaScript code. All you need to do is add your repository and you are good to go – no account and no credit card are needed for open source projects:

Start with Code Climate

For a nearly empty project it is quite simple to get a 4.0 score. The challenge is in keeping it that way and quickly react if your classes fall from A to B (or even worse):

Changes in quality

 

Badges

As soon as these two services are working you can get a badge for your project page. This shows instantly how your project is doing and if there are any big problems. Whenever I search for a Gem those badges help me to decide if I should look at this project or another.

All you need to do is to select the appropriate code snipped from Travis CI and Code Climate, put it on your project page and keep them green:
badges

 

No Open Source?

In this case you can’t use the free services, but for both you can buy a plan. Code Climate starts at 99$/month and Travis CI at 129$/month. This seams a lot but think about how much it would cost you to get this kind of infrastructure running in your company. These services may not be that costly after all.

 

Conclusion

It never was so easy to get automated guards against a decline in the quality of your code. When you have an open source project you can get continuous integration and code analysis within a few clicks and for free. There really is no longer a reason not to use continuous integration and code analysis…

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.