]> git.lizzy.rs Git - rust.git/commitdiff
allow by default
authorOliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 16 Jun 2016 16:37:56 +0000 (18:37 +0200)
committerOliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 16 Jun 2016 16:37:56 +0000 (18:37 +0200)
CHANGELOG.md
README.md
clippy_lints/src/enum_variants.rs
clippy_lints/src/lib.rs

index 790bbc04691b496e86e1c028d34130b7013cfcf0..3c2f9e1a622e8e7a08b32a393cfed2896cc014a8 100644 (file)
@@ -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
index 85e9ed70bf843ca52396fb0433317f73032ea040..a8e8cbb3a5adeaa5f3a568cb9939cee1e44b214a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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
index 8905870f1d823aaf95a8158568b45ef39de82327..4bf65ec42973482d79fa5abca3f250aeef743cf3 100644 (file)
     "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 @@ fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
                     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));
                     }
                 }
             }
index 32dd274ba6deb99e0834d7ca1ecc0b058511a472..b68596f253558350363c8f93c8482c9284764363 100644 (file)
@@ -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,