Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc plugin does not respect ignores #64

Closed
SpencerC opened this issue May 21, 2024 · 3 comments
Closed

protoc plugin does not respect ignores #64

SpencerC opened this issue May 21, 2024 · 3 comments

Comments

@SpencerC
Copy link

SpencerC commented May 21, 2024

Given a proto:

version: v1
lint:
  use:
    - DEFAULT
  allow_comment_ignores: true
  ignore:
    - IMPORT_USED

And a buf.yaml

syntax = "proto3";

// buf:lint:ignore IMPORT_USED
import "unused.proto";
import "validate/validate.proto";

Running a buf_lint_test outputs:

--buf-plugin_out: file.proto:1:1:Import "unused.proto" is unused.
file.proto:1:1:Import "validate/validate.proto" is unused.
file.proto:1:1:Files must have a package defined.
unused.proto:1:1:Files must have a package defined.

It's definitely reading the buf.yaml file: use: -RPC_REQUEST_STANDARD_NAME causes all the errors to go away.

Reproducible example: SpencerC@e38bd77

Related: aspect-build/rules_lint#222

@srikrsna-buf
Copy link
Member

Hey! proto_library rules don't include the source code info by default, the comment gets stripped. There are two ways to solve this:

  • Use ignore_only to skip a rule for specific files. More on this here.
  • Add the build flag --experimental_proto_descriptor_sets_include_source_info. More on this here

@SpencerC
Copy link
Author

SpencerC commented May 22, 2024

Thanks @srikrsna-buf. --experimental_proto_descriptor_sets_include_source_info makes allow_comment_ignores work. However, there still seems to be a problem with ignore. When adding that flag to the example above, the errors appear when the buf:lint:ignore comment is present, but not when it isn't.

@srikrsna-buf
Copy link
Member

srikrsna-buf commented May 22, 2024

I think I see the issue, ignore is used to ignore files. Except is used to exclude rules: https://buf.build/docs/configuration/v1/buf-yaml#except, try:

version: v1
lint:
  use:
    - DEFAULT
  allow_comment_ignores: true
  except:
    - IMPORT_USED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants