42School / norminette

Official 42 norminette
MIT License
926 stars 138 forks source link

Add a new user/beginner friendly errors system #505

Open NiumXp opened 2 months ago

NiumXp commented 2 months ago

Hi, this is one of my drafts (maybe 7 months ago) focused on beginners (and quality of life) that I wrote for norminette when @matthieu42Network was accepting my PRs, I'm not sure if he's still available, but recently it seems like new people became collaborators, this made me happy and willing to continue with contributions.

New errors formatting

To use the new format is not necessary a new configuration, just run your norminette:

(.venv) niumxp@DESKTOP-LRN507C:~/oss/norminette$ cat -A test.c
#define exit 42$
$
int^IMain(void) {$
^Ireturn exit;$
}$
(.venv) niumxp@DESKTOP-LRN507C:~/oss/norminette$ norminette test.c
test.c:1:1 INVALID_HEADER Missing or invalid 42 header
test.c:1:9 MACRO_NAME_CAPITAL
     1 | #define exit 42
       |         ^^^^ Macro name must be capitalized
test.c:3:5 FORBIDDEN_CHAR_NAME
     3 | int Main(void) {
       |     ^^^^ user defined identifiers should contain only lowercase characters, digits or '_'
test.c:3:16 BRACE_NEWLINE
     3 | int Main(void) {
       |                ^ Expected newline before brace
test.c:4:12 RETURN_PARENTHESIS
     4 |     return exit;
       |            ^^^^ Return value must be in parenthesis

I added a red color to the errors: image