Skip to content

Commit 913c710

Browse files
committed
upper_case_acronyms: add io-toml tests and bless previous tests
1 parent 59750dc commit 913c710

File tree

7 files changed

+103
-27
lines changed

7 files changed

+103
-27
lines changed

clippy_lints/src/upper_case_acronyms.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare_clippy_lint! {
1616
/// for more.
1717
///
1818
/// By default, the lint only triggers on fully-capitalized names.
19-
/// You can use the `upper_case_acronyms_aggressive: true` config option to enable linting
19+
/// You can use the `upper-case-acronyms-aggressive: true` config option to enable linting
2020
/// on all camel case names
2121
///
2222
/// **Known problems:** When two acronyms are contiguous, the lint can't tell where
@@ -82,7 +82,7 @@ fn check_ident(cx: &EarlyContext<'_>, ident: &Ident, be_aggressive: bool) {
8282
// (and don't warn)
8383
if (ident.chars().all(|c| c.is_ascii_uppercase()) && ident.len() > 2)
8484
// otherwise, warn if we have SOmeTHING lIKE THIs but only warn with the aggressive
85-
// upper_case_acronyms_aggressive config option enabled
85+
// upper-case-acronyms-aggressive config option enabled
8686
|| (be_aggressive && ident != &corrected)
8787
{
8888
span_lint_and_sugg(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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`, `cargo-ignore-publish`, `third-party` at line 5 column 1
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
22

33
error: aborting due to previous error
44

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
upper-case-acronyms-aggressive = true
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![warn(clippy::upper_case_acronyms)]
2+
3+
struct HTTPResponse; // not linted by default, but with cfg option
4+
5+
struct CString; // not linted
6+
7+
enum Flags {
8+
NS, // not linted
9+
CWR,
10+
ECE,
11+
URG,
12+
ACK,
13+
PSH,
14+
RST,
15+
SYN,
16+
FIN,
17+
}
18+
19+
struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
20+
// `GccLlvmSomething`
21+
22+
fn main() {}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
error: name `HTTPResponse` contains a capitalized acronym
2+
--> $DIR/upper_case_acronyms.rs:3:8
3+
|
4+
LL | struct HTTPResponse; // not linted by default, but with cfg option
5+
| ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse`
6+
|
7+
= note: `-D clippy::upper-case-acronyms` implied by `-D warnings`
8+
9+
error: name `NS` contains a capitalized acronym
10+
--> $DIR/upper_case_acronyms.rs:8:5
11+
|
12+
LL | NS, // not linted
13+
| ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ns`
14+
15+
error: name `CWR` contains a capitalized acronym
16+
--> $DIR/upper_case_acronyms.rs:9:5
17+
|
18+
LL | CWR,
19+
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr`
20+
21+
error: name `ECE` contains a capitalized acronym
22+
--> $DIR/upper_case_acronyms.rs:10:5
23+
|
24+
LL | ECE,
25+
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Ece`
26+
27+
error: name `URG` contains a capitalized acronym
28+
--> $DIR/upper_case_acronyms.rs:11:5
29+
|
30+
LL | URG,
31+
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Urg`
32+
33+
error: name `ACK` contains a capitalized acronym
34+
--> $DIR/upper_case_acronyms.rs:12:5
35+
|
36+
LL | ACK,
37+
| ^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ack`
38+
39+
error: name `PSH` contains a capitalized acronym
40+
--> $DIR/upper_case_acronyms.rs:13:5
41+
|
42+
LL | PSH,
43+
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Psh`
44+
45+
error: name `RST` contains a capitalized acronym
46+
--> $DIR/upper_case_acronyms.rs:14:5
47+
|
48+
LL | RST,
49+
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Rst`
50+
51+
error: name `SYN` contains a capitalized acronym
52+
--> $DIR/upper_case_acronyms.rs:15:5
53+
|
54+
LL | SYN,
55+
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Syn`
56+
57+
error: name `FIN` contains a capitalized acronym
58+
--> $DIR/upper_case_acronyms.rs:16:5
59+
|
60+
LL | FIN,
61+
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin`
62+
63+
error: name `GCCLLVMSomething` contains a capitalized acronym
64+
--> $DIR/upper_case_acronyms.rs:19:8
65+
|
66+
LL | struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
67+
| ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething`
68+
69+
error: aborting due to 11 previous errors
70+

tests/ui/upper_case_acronyms.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#![warn(clippy::upper_case_acronyms)]
22

3-
struct HTTPResponse; // linted
3+
struct HTTPResponse; // not linted by default, but with cfg option
44

55
struct CString; // not linted
66

77
enum Flags {
8-
NS, // linted
8+
NS, // not linted
99
CWR,
1010
ECE,
1111
URG,
@@ -16,6 +16,7 @@ enum Flags {
1616
FIN,
1717
}
1818

19-
struct GCCLLVMSomething; // linted, beware that lint suggests `GccllvmSomething` instead of `GccLlvmSomething`
19+
struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
20+
// `GccLlvmSomething`
2021

2122
fn main() {}

tests/ui/upper_case_acronyms.stderr

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
error: name `HTTPResponse` contains a capitalized acronym
2-
--> $DIR/upper_case_acronyms.rs:3:8
3-
|
4-
LL | struct HTTPResponse; // linted
5-
| ^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `HttpResponse`
6-
|
7-
= note: `-D clippy::upper-case-acronyms` implied by `-D warnings`
8-
9-
error: name `NS` contains a capitalized acronym
10-
--> $DIR/upper_case_acronyms.rs:8:5
11-
|
12-
LL | NS, // linted
13-
| ^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ns`
14-
151
error: name `CWR` contains a capitalized acronym
162
--> $DIR/upper_case_acronyms.rs:9:5
173
|
184
LL | CWR,
195
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Cwr`
6+
|
7+
= note: `-D clippy::upper-case-acronyms` implied by `-D warnings`
208

219
error: name `ECE` contains a capitalized acronym
2210
--> $DIR/upper_case_acronyms.rs:10:5
@@ -60,11 +48,5 @@ error: name `FIN` contains a capitalized acronym
6048
LL | FIN,
6149
| ^^^ help: consider making the acronym lowercase, except the initial letter: `Fin`
6250

63-
error: name `GCCLLVMSomething` contains a capitalized acronym
64-
--> $DIR/upper_case_acronyms.rs:19:8
65-
|
66-
LL | struct GCCLLVMSomething; // linted, beware that lint suggests `GccllvmSomething` instead of `GccLlvmSomething`
67-
| ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething`
68-
69-
error: aborting due to 11 previous errors
51+
error: aborting due to 8 previous errors
7052

0 commit comments

Comments
 (0)