Why should you lint your source code? And what is linting anyways?
A linter is best classified as a static program analysis tool. Casually, a linter or linting refers to tools that analyze source code to find potential logic fallacies, programming errors, bugs, stylistic errors, and suspicious architecture.
Certainly, most teams will find static code analysis via linting wonderful, as it reduces meatless comments on code reviews and pull requests when new commits or features are littered with problematic code. Linting your source code is also a way to enforce standards or prevent security problems and avoid potential performance issues.
Silicon Valley => Russ Hanneman => Linting
I like this clip from Silicon Valley where Russ Hanneman (the triple comma billionaire) uses his house-automation system to tell his son to brush his teeth and go to bed (at about 3 minutes and 37 seconds):
Monica, Erlich and Richard arrive at Russ’ house for a board meeting. Russ’ young son appears, and a voice on a PA system instructs him to go to bed. Russ explains that the system is called The Lady — a company he’s funding that tells his son when to go to bed, take a bath and so on. “I get to be his friend, and she’s the bad guy,” Russ says, with a smile. “I’ve disrupted fatherhood.”
– via HBO
Static Code Analysis: The Analogy
Hence the reason I like this clip: the boy knows that the dad is the one who pushes the button, and the dad loves to pretend that the house has told the kid to do it, not him — “I’m sorry buddy it’s not up to me”. The dad goes on further to say, “I’ve disrupted fatherhood”, in a way removing the tension and friction from being a father and putting it on the house.
As a father, I think this is hilarious. As a developer, I think this is hilarious. It’s the same idea as when an experienced person on your team creates the linter rules. A majority of your team agreed on the linter rules, and your team maintains the linter rules.
Therefore, as a team, you all become the house in this example. And as an individual developer on the team, you all become the child when you commit new code, because the linter will yell at you and say, “You didn’t put your curly brace in the right spot!”
Finally, when it comes to a developer’s day-to-day, they will know that the team decided to enforce the rule to put the curly brace there, right? The developer will have to adjust their code to follow the convention! You gotta follow the rules.
“I’m sorry buddy it’s not up to me”
Originally published at hyperpolyglot.io on November 2, 2018.