-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[epic] Improve lint config discoverability #9880
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
Comments
I agree that config values are a bit hard to discover for users. Maybe I would restrict the message a bit more to only add the note, if the configuration would have potentially suppressed the emission. My main fear with this addition is that the output becomes overwhelming. We could also add a config value to suppress the config message ^^ I know that you added a message on Zulip, but let's ping everyone here again @rust-lang/clippy Maybe also @kraktus since they've been quite active lately and might also be interested or have some thoughts (Hope it's okay that I pinged you) |
I think most lints don't start well balanced -- either they don't show as often as developers may want them to, or they are shown too much. If the proposed hints only reduce the number of notifications, it defeats the purpose of discoverability - a way for users to start using new features they may want. We do not have a way to grow lint usage, so we never know if a lint is not used because it's not helpful, or because users never discovered it. Having a way to advertise for both increase and decrease of notifications, we allow the lint ecosystem to be more flexible:
Lastly, lets clarify the impact. We are talking about a single line of text. At the bottom of a suggestion that's usually 5-20 lines long. Shown just once in the entire output, even if there are tens of suggestions. Shown next to the line that users tend to read the least - info on how to disable the lint itself. So overall I think this is the least invasive way to help users discover new functionality they often would find useful, compared with the benefits it provides to the developers. |
Every lint gets a message attached that tells the user where the lint level was set, when the lint is first emitted. This is done by This will only be a one-line help message in the terminal. So as an "easy" first step we can just emit it for every lint that has a config, no matter if the config was already set or not, but only emit it the first time the lint is emitted. Excluding I think this is a good idea. I would recommend to do this in |
This one we plan to address with |
I want to put it into utils, so that we don't have to remember to include it into every lint emission of a lint with a config. This will get really hard to maintain. Reviewers would need to remember that this has to be included and we would have to keep the emitted message consistent between lints. We could write an internal lint for it, but I would rather put that effort into solving this problem in |
@flip1995 I might be misunderstanding your suggestion. Clippy lints currently use Note that I am fairly new to clippy codebase, so please do ignore if this is irrelevant or simply a misunderstanding on my part.
|
Sorry, I can see that what I'm suggesting doesn't make sense, if you're not familiar with our So, you might have noticed, that Clippy emits a link to the lint documentation, when emitting a lint. This is handled in rust-clippy/clippy_utils/src/diagnostics.rs Lines 17 to 29 in 51ec465
This function is then called by each of the functions, that you listed above, see for example rust-clippy/clippy_utils/src/diagnostics.rs Lines 48 to 53 in 51ec465
We could do the same for the config note. Just create a function that does something like this: fn config_note(lint, diag) {
if has_config(lint) { // <- implementing this function will be the hardest part, design-wise
diag.note_once(...);
}
} And then just add a call to this function for every |
We could additionally try to add a new section to the book or our lint list, which lists all config values. The metadata collection monster already collects all the information. We would just need to figure out if such a representation is helpful and where to put it :) |
I think the book is a great place for this list of configuration values. |
For future reference, this issue has been discussed in our meeting today: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202022-11-29/near/312808259 |
Here is a summary:
|
@flip1995 Could you explain the difference of the last two points 😅 |
The default config would be a toml file with all the configuration values in it, all set to their default value. See how cargo does this: https://doc.rust-lang.org/cargo/reference/config.html#configuration-format Example configs would be something like: "If you want to use Clippy before releasing a new version, use this config: |
The last one is just a |
A full discussion of |
I think that |
I like the idea. I still think having a deeper chapter about configuration in the book is still a good idea independently. I wonder if we could change our config API so it would automatically create the diagnostic along with the config so it's easier not to forget it? |
We now have a chapter that documents the current configurations better: Lint Configuration Options but I agree that a deeper chapter about the configuration would be nice. @blyxyas this might be interesting for you, since you're currently reworking the book ❤️ |
The Lint Configuration Options chapter has been re-vamped almost completely, focusing on readability. (#10699) Althought it seems pretty dead (hasn't had any interactions since its creation) |
I would be pleased to see those changes merged. |
Description
There are almost 50 Clippy configuration parameters. Most of them are likely unused by the users, in part because users do not know about them. I would like to propose a simple method to improve config param visibility: all lints should print a note, just once, in its output if the lint's behavior can be changed by a config parameter. The note should not be printed if the config param is already used. This approach would address some concerns from #9787
Note that the current config parser resolves defaults early on, so the lint doesn't know whether the config value is not set, or if it is set to the same value as default. We may want to introduce an additional flag for this in the future.
Example
The text was updated successfully, but these errors were encountered: