From f27372061a0effe3b00d400f4e577b9d9e0ad4c0 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 20 Nov 2021 18:57:28 +0530 Subject: add config option to fix and check --- bin/src/utils.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 bin/src/utils.rs (limited to 'bin/src/utils.rs') diff --git a/bin/src/utils.rs b/bin/src/utils.rs new file mode 100644 index 0000000..747a761 --- /dev/null +++ b/bin/src/utils.rs @@ -0,0 +1,24 @@ +use std::collections::HashMap; + +use lib::{Lint, LINTS}; +use rnix::SyntaxKind; + +pub fn lint_map_of( + lints: &[&'static Box], +) -> HashMap>> { + let mut map = HashMap::new(); + for lint in lints.iter() { + let lint = *lint; + let matches = lint.match_kind(); + for m in matches { + map.entry(m) + .and_modify(|v: &mut Vec<_>| v.push(lint)) + .or_insert_with(|| vec![lint]); + } + } + map +} + +pub fn lint_map() -> HashMap>> { + lint_map_of(&*LINTS) +} -- cgit v1.2.3