-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #6788 - matthiaskrgr:upper_case_acronyms, r=flip1995
move upper_case_acronyms back to style, but make the default behaviour less aggressive by default (can be unleashed via config option) Previous discussion in the bi-weekly clippy meeting for reference: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202021-02-23/near/227458019 Move the `upper_case_acronyms` lint back to the style group. Only warn on fully-capitalized names by default. Add add a clippy-config option `upper-case-acronyms-aggressive: true/false` to enabled more aggressive linting on all substrings that could be capitalized acronyms. --- changelog: reenable upper_case_acronyms by default but make the more aggressive linting opt-in via config option
- Loading branch information
Showing
9 changed files
with
139 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown field `foobar`, expected one of `msrv`, `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `unreadable-literal-lint-fractions`, `cargo-ignore-publish`, `third-party` at line 5 column 1 | ||
error: error reading Clippy's configuration file `$DIR/clippy.toml`: unknown field `foobar`, expected one of `msrv`, `blacklisted-names`, `cognitive-complexity-threshold`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `literal-representation-threshold`, `trivial-copy-size-limit`, `pass-by-value-size-limit`, `too-many-lines-threshold`, `array-size-threshold`, `vec-box-size-threshold`, `max-trait-bounds`, `max-struct-bools`, `max-fn-params-bools`, `warn-on-all-wildcard-imports`, `disallowed-methods`, `unreadable-literal-lint-fractions`, `upper-case-acronyms-aggressive`, `cargo-ignore-publish`, `third-party` at line 5 column 1 | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
upper-case-acronyms-aggressive = true |
22 changes: 22 additions & 0 deletions
22
tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![warn(clippy::upper_case_acronyms)] | ||
|
||
struct HTTPResponse; // not linted by default, but with cfg option | ||
|
||
struct CString; // not linted | ||
|
||
enum Flags { | ||
NS, // not linted | ||
CWR, | ||
ECE, | ||
URG, | ||
ACK, | ||
PSH, | ||
RST, | ||
SYN, | ||
FIN, | ||
} | ||
|
||
struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of | ||
// `GccLlvmSomething` | ||
|
||
fn main() {} |
70 changes: 70 additions & 0 deletions
70
tests/ui-toml/upper_case_acronyms_aggressive/upper_case_acronyms.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
error: name `HTTPResponse` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:3:8 | ||
| | ||
LL | struct HTTPResponse; // not linted by default, but with cfg option | ||
| ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse` | ||
| | ||
= note: `-D clippy::upper-case-acronyms` implied by `-D warnings` | ||
|
||
error: name `NS` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:8:5 | ||
| | ||
LL | NS, // not linted | ||
| ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ns` | ||
|
||
error: name `CWR` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:9:5 | ||
| | ||
LL | CWR, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr` | ||
|
||
error: name `ECE` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:10:5 | ||
| | ||
LL | ECE, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece` | ||
|
||
error: name `URG` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:11:5 | ||
| | ||
LL | URG, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg` | ||
|
||
error: name `ACK` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:12:5 | ||
| | ||
LL | ACK, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack` | ||
|
||
error: name `PSH` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:13:5 | ||
| | ||
LL | PSH, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh` | ||
|
||
error: name `RST` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:14:5 | ||
| | ||
LL | RST, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst` | ||
|
||
error: name `SYN` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:15:5 | ||
| | ||
LL | SYN, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn` | ||
|
||
error: name `FIN` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:16:5 | ||
| | ||
LL | FIN, | ||
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin` | ||
|
||
error: name `GCCLLVMSomething` contains a capitalized acronym | ||
--> $DIR/upper_case_acronyms.rs:19:8 | ||
| | ||
LL | struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of | ||
| ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething` | ||
|
||
error: aborting due to 11 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters