Merge pull request #819 from oli-obk/more_whitelisted_names
whitelist more non-expressive-name false positives
This commit is contained in:
commit
fc64053da4
@ -60,6 +60,8 @@ struct SimilarNamesLocalVisitor<'a, 'b: 'a> {
|
||||
const WHITELIST: &'static [&'static [&'static str]] = &[
|
||||
&["parsed", "parser"],
|
||||
&["lhs", "rhs"],
|
||||
&["tx", "rx"],
|
||||
&["set", "get"],
|
||||
];
|
||||
|
||||
struct SimilarNamesNameVisitor<'a, 'b: 'a, 'c: 'b>(&'a mut SimilarNamesLocalVisitor<'b, 'c>);
|
||||
@ -88,13 +90,11 @@ fn whitelisted(interned_name: &str, list: &[&str]) -> bool {
|
||||
}
|
||||
for name in list {
|
||||
// name_*
|
||||
let allow_start = name.chars().chain(Some('_'));
|
||||
if interned_name.chars().zip(allow_start).all(|(l, r)| l == r) {
|
||||
if interned_name.chars().zip(name.chars()).all(|(l, r)| l == r) {
|
||||
return true;
|
||||
}
|
||||
// *_name
|
||||
let allow_end = Some('_').into_iter().chain(name.chars());
|
||||
if interned_name.chars().rev().zip(allow_end.rev()).all(|(l, r)| l == r) {
|
||||
if interned_name.chars().rev().zip(name.chars().rev()).all(|(l, r)| l == r) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
#![allow(unused)]
|
||||
|
||||
fn main() {
|
||||
@ -45,9 +44,8 @@ fn main() {
|
||||
let bla_rhs: i32;
|
||||
let bla_lhs: i32;
|
||||
|
||||
let blubrhs: i32; //~ NOTE: existing binding defined here
|
||||
let blublhs: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: for further information visit
|
||||
let blubrhs: i32;
|
||||
let blublhs: i32;
|
||||
|
||||
let blubx: i32; //~ NOTE: existing binding defined here
|
||||
let bluby: i32; //~ ERROR: name is too similar
|
||||
@ -83,6 +81,13 @@ fn main() {
|
||||
let parsee: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: for further information visit
|
||||
//~| HELP: separate the discriminating character by an underscore like: `parse_e`
|
||||
|
||||
let setter: i32;
|
||||
let getter: i32;
|
||||
let tx1: i32;
|
||||
let rx1: i32;
|
||||
let tx_cake: i32;
|
||||
let rx_cake: i32;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
Loading…
Reference in New Issue
Block a user