The goal of this program is to create a tool that will check EPITA C norme. The non respect of this will result with a 0 mark, so having an automated tool to check it is really useful.
The respect of this goal mean that their must not have ANY false negative (No errors were found where it should have): if a goal passe all test then it RESPECT the rule. That mean that this norme-checker is allowed to have some false positive (The checker detect an error when it shouldn't).
Some [norme] rules might depend on more than one [checker] rule to work. Some [checker] rules might depend on another to detect all errors.
An extract of this norme can be found here. Note that this is an old norme, and new rules might have been added
- Usable in command line.
- Check all content of a directory at once, or only some file.
- Pointing the exact place where errors happened.
- Checking a file will display all current errors, it doesn't stop at the first rule that found errors.
- Detecting if a file have been included more than once. In this case, it will be processed has many time as mentionned.
- Detecting if code langage is in english and no other langage is used.
- Detecting unused function (use your compiler).
- Detecting if composite names are separated with underscores.
- Basic rule trait.
- Reading a file and checking its norme.
- Reading all contents of a directory.
- Multiprocessing rules check (useful for big project).
- Correcting file to match norme.
- No more than 80 characters per line (including newline character).
- No trailing whitespace.
- All braces must be on their own line.
- The goto statement must not be used.
- Static variables must be constant.
- Global variables must start with 'g_'.
- The pointer symbol '*' must appear next to the variable name, not the type.
- One declaration per line (in function, structure, enum or union).
- One statement per line.
- Structures and unions must be passed by address in functions.
- Space instead of tab.
- The text between brace must be indented by 4 spaces (could be 2, but 4 is choosen for personnal preference).
- Closing brace must appear on the same column at the corresponding opening brace.
- Semicolon must be followed by a newline and must not be preceded by a whitespace, except if alone on a line.
- Comma must be followed by a single space, except if it's the last non white character of the line (and not precedeed by whitespaces).
- All binary and ternary operator must be padded on the left and right by one space, including assignement operator.
- Structure and union fields must be aligned with the type name.
- Multiline comments delimiters must appear on their on line.
- Multiline comments intermediary line must start with **
- Preprocessor directive must appear on the first column.
- Preprocessor directives following '#if' and '#ifdef' must be indented by one character.
- '#else' and 'endif' must be followed by a comment describing the corresponding initial condition.
- When macro must span over multiple lines, escape line break ('\') must be aligned.
- Macro names must be entirely captitalized.
- Macro arguments must be capitalized.
- All #include directive must appear at the start of the file.
- System header must appear before local one. In header (.h) file only.
- Headers must be protected against multiple inclusions. See official norme for more info.
- Function's body must not contain more than 25 lines (excluding comments and blank line).
- Function's subpart have to be separated one blank line maximum (No two following blank line, excluding comments).
- Function must not have more than four arguments.
- There must be at most five exported functions per source file.
- There must be at most ten function per source file.
- Function prototype must only be located in header (.h) file.
- If function arguments are split over multiple lines, they must be aligned.
- No whitespace between function and the opening parenthesis.
- Enumerations values must be entirely capitalized.
- Enumerations values must appear on their own line.
- Control structure keywords must be followed by a whitespace (including return, but only with arguments and sizeof).
- return (without argument), continue and break statement must be followed directly by a semicolon.
- All switch conditions must ends with 'break' or 'return'.
- Switch must contains a 'default' block.
- Switch must only be used with enumeration.
- Each 'case' conditions must be indented from the switch once, as well as the code following the 'case' from it.
- Structures names must be prefixed by 's_'.
- Unions names must be prefixed by 'u_'.
- Enumerations names must be prefixed by 'e_'.
- Basic type aliasing must start with 't_'. 't_' alone are prohibited.
- If the type already have 'e_', 'f_', 's_', 't_', 'u_' as prefix, it has to be keep.
More rules to be added later...