42School/norminette

Add optional compiler-style line numbering

gagero opened this issue · 2 comments

gagero commented

When either GCC or Clang detect a warning or error, they output the position in the file:line:column format. Supporting this in norminette would make it usable more so as a linter integrated into your editor rather than an external tool you run, since most editors already support this format (VSCode with the C/C++ extension and Emacs with compilation-mode for example).

Hey, @gagero! Sorry for late reply.

What about a flag --error-format=(json|humanized) to return something like:

{
    "files": [
        { "path": "/nium/norminette/ok.c", "status": "OK", "errors": [] },
        {
            "path": "/nium/norminette/error.c",
            "status": "Error",
            "errors": [
                {
                    "name": "INVALID_HEADER",
                    "text": "Missing or invalid 42 header",
                    "location": { "lineno": 1, "column": 1 },
                },
                {
                    "name": "NO_ARGS_VOID",
                    "text": "Empty function argument requires void",
                    "location": { "lineno": 1, "column": 10 },
                }
            ]
        }
    ]
}

The location is just an example and doesn't mean that it should be in the final version, as it doesn't contain much information about highlighting (necessary in an unterminated binary expression). Anyway, is it useful?

Yes, that'd be really useful.