Skip to content
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

Add more lint checks for style #3070

Closed
brson opened this issue Aug 1, 2012 · 15 comments
Closed

Add more lint checks for style #3070

brson opened this issue Aug 1, 2012 · 15 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. metabug Issues about issues themselves ("bugs about bugs") P-low Low priority

Comments

@brson
Copy link
Contributor

brson commented Aug 1, 2012

We have one now that checks for camel case on types, variants and traits.

We have some other rules:

Let's have lint passes for those as well.

@nikomatsakis
Copy link
Contributor

I put this on as a 1.0 milestone because I think that having such lint checks enabled (to warn, probably) by default is something we really ought to have before we release. Specifically I am thinking of warning if variant names are lowercase or variable names are upper case---capitalization rules on types I think are less important.

@graydon
Copy link
Contributor

graydon commented Apr 24, 2013

oops, closed by accident (wrong bug)

@graydon graydon reopened this Apr 24, 2013
@pnkfelix
Copy link
Member

Visiting for bug triage, 2013 june 26.

I guess this bug is really a meta-bug, collecting lint additions that the rust dev team wants in as rules for the rustc and standard library code base before 1.0 is released.

There is still at least issue #4639 to resolve, so I'm leaving this open. (Once #4639 is resolved, then I'm guessing we'll close and reopen it as necessary to track whether lint items remain to do.)

@emberian
Copy link
Member

Visiting for triage; nothing to add.

@brson
Copy link
Contributor Author

brson commented Jan 16, 2014

Still want more of these. Any ideas?

@pnkfelix
Copy link
Member

accepted for P-low

@pnkfelix
Copy link
Member

tagging as a good mentorship bug, with @brson as the mentor.

@huonw
Copy link
Member

huonw commented Jan 16, 2014

Some more ideas:

  • Generic type parameters should be camel case, lifetimes should be snake case. (Although people rarely go beyond a single letter for either.)
  • modules should be snake case
  • no outer parens on if and match conditions

@pnkfelix
Copy link
Member

@huonw Does all-caps count as an instance of camel-case? If I need more than one letter in a type-param, I will often go for a (short) all-caps word.

@huonw
Copy link
Member

huonw commented Jan 16, 2014

Oh, it probably passes the camel case checker, but I normally do Foo for longer parameters (hence my suggestion of camel case); maybe I'm going against the prevailing style.

I guess we need to decide on a style for type parameters before linting them.

@pnkfelix
Copy link
Member

@huonw I suspect the prevailing style is to use less than 26 type parameters. ;)

bors added a commit that referenced this issue Jan 21, 2014
The parens in `if (true) {}` are not necessary, so we'll warn about them.

cc #3070 and #11432
@brson
Copy link
Contributor Author

brson commented Feb 6, 2014

I believe camel case is more common for typarams than allcaps.

@Rdbaker
Copy link

Rdbaker commented Jun 26, 2014

I'd love to start contributing! Is this a good place to start?

@ftxqxd
Copy link
Contributor

ftxqxd commented Sep 11, 2014

#15773 extended the existing lints to detect more cases where the Rust style for naming is not being used. That means that it detects non-uppercase statics, non-camel-case types and type parameters, and non-snake-case variables, struct/struct variant fields, lifetimes, functions, methods, and modules. (I might’ve missed something, but I think that’s it.) Is there anything else left with regards to naming? And what other lints are missing for this issue to be closed? Also, should non_uppercase_statics be set to warn by default? All the other naming lints are.

This is what I’ve come up with in the way of remaining style lints:

  • Pattern bindings with names the same as variants or statics. This probably couldn’t be done with a (normal) lint, because most of the time this would throw an error, and lints occur only if compilation was successful.
  • Line length. I seriously doubt it’s possible for a normal lint to do this, but it’s still part of Rust’s style (albeit an often-disputed one).

@steveklabnik
Copy link
Member

I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

This issue has been moved to the RFCs repo: rust-lang/rfcs#609

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
Format a paren expr with double slash comment
RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 25, 2023
disable no-merges check for now

It leads to false warnings on sync PRs until rust-lang/triagebot#1720 lands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. metabug Issues about issues themselves ("bugs about bugs") P-low Low priority
Projects
None yet
Development

No branches or pull requests

9 participants