Meet Betty, The C code linter

Meet Betty, The C code linter

ยท

2 min read

I need to make this clear - "betty frustrates me!".

Over the time though, I've learnt to avoid her and I'll tell you how, but first...

Who Is Betty

Betty is actually a very real person ๐Ÿคฏ, according to Wikipedia...

Frances Elizabeth Holberton was an American computer scientist who was one of the six original programmers of the first general-purpose electronic digital computer, ENIAC. The other five ENIAC programmers were Jean Bartik, Ruth Teitelbaum, Kathleen Antonelli, Marlyn Meltzer, and Frances Spence.

But seriously, this isn't the Betty we'll be talking about today. Betty is a Holberton-style C code checker written in perl.

Now there's some explanation needed for the above sentence, so I'll start with...

Holberton

Holberton is a computer science school founded in silicon valley (that's all you get ๐Ÿ˜ด)

Code Checker

Also known as linter. Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.

This means that Betty does not have to run or compile your C code before she detects potential errors and wrong styles.

Perl

It's just another programming language like C. Hold on! So Betty is basically a program in one language trying to detect errors in another language ๐Ÿคฆ๐Ÿพโ€โ™‚๏ธ


Now that you know Betty, how do you use Betty?

I'm assuming you already have Betty installed. If you don't, checkout the installation guide here

How to summon Betty

The usage is basically just

betty FILE...

Where FILE... means 1 file or more. Once you run Betty like this, Betty would enter each file you specified and do a series of checks. Here is a list of the things Betty checks for

  • Indentation

  • Length of each line

  • Placement of braces {}

  • Placement of spaces

  • Naming of variables, functions, structs...

  • Length of functions ๐Ÿคจ

  • Commenting

  • Macros & Enums

  • Header files

You can find exhaustive information on Holberton-style code here, so you don't fall a victim of Betty as I did ๐Ÿ˜‚๐Ÿ˜ญ

ย