-
Notifications
You must be signed in to change notification settings - Fork 22
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
Sharing Clippy lints with 3rd party crates #1057
Comments
Thanks for your kind words. And I am a fan of
I'm not sure there is a good answer to this. One could publish a library that constitutes the bulk of the lint's logic, and then the third party could add whatever else was needed to complete it. But it sounds like you are looking for something more than that. Could you maybe share the kind of answer you were hoping for? Would it not make sense to have just one lint that handles a set of known third-party crates? You mentioned Aside: I may send further replies from a different account. |
IntelliJ for C# has solved it with a custom attribute ( [StringFormatMethod("message")]
void ShowError(string message, params object[] args) { /* do something */ }
void Foo() {
ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
} In theory, all rust macros that behave like In Rust, we cannot have an attribute without declaration, so I am not sure what the good solution would be... Perhaps work with the core lib to add it there? |
To be sure I understand, you're imagining that a third party maintainer would an annotation each relevant macro in their package? |
@smoelius1 ideally, rust-lang/rust-clippy#9948 should "just work". But people did bring up a lot of corner cases where suggestions might be incorrect... Hence, I was wondering if this is something each lib author can optionally help with. Still, not ideal, so just thinking out loud. |
I think I'm getting lost on the thread here. I see that there have been updates to rust-lang/rust-clippy#9948 since this issue was opened. Is it still possible Dylint could help you? If so, how? |
Thanks for a great tool! I created uninlined_format_args Clippy lint that works on the core library's
format!
and similar macros. There are also a few other similar format-focused lints, but they all focus just the core lib. The same lint should be usable on numerous 3rd party crates like log - crates with macros that mimicformat!
behavior. Sometimes 3rd party crates add a few arguments before the format string likeinfo!(razor = razor; "Razor located {foo} {}", bar(10));
Is there a good way for 3rd party crates to support the built-in format lints without the complexities of implementing such lints from scratch? The code is obviously non-trivial, so it would be a huge task for each format-using crate to re-implement it.
The text was updated successfully, but these errors were encountered: