From ea1c2406cc2711ac19bc651b665ab081cfac987f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 14 Mar 2016 14:56:44 +0100 Subject: [PATCH] make single char names threshold configurable --- src/lib.rs | 2 +- src/non_expressive_names.rs | 4 ++-- src/utils/conf.rs | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a42db8d1fcb6..8bbaff653613 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,7 +202,7 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_late_lint_pass(box print::PrintLint); reg.register_late_lint_pass(box vec::UselessVec); reg.register_early_lint_pass(box non_expressive_names::NonExpressiveNames { - max_single_char_names: 5, + max_single_char_names: conf.max_single_char_names, }); reg.register_late_lint_pass(box drop_ref::DropRefPass); reg.register_late_lint_pass(box types::AbsurdExtremeComparisons); diff --git a/src/non_expressive_names.rs b/src/non_expressive_names.rs index 0c7c97ce474a..9ad91b421dde 100644 --- a/src/non_expressive_names.rs +++ b/src/non_expressive_names.rs @@ -32,7 +32,7 @@ declare_lint! { } pub struct NonExpressiveNames { - pub max_single_char_names: usize, + pub max_single_char_names: u64, } impl LintPass for NonExpressiveNames { @@ -92,7 +92,7 @@ impl<'a, 'b, 'c> SimilarNamesNameVisitor<'a, 'b, 'c> { return; } self.0.single_char_names.push(c); - if self.0.single_char_names.len() >= self.0.lint.max_single_char_names { + if self.0.single_char_names.len() as u64 >= self.0.lint.max_single_char_names { span_lint(self.0.cx, MANY_SINGLE_CHAR_NAMES, span, diff --git a/src/utils/conf.rs b/src/utils/conf.rs index 6636e30ab38a..2411e48997b3 100644 --- a/src/utils/conf.rs +++ b/src/utils/conf.rs @@ -153,6 +153,8 @@ define_Conf! { ("too-many-arguments-threshold", too_many_arguments_threshold, 7 => u64), /// Lint: TYPE_COMPLEXITY. The maximum complexity a type can have ("type-complexity-threshold", type_complexity_threshold, 250 => u64), + /// Lint: MANY_SINGLE_CHAR_NAMES. The maximum number of single char bindings a scope may have + ("single-char-binding-names-threshold", max_single_char_names, 5 => u64), } /// Read the `toml` configuration file. The function will ignore “File not found” errors iif