42School / norminette

Official 42 norminette
MIT License
956 stars 140 forks source link

feat: add --format flag and *ErrorsFormatter classes #482

Closed NiumXp closed 8 months ago

NiumXp commented 9 months ago

I'm adding a rich way of handling errors to format it as "short" (currently), "verbose" (with highlights and hints, like GCC does on errors/warnings), or others like JSON (#448).

Example of errors in JSON format:

norminette test.c --format=json
{
  "files": [
    {
      "path": "/home/nium/OpenSource/norminette/test.c",
      "status": "Error",
      "errors": [
        {
          "name": "INVALID_HEADER",
          "text": "Missing or invalid 42 header",
          "level": "Error",
          "highlights": [{"lineno": 1, "column": 1, "length": null, "hint": null}]
        },
        {
          "name": "SPACE_AFTER_KW",
          "text": "Missing space after keyword",
          "level": "Error",
          "highlights": [{"lineno": 3, "column": 5, "length": null, "hint": null}]
        }
      ]
    }
  ]
}

Some considerations (just for now):