regal
regal copied to clipboard
Inconsistent JSON output on errors
Hello
Let's say we have file test.rego with following content,
package test
default allow := true
Running regal
with JSON format regal lint --format json test.rego
- the successful output will be
{
"violations": [],
"summary": {
"files_scanned": 1,
"files_failed": 0,
"rules_skipped": 0,
"num_violations": 0
}
}
Let's introduce a syntax error into test.rego
, so it becomes
package test
def ault allow := true
Running regal
with JSON format once again gives inconsistent output
error(s) encountered while linting: errors encountered when reading files to lint: 2 errors occurred:
test.rego:3: rego_parse_error: var cannot be used for rule name
test.rego:3: rego_parse_error: var cannot be used for rule name
The inconsistency is that error format is not JSON. It makes a difficulty when creating Editor/IDE plugin that tries to parse JSON for the list of error. Since in this case there's no JSON and error has no predefined format.