Betty Linter Style Guide For Alx

Victor OkaforVictor Okafor
3 min read

We kick off by understanding what a linter is, so a Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors, and suspicious constructs. In summation, continually employing the use of a linter makes your code easier to read and understand and ultimately makes it easier to collaborate on.

The ALX coding style(linter) is inspired mainly by the Linux kernel coding style but for your time at ALX and to avoid any confusion, please refer to the official guide for the ALX SWE program and not the Linux kernel coding style.

Some warnings and errors mostly encountered by ALX students

  • Indentation error: this occurs because you are not using the specified indentation which is 8 spaces for a tab you are to Use tabs to indent your code as Tabs characters will be counted as 1 character by Betty. For VScode simply look at the bottom right panel of the editor and find the select indentation button to effect the change, for other editors like Vim, Emacs, and Atom click the editors to follow through on it.

  • WARNING: adding a line without newline at end of file: this occurs when you don’t add a new line by simply hitting the Enter button after the last curly brace of the main function as shown below.

  • WARNING: no description found for function main: you will mostly get this error when you have not described your function in the comment section

    FUNCTION MAIN NOT DESCRIBED IN THE COMMENT SECTION

    so to get rid of this error, you will mention the function name main in the comment block so

  • ERROR: trailing whitespace: to fix this error you only have to go to the line referenced for the error and use the backspace key till you have taken out the extra whitespace. To totally avoid this error make sure to use the Enter key just after you are done with a line and you need to go to a new line.

  • WARNING: No description found for parameter or member 'c': this error occurs because in your function you have a parameter named ‘c’ and you have not described this in your comment section as so

    to fix this, you will have to include a description of the named parameter 'c' in the comment section above the function.

  • WARNING: Missing a blank line after declarations: this happened because you have declared variables like char c and int counter and on the next line you assigned them values like counter =o and c =’a’

    to fix you simply need a new line after the last declared variable and it solves it.

    💡
    As of the time this article was written, these were the major errors encountered by myself and these are not limited to the possible errors still to be encountered. This article will be occasionally updated as I encounter more errors and solve them so bookmark this to stay updated.
0
Subscribe to my newsletter

Read articles from Victor Okafor directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Victor Okafor
Victor Okafor