allow by default
This commit is contained in:
parent
af98a7ce52
commit
e628e4d513
|
@ -240,6 +240,7 @@ All notable changes to this project will be documented in this file.
|
|||
[`string_add_assign`]: https://github.com/Manishearth/rust-clippy/wiki#string_add_assign
|
||||
[`string_lit_as_bytes`]: https://github.com/Manishearth/rust-clippy/wiki#string_lit_as_bytes
|
||||
[`string_to_string`]: https://github.com/Manishearth/rust-clippy/wiki#string_to_string
|
||||
[`stutter`]: https://github.com/Manishearth/rust-clippy/wiki#stutter
|
||||
[`suspicious_assignment_formatting`]: https://github.com/Manishearth/rust-clippy/wiki#suspicious_assignment_formatting
|
||||
[`suspicious_else_formatting`]: https://github.com/Manishearth/rust-clippy/wiki#suspicious_else_formatting
|
||||
[`temporary_assignment`]: https://github.com/Manishearth/rust-clippy/wiki#temporary_assignment
|
||||
|
|
|
@ -17,7 +17,7 @@ Table of contents:
|
|||
|
||||
## Lints
|
||||
|
||||
There are 153 lints included in this crate:
|
||||
There are 154 lints included in this crate:
|
||||
|
||||
name | default | meaning
|
||||
---------------------------------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -144,6 +144,7 @@ name
|
|||
[string_add](https://github.com/Manishearth/rust-clippy/wiki#string_add) | allow | using `x + ..` where x is a `String`; suggests using `push_str()` instead
|
||||
[string_add_assign](https://github.com/Manishearth/rust-clippy/wiki#string_add_assign) | allow | using `x = x + ..` where x is a `String`; suggests using `push_str()` instead
|
||||
[string_lit_as_bytes](https://github.com/Manishearth/rust-clippy/wiki#string_lit_as_bytes) | warn | calling `as_bytes` on a string literal; suggests using a byte string literal instead
|
||||
[stutter](https://github.com/Manishearth/rust-clippy/wiki#stutter) | allow | finds type names prefixed/postfixed with their containing module's name
|
||||
[suspicious_assignment_formatting](https://github.com/Manishearth/rust-clippy/wiki#suspicious_assignment_formatting) | warn | suspicious formatting of `*=`, `-=` or `!=`
|
||||
[suspicious_else_formatting](https://github.com/Manishearth/rust-clippy/wiki#suspicious_else_formatting) | warn | suspicious formatting of `else if`
|
||||
[temporary_assignment](https://github.com/Manishearth/rust-clippy/wiki#temporary_assignment) | warn | assignments to temporaries
|
||||
|
|
|
@ -19,6 +19,18 @@ declare_lint! {
|
|||
"finds enums where all variants share a prefix/postfix"
|
||||
}
|
||||
|
||||
/// **What it does:** Warns on type names that are prefixed or suffixed by the containing module's name
|
||||
///
|
||||
/// **Why is this bad?** It requires the user to type the module name twice
|
||||
///
|
||||
/// **Known problems:** None
|
||||
///
|
||||
/// **Example:** mod cake { struct BlackForestCake; }
|
||||
declare_lint! {
|
||||
pub STUTTER, Allow,
|
||||
"finds type names prefixed/postfixed with their containing module's name"
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct EnumVariantNames {
|
||||
modules: Vec<String>,
|
||||
|
@ -26,7 +38,7 @@ pub struct EnumVariantNames {
|
|||
|
||||
impl LintPass for EnumVariantNames {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(ENUM_VARIANT_NAMES)
|
||||
lint_array!(ENUM_VARIANT_NAMES, STUTTER)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,10 +155,10 @@ impl EarlyLintPass for EnumVariantNames {
|
|||
let rmatching = partial_rmatch(mod_camel, &item_camel);
|
||||
let nchars = mod_camel.chars().count();
|
||||
if matching == nchars {
|
||||
span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) starts with its containing module's name ({})", item_camel, mod_camel));
|
||||
span_lint(cx, STUTTER, item.span, &format!("Item name ({}) starts with its containing module's name ({})", item_camel, mod_camel));
|
||||
}
|
||||
if rmatching == nchars {
|
||||
span_lint(cx, ENUM_VARIANT_NAMES, item.span, &format!("Item name ({}) ends with its containing module's name ({})", item_camel, mod_camel));
|
||||
span_lint(cx, STUTTER, item.span, &format!("Item name ({}) ends with its containing module's name ({})", item_camel, mod_camel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,6 +263,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
|
|||
array_indexing::INDEXING_SLICING,
|
||||
booleans::NONMINIMAL_BOOL,
|
||||
enum_glob_use::ENUM_GLOB_USE,
|
||||
enum_variants::STUTTER,
|
||||
if_not_else::IF_NOT_ELSE,
|
||||
items_after_statements::ITEMS_AFTER_STATEMENTS,
|
||||
matches::SINGLE_MATCH_ELSE,
|
||||
|
|
Loading…
Reference in New Issue