1
Fork 0

make single char names threshold configurable

This commit is contained in:
Oliver Schneider 2016-03-14 14:56:44 +01:00
commit ea1c2406cc
3 changed files with 5 additions and 3 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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