obi1kenobi / cargo-semver-checks

Scan your Rust crate for semver violations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configuration methods do not have consistent naming

suaviloquence opened this issue · comments

Question on method naming: it seems like we now have a set_level() method where before we had a with_log_level() method. Is this divergence intentional, or should we instead have either set_log_level() or with_log_level() as before? Similar question about with the other set_...() methods, as opposed to the existing with_...() methods' naming convention.

The GlobalConfig::set_level method already existed before this PR, so I left it unchanged. Additionally, since we used to have that and the set_color_choice method, I used the set_ prefix for GlobalConfig setters. I agree that it's not consistent between GlobalConfig and Check, but they are both internally consistent. Should we use the same prefix for everything? If so, in here, or in a different PR?

Originally posted by @suaviloquence in #737 (comment)

If we want all the methods to be consistent across Check and GlobalConfig, we need to choose:

  • do we want the with_ (found in Check) prefix or the set_ (from GlobalConfig) prefix?
  • do we want set_log_level or set_level?

I definitely prefer log_level over level, and I have a slight preference for set over with. What do others think?

Sounds good, let's go with that!

Probably best to make this change now, before the next release, so that we only break the API once. Would you mind posting the updated migration guide together with the PR?

I can do that. One other thing: do we want to standardize the calling convention? Currently only set_level takes an owned Self (and it doesn't use it, we could use a &mut self). If we copy the Check convention, setter methods go fn(&mut self, ...) -> &mut self which I think makes a lot of sense.

Sounds good to me!