From af441b5b072eb01c939d2e92a3496dbedf6d412b Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Tue, 16 Oct 2018 07:24:32 +0200 Subject: [PATCH] Rename `active_lints` to `usable_lints` Because now `usable_lints` will also exclude internal lints. --- clippy_dev/src/lib.rs | 14 ++++++++------ clippy_dev/src/main.rs | 8 +++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index 8477183ae..d4b74f557 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -57,9 +57,9 @@ impl Lint { } } - /// Returns all non-deprecated lints - pub fn active_lints(lints: impl Iterator) -> impl Iterator { - lints.filter(|l| l.deprecation.is_none()) + /// Returns all non-deprecated lints and non-internal lints + pub fn usable_lints(lints: impl Iterator) -> impl Iterator { + lints.filter(|l| l.deprecation.is_none() && !l.group.starts_with("internal")) } /// Returns the lints in a HashMap, grouped by the different lint groups @@ -141,15 +141,17 @@ declare_deprecated_lint! { } #[test] -fn test_active_lints() { +fn test_usable_lints() { let lints = vec![ Lint::new("should_assert_eq", "Deprecated", "abc", Some("Reason"), "module_name"), - Lint::new("should_assert_eq2", "Not Deprecated", "abc", None, "module_name") + Lint::new("should_assert_eq2", "Not Deprecated", "abc", None, "module_name"), + Lint::new("should_assert_eq2", "internal", "abc", None, "module_name"), + Lint::new("should_assert_eq2", "internal_style", "abc", None, "module_name") ]; let expected = vec![ Lint::new("should_assert_eq2", "Not Deprecated", "abc", None, "module_name") ]; - assert_eq!(expected, Lint::active_lints(lints.into_iter()).collect::>()); + assert_eq!(expected, Lint::usable_lints(lints.into_iter()).collect::>()); } #[test] diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 9e78def78..ff7d47366 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -37,8 +37,10 @@ fn main() { } fn print_lints() { - let lint_list = gather_all().collect::>(); - let grouped_by_lint_group = Lint::by_lint_group(&lint_list); + let lint_list = gather_all(); + let usable_lints: Vec = Lint::usable_lints(lint_list).collect(); + let lint_count = usable_lints.len(); + let grouped_by_lint_group = Lint::by_lint_group(&usable_lints); for (lint_group, mut lints) in grouped_by_lint_group { if lint_group == "Deprecated" { continue; } @@ -51,5 +53,5 @@ fn print_lints() { } } - println!("there are {} lints", Lint::active_lints(lint_list.into_iter()).count()); + println!("there are {} lints", lint_count); }