-
Notifications
You must be signed in to change notification settings - Fork 288
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
Add configuration option to enable inline comment-driven ignores #63
Comments
Run We disable the comment ability as this would allow individual developers in large organizations to disregard lint rules, which defeats the purpose. We could theoretically have a mode where we enable comment ignores as an option through the config, but I’m not sure why the above doesn’t work? Let us know. |
It doesn't really work in a large repository where the generated file is thousands of lines long and it's a pain to modify it because:
Ultimately I like the idea, but it doesn't pass the reality check. |
Allowing comment ignores causes the exact same issue - it allows new bad code to not be rejected, except with no visibility at the top-level.
What IDE would be slow for a 1000-3000 line YAML file?
Not sure this would be that bad, and allowing comment-driven ignores is a bigger issue (in that it in effect defeats the purpose of the linter).
It takes 0.8s to lint all 2300 files in googleapis on a four core laptop, how many files are we talking here? |
We didn't make this decision without experience, in fact it was based on our real-world experience seeing comment-driven ignores effectively turn off enforced linting, resulting in inconsistent (and often incorrect) Protobuf usage across teams. Despite any downsides (merges, for example), |
Unfortunately Still, I don't understand the issue here. Developers can just not enable the linter altogether and be done with it. As long as developers want the linter you can be sure they will use it. In my case I'm building the tooling and it's up to each individual team to use it or not. In any case, of course it's your decision, thanks for a prompt reply! |
We can consider enabling it in the future as an option if you'd like - I can see some developers wanting it, although it's extremely not recommended. I'd really encourage trying out the Happy to rename this issue to be something like "enable option to allow commen-driven ignores", because then at least, a Protobuf monorepo owner can have their top-level OWNERS file disallow modifications to the |
I do indeed use Bazel and I indeed can't force everyone to use the linter. In fact, I need to provide a tool for each team to configure it as they wish but with recommended defaults. We try not to be authoritarian in that respect :) |
Are you looking for something like: // buf:ignore MESSAGE_PASCAL_CASE
message who_uses_snake_case_for_protobuf {} Feel free to propose an alternative format, this is what makes the most sense to me though. Re: authoritarianism with linters - our opinion is there are way too many options available, and creativity in your APIs should not come down to style, instead the creativity should come in the design. And we want to encourage this behavior. We thought that the |
Looks perfect! One important feature here is that a user should be able to run the build, parse the errors and generate the comments to send out in a few PRs. For some more context, we have some weird proto-like DSLs that are not really protos but use protoc for parsing the DSL. It's a big mess, but saves many-many klocs of boring code without creating a zoo of DSLs. One size can't really fit all :) |
I'm in the middle of a 10000 line refactor on the internal repo (this repo is actually just a mirror of the public code in the internal repo), so I'll keep this in mind and see how hard it is to add. Knowing the codebase, it's likely trivial actually. One note - we're likely going to add a required |
Good idea! Thanks for the warning! Although you could just say that the default version is the current one and that won't be a breaking change any more. I'm assuming you can make |
Yea that is an option, although if we do that, then new users who don't have a config file yet will always get the beta rule set. It's a tough spot, but we figure since we are technically beta, it's fair to ask users for this single change, so that we don't have changes in the future - we don't think it's fair that linters change their rules sets on upgrade (which happens all the time), you should be able to rely on buf producing the same errors now as in 10 years. FYI (note for us), we likely want to make the comments scoped to the linter, i.e.: // buf:check:lint:ignore MESSAGE_PASCAL_CASE So we could theoretically add comment controls for the breaking change detector (or other functionality) in the future. |
Personally I'm listing all rules explicitly anyway so unless you delete them I won't be affected at all. |
@Monnoroch see #73 There's instructions in there, I will keep them updated. We need to:
To install:
Or in your case:
Let me know what you think. |
Thank you, will definitely try it out! |
Test added, you can see the file for now at https://github.com/bufbuild/buf/blob/comment-driven-ignores/internal/buf/bufcheck/buflint/testdata/comment_driven_ignores/a.proto |
@Monnoroch I think this is ready to go now, the open questions:
|
I'm happy with your naming choices. A few small suggestions though:
Love the comment in the test file though xD |
Interesting, I think we want to keep it simple for now though, it’s easier to add things later than take things out |
Could be open to extending later? On the specific suggestions above:
|
Of course, please treat those as feature requests to be implemented whenever.
|
Ahhh got it. Ok, both interesting and valid cases for sure. Let us think about em - I think what we will do is get the PR as is merged, do a release, and sit on those for a bit? Want to think about it for a bit. Also I think the option should be allow_comment_ignores now, thoughts? |
LGTM on all fronts :) |
This is published as v0.15.0, and the documentation on the website is updated! |
Thank you for such a quick response! |
We would generally want to be quicker haha, feel free to email dev@buf.build if you want to discuss more! |
Documentation says
While I understand the reasoning, I still suggest reconsidering. For example I just finished integrating
buf
checks in a code base which is a large monorepo. Most protos conform to almost all checks, but for most checks there's a few proto files that don't. Of course I could fix everything (actually sometimes that's impossible, but okay), but that would involve a ton of work. The yaml solution is far from perfect as every time the config changes the whole repository needs to be re-linted rather than just one proto file that has changed. Not to mention a huge config with all the checks and files needs to be created and maintained. I would prefer to silence those places and create issues for maintainers to fix whatever is possible at their own pace. Instead I have to only enable a couple of very basic checks for the whole repo. Which means most of new bad code will not be rejected, so while existing issues are being fixed new ones will pop up.As you can see, while principled, the no-comments approach is far from practical as it makes it impossible to implement
buf check
in a large repository in a meaningful way.The text was updated successfully, but these errors were encountered: