Skip to content

Commit

Permalink
upper_case_acronyms: add io-toml tests and bless previous tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Feb 24, 2021
1 parent 59750dc commit 913c710
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 27 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/upper_case_acronyms.rs
Expand Up @@ -16,7 +16,7 @@ declare_clippy_lint! {
/// for more.
///
/// By default, the lint only triggers on fully-capitalized names.
/// You can use the `upper_case_acronyms_aggressive: true` config option to enable linting
/// You can use the `upper-case-acronyms-aggressive: true` config option to enable linting
/// on all camel case names
///
/// **Known problems:** When two acronyms are contiguous, the lint can't tell where
Expand Down Expand Up @@ -82,7 +82,7 @@ fn check_ident(cx: &EarlyContext<'_>, ident: &Ident, be_aggressive: bool) {
// (and don't warn)
if (ident.chars().all(|c| c.is_ascii_uppercase()) && ident.len() > 2)
// otherwise, warn if we have SOmeTHING lIKE THIs but only warn with the aggressive
// upper_case_acronyms_aggressive config option enabled
// upper-case-acronyms-aggressive config option enabled
|| (be_aggressive && ident != &corrected)
{
span_lint_and_sugg(
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
@@ -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

1 change: 1 addition & 0 deletions tests/ui-toml/upper_case_acronyms_aggressive/clippy.toml
@@ -0,0 +1 @@
upper-case-acronyms-aggressive = true
@@ -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() {}
@@ -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

7 changes: 4 additions & 3 deletions tests/ui/upper_case_acronyms.rs
@@ -1,11 +1,11 @@
#![warn(clippy::upper_case_acronyms)]

struct HTTPResponse; // linted
struct HTTPResponse; // not linted by default, but with cfg option

struct CString; // not linted

enum Flags {
NS, // linted
NS, // not linted
CWR,
ECE,
URG,
Expand All @@ -16,6 +16,7 @@ enum Flags {
FIN,
}

struct GCCLLVMSomething; // linted, beware that lint suggests `GccllvmSomething` instead of `GccLlvmSomething`
struct GCCLLVMSomething; // linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
// `GccLlvmSomething`

fn main() {}
24 changes: 3 additions & 21 deletions tests/ui/upper_case_acronyms.stderr
@@ -1,22 +1,10 @@
error: name `HTTPResponse` contains a capitalized acronym
--> $DIR/upper_case_acronyms.rs:3:8
|
LL | struct HTTPResponse; // linted
| ^^^^^^^^^^^^ 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, // 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`
|
= note: `-D clippy::upper-case-acronyms` implied by `-D warnings`

error: name `ECE` contains a capitalized acronym
--> $DIR/upper_case_acronyms.rs:10:5
Expand Down Expand Up @@ -60,11 +48,5 @@ error: name `FIN` contains a capitalized acronym
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, beware that lint suggests `GccllvmSomething` instead of `GccLlvmSomething`
| ^^^^^^^^^^^^^^^^ help: consider making the acronym lowercase, except the initial letter: `GccllvmSomething`

error: aborting due to 11 previous errors
error: aborting due to 8 previous errors

0 comments on commit 913c710

Please sign in to comment.