Linters, What are they and why should you use them

Admittedly I had very little knowledge of linters until very recently. I knew of their existence and a basic idea of what they did but assumed they were hard to use and offered minimal results, but now I have seen the light and I must share.

So to start, what is a linter? I see a linter as a coder's version of spell check, but with a bunch of extra features. Linters check your code for bugs, styling, security breaches, and more. There are lots of linters available but since I’m a ruby guy I would like to look at a few ruby linters and talk about what they do.

The linter Brakeman is a Static analysis (meaning it checks your code by reading through it without actually executing anything) Security tool. It checks for SQL Injection vulnerabilities as well as XSS, config options, and more. These things can be hard to catch in your code on your own (especially if you're relatively new to programming, or web programming and don't have a thorough understanding of these attacks and how they are carried out or handled.

The linter Rubocop is another ruby linter, this checks for ways to make your code faster, or efficiencies in styling. It also helps with styling issues that don't follow the ruby styling guide.

Using these linters together can make your projects more efficient, more readable, and more secure. There are many more linters out there and taking the time to explore for some good ones can save you time down the road as well as make your code better. They are often easy to run, with rubocop being as simple as installing the gem and running one short command in the directory of your project.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store