-
Notifications
You must be signed in to change notification settings - Fork 344
Description
Feature
Hello,
I'm attempting to detect and automatically remove unused imports in proto files.
The context that I'm working in is a build system similar to bazel (https://please.build/).
Currently, I'm able to use protoc-gen-buf-lint to detect unused imports. However, the current method puts a burden on developers to manually fix the linter violations despite it being conceptually trivial for these fixes to be automated.
My plan for automatically fixing the unused imports is to:
- Write a build rule which uses protoc-gen-buf-lint to find unused imports and write those violations to a file.
- Read that file in an independent tool that removes any unused imports (which runs as a hook before each PR is raised).
To achieve step 1 the build system requires protoc to:
- Exit with a non-zero exit code (provided it runs with no exceptions, whether it detects linter violations or not)
- Write the linter violations to a file (in the same way that the protoc plugins associated with a language write the generated code for that language to a file).
I see that configuration for modifying the exit code was previously discussed in #699 and dismissed due to limited use cases. Perhaps it could be worth revisiting this decision given this new use case?
Any advice on how to achieve this outcome would be greatly appreciated - thank you!