bazel-contrib / bazel-contrib/buildtools
buildifier is still printing errors to stderr even when `-format json` is used
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 471
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 13
Description
Given an invalid `BUILD.bazel` file:
```starlark
Bad syntax
```
When running `buildifier as follows I get:
```bash
$ buildifier -lint=warn -mode check -warnings=all -format json BUILD.bazel
BUILD.bazel:1:11: syntax error near syntax
{"success":false,"files":[{"filename":"BUILD.bazel","formatted":false,"valid":false,"warnings":[]}]}
```
Right now the users attempting to write a parser for `buildifier` output have to write two parsers:
* One for `stdout` that would be in JSON.
* One for `stderr` that would be plain text.
This does not make it easy for users to write one. I would assume that most of the `syntax` error information could be surfaced to the user to provide easier to parse diagnostic messages.
For what people have to do currently, see https://github.com/mfussenegger/nvim-lint/pull/335
Contributor guide
Research direction
Start with the buildifier command and its handling of invalid BUILD.bazel input, then reproduce the shown -format json invocation. Trace where the syntax diagnostic is emitted and how the JSON result is assembled. Done means invalid-file diagnostics are represented consistently in the requested JSON output rather than requiring a separate plain-text stderr parser.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system, cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100