[tor-bugs] #22156 [Core Tor/Tor]: Add Rust linting/formatting tools

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed May 31 14:03:56 UTC 2017


#22156: Add Rust linting/formatting tools
--------------------------+----------------------------------
 Reporter:  chelseakomlo  |          Owner:
     Type:  enhancement   |         Status:  new
 Priority:  Medium        |      Milestone:  Tor: unspecified
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:  rust          |  Actual Points:
Parent ID:                |         Points:
 Reviewer:                |        Sponsor:
--------------------------+----------------------------------

Comment (by chelseakomlo):

 Hey, thanks for the further info on clippy.

 Replying to [comment:1 hdevalence]:
 > `cargo clippy` is a great tool, but I don't think that it should be part
 of a CI run, and I don't think that it makes sense (or is worthwhile) to
 spend time deciding which rules should be included or not.
 >
 > The reason is that `cargo clippy` is meant to be **extremely
 enthusiastic** about giving suggestions.  Often, these suggestions are
 helpful, but sometimes, they aren't.  And, for a given rule, there's no
 way to know whether it will always be useful or not (i.e., there's no way
 to decide in advance whether it should be "required").  For instance,
 consider [https://github.com/Manishearth/rust-
 clippy/wiki#needless_range_loop `needless_range_loop`].  This is often a
 good warning, but sometimes it really does make more sense to use an
 explicit index.  There's no way to know, except by using context and
 judgement.
 >

 Yes, we'll definitely need to slowly build up which warnings we
 follow/ignore, mostly on a as-needed basis, as you said. It isn't
 practical to decide everything in one go.

 >
 > I wonder whether a focus on requiring linting tools as part of a
 development/CI process is a legacy from C development.  Since `rustc`
 already includes quite extensive errors and warnings, is a required
 linting process beyond "no warnings on compilation" necessary?
 >

 Linting is a pretty common practice in languages other than C. For
 example, Golang has its own linter: https://github.com/golang/lint and
 JavaScript has JSHint and other tools.

 >
 > To put it another way, what errors are people hoping to catch using a
 linter that `rustc` wouldn't already warn about?
 >

 It is true that we'll lean on rustc for compile errors, but using a linter
 helps ensure a certain coding style.

 Because clippy is so opinionated and also in flux, we hope starting simple
 and iterating when needed will have the best result. Hopefully we can give
 feedback to clippy developers to help improve the usefulness of it as
 well.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/22156#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list