Rust-clippy: Bikesheds to be done when RfCing clippy

Created on 2 Jan 2016  Â·  20Comments  Â·  Source: rust-lang/rust-clippy

At some point I wish to RfC the clippy lints.

One part of this will be figuring out Allow/Warn defaults. It will also be bikeshedding various questionable choices clippy has made.

Feel free to list anything you find bikesheddable here:

C-needs-discussion M-question

Most helpful comment

Regarding #1043, I defend that !x is not only shorter, but also more idiomatic. I remember x == false from my time as university tutor, often used by students who failed to understand boolean logic. Also ! is more easily grepped than == false (and leaves no questions as to spacing/line breaks/..)

All 20 comments

See also: #541

Another thing is shadow_unrelated – I consider those programmer lazyness, but I found so many matches in the wild that I haven't found the courage to make it warn by default.

:smile: I'm :+1: for warning it now if you want, btw, but yeah, it's something that we should list here.

Two-branch matches: warn or allow?

Obviously allow. That’s purely a programmer/style-preference thing.

Glob enum imports: warn or allow?

Also allow?

fn a() {
     use Enum::*;
     // do a lot with the variants.
}

is pretty common, though I’m not sure if this exact pattern is linted against.

@nagisa only glob imports at the module level are linted against. The question is whether to also not lint on pub use Enum::*; since that also seems to be a common pattern for old-style enums.

That’s purely a programmer/style-preference thing.

@nagisa I changed the lint to only trigger if the second arm is a block. In that case it's both more vertical space AND more indentation when using a match instead of an if let.

I changed the lint to only trigger if the second arm is a block

This is still preference/style based.

Allow cyclomatic_complexity, there is no universal answer to how complex is too complex. Allow explicit_iter_loop, &x is more concise but x.iter() is more explicit, not obvious which is more readable.

When I made a PR to fix all Clippy warnings in Cargo, they asked me to remove my commit about explicit_iter_loop because they preferred x.iter() over &x.

toplevel_ref_arg should be allowed for let bindings, it's purely stylistic, let ref x = expr can be more readable than let x = &expr when expr is complex (for example a long match).

1043 is bikesheddable

Regarding #1043, I defend that !x is not only shorter, but also more idiomatic. I remember x == false from my time as university tutor, often used by students who failed to understand boolean logic. Also ! is more easily grepped than == false (and leaves no questions as to spacing/line breaks/..)

Things like #1043 is why I prefer Python's not keyword to !...

Undeprecate string_to_string. I think it _is_ unidiomatic to use to_string to clone a String. clone is clearer in intent. Also there are many lints related to clone, using to_string may hide bad practices.

I'm not sure if we should undeprecate, but a new lint sounds bikesheddable.

@alexcrichton prefers .iter()/.iter_mut() to &/&mut,see futures-rs PR#55. I'm a bit torn on this issue (and I'm usually plenty opinionated). Showing newbies that they can use anything that implements IntoIterator in a for loop seems a good idea, is shorter and certainly rustic. On the other hand, the functions are more discoverable, and don't introduce sigils, to which some developers seem to have an aversion.

Perhaps the lint should not warn, but merely suggest that it is possible to iterate over &x instead of x.iter() (E.g. just issue a cx.sess().span_note_without_error(..)). I suspect this would make the lint appear friendlier.

Oh sorry, I didn't see this issue when I created #1192: I'd to make option_map_unwrap_or and option_map_unwrap_or_else allow by default.

Default allow/warn for option_map_unwrap_or (see #1192)?

cc @Shepmaster

(Clippy was RFCd)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthiaskrgr picture matthiaskrgr  Â·  24Comments

malbarbo picture malbarbo  Â·  26Comments

kevincox picture kevincox  Â·  17Comments

Pyriphlegethon picture Pyriphlegethon  Â·  17Comments

dtolnay picture dtolnay  Â·  20Comments