mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
upper_case_acronyms: add io-toml tests and bless previous tests
This commit is contained in:
parent
59750dceb8
commit
913c71018c
7 changed files with 103 additions and 27 deletions
|
@ -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
|
||||
|
@ -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(
|
||||
|
|
|
@ -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
tests/ui-toml/upper_case_acronyms_aggressive/clippy.toml
Normal file
1
tests/ui-toml/upper_case_acronyms_aggressive/clippy.toml
Normal file
|
@ -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
|
||||
|
|
@ -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,
|
||||
|
@ -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() {}
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue