How to improve code quality using GitHub Super Linter

 Background

As developers, we work on multiple programming languages like C#, Java, Python, JavaScript, SQL, etc. Apart from the mainstream programming languages, we also work with different file types like XML, JSON, YAML. Each of these languages and file types has their own styles and conventions. As a language or a format becomes mature, there are standards and best practices which get developed over a period of time. 

Nowadays, many developers are full stack developers or polyglot developers. As part of the Microservices style of development, they might work on the web or Javascript based front end, a Java, C#, Go, Python or some other programming language based middle tier. And then some SQL or NoSQL backend. Each of these components can use a different language. And each language will have its own style. It can be very difficult for new or even experienced developers to follow all the best practices for all the languages at the same time.

Linter to the rescue

A linter is a software or an add on which will help to identify issues in a file with respect to the rules or conventions. It is a static code analysis tool which helps to automate the process of validating common errors, bugs, style-related errors. Some of the Integrated Development Environments have built-in linters for the common programming languages. Visual Studio, for example, can suggest changes to classes and methods. External tools and extensions like Resharper can also help. One of the most popular code editors, Visual Studio Code has many extensions which are specific to a particular language like

I tried doing a search for Linter in the Visual Studio Code Marketplace and as of this writing, there are more than 200 linters available.


All these linters help in making sure an individual developer can follow the rules and styles correctly on their development environment. Things get tricky when we work in teams and multiple developers are working on the same project. Each developer can have their personal opinion. To avoid having multiple styles for the same codebase, it is necessary to standardize the rules across the whole team. 

These rules can then be automatically checked as part of the automated build process. All the modern day Continuous Integration (CI) systems like Azure DevOps, Jenkins, Bamboo, TeamCity, TavisCI etc. allow us to perform static code analysis. 

GitHub Super Linter

Github recently announced what they call the Super Linter. GitHub also allows us to trigger certain actions based on some conditions like source code checkin into a master or main branch or a feature branch. These are called GitHub Actions.

The Super Linter is a collection of more than 30 linters for some of the most commonly used programming languages. With one GitHub action, we can scan the whole codebase and identify any issues in a single go. If the team has its own set of predefined rules for a particular language, we can customize the defaults to use the team or organizational rules.

In the video below, we can see how GitHub Super Linter can be configured for your repository and triggered using GitHub Action.



Conclusion

As demonstrated in the video, GitHub Super Linter can be a great tool for automating the static code analysis. It can easily help to standardize coding practices across multiple languages for teams and organizations. It is very easy to set up and can help a great deal in DevOps practices. Hope you find this useful.

Until next time, Code with Passion and Strive for Excellence.
Share:
spacer

No comments:

Post a comment