diff options
Diffstat (limited to 'lib/src')
-rw-r--r-- | lib/src/lib.rs | 19 | ||||
-rw-r--r-- | lib/src/lints.rs | 4 | ||||
-rw-r--r-- | lib/src/lints/collapsible_let_in.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/deprecated_is_null.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/empty_let_in.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/empty_pattern.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/eta_reduction.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/legacy_let_syntax.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/manual_inherit.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/manual_inherit_from.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/redundant_pattern_bind.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/unquoted_splice.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/unquoted_uri.rs | 2 | ||||
-rw-r--r-- | lib/src/lints/useless_parens.rs | 2 |
14 files changed, 20 insertions, 27 deletions
diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 5347666..d96d9eb 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs | |||
@@ -255,31 +255,24 @@ pub trait Lint: Metadata + Explain + Rule + Send + Sync {} | |||
255 | /// | 255 | /// |
256 | /// See `lints.rs` for usage. | 256 | /// See `lints.rs` for usage. |
257 | #[macro_export] | 257 | #[macro_export] |
258 | macro_rules! lint_map { | 258 | macro_rules! lints { |
259 | ($($s:ident),*,) => { | 259 | ($($s:ident),*,) => { |
260 | lint_map!($($s),*); | 260 | lints!($($s),*); |
261 | }; | 261 | }; |
262 | ($($s:ident),*) => { | 262 | ($($s:ident),*) => { |
263 | use ::std::collections::HashMap; | ||
264 | use ::rnix::SyntaxKind; | ||
265 | $( | 263 | $( |
266 | mod $s; | 264 | mod $s; |
267 | )* | 265 | )* |
268 | ::lazy_static::lazy_static! { | 266 | ::lazy_static::lazy_static! { |
269 | pub static ref LINTS: HashMap<SyntaxKind, Vec<&'static Box<dyn $crate::Lint>>> = { | 267 | pub static ref LINTS: Vec<&'static Box<dyn $crate::Lint>> = { |
270 | let mut map = HashMap::new(); | 268 | let mut v = Vec::new(); |
271 | $( | 269 | $( |
272 | { | 270 | { |
273 | let temp_lint = &*$s::LINT; | 271 | let temp_lint = &*$s::LINT; |
274 | let temp_matches = temp_lint.match_kind(); | 272 | v.push(temp_lint); |
275 | for temp_match in temp_matches { | ||
276 | map.entry(temp_match) | ||
277 | .and_modify(|v: &mut Vec<_>| v.push(temp_lint)) | ||
278 | .or_insert_with(|| vec![temp_lint]); | ||
279 | } | ||
280 | } | 273 | } |
281 | )* | 274 | )* |
282 | map | 275 | v |
283 | }; | 276 | }; |
284 | } | 277 | } |
285 | } | 278 | } |
diff --git a/lib/src/lints.rs b/lib/src/lints.rs index 8b0f92b..b4d4af3 100644 --- a/lib/src/lints.rs +++ b/lib/src/lints.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use crate::lint_map; | 1 | use crate::lints; |
2 | 2 | ||
3 | lint_map! { | 3 | lints! { |
4 | bool_comparison, | 4 | bool_comparison, |
5 | empty_let_in, | 5 | empty_let_in, |
6 | manual_inherit, | 6 | manual_inherit, |
diff --git a/lib/src/lints/collapsible_let_in.rs b/lib/src/lints/collapsible_let_in.rs index 26a3102..aa7e5a7 100644 --- a/lib/src/lints/collapsible_let_in.rs +++ b/lib/src/lints/collapsible_let_in.rs | |||
@@ -37,7 +37,7 @@ use rowan::Direction; | |||
37 | /// a + b | 37 | /// a + b |
38 | /// ``` | 38 | /// ``` |
39 | #[lint( | 39 | #[lint( |
40 | name = "collapsible let in", | 40 | name = "collapsible_let_in", |
41 | note = "These let-in expressions are collapsible", | 41 | note = "These let-in expressions are collapsible", |
42 | code = 6, | 42 | code = 6, |
43 | match_with = SyntaxKind::NODE_LET_IN | 43 | match_with = SyntaxKind::NODE_LET_IN |
diff --git a/lib/src/lints/deprecated_is_null.rs b/lib/src/lints/deprecated_is_null.rs index fce6931..c814e87 100644 --- a/lib/src/lints/deprecated_is_null.rs +++ b/lib/src/lints/deprecated_is_null.rs | |||
@@ -27,7 +27,7 @@ use rnix::{ | |||
27 | /// e == null | 27 | /// e == null |
28 | /// ``` | 28 | /// ``` |
29 | #[lint( | 29 | #[lint( |
30 | name = "deprecated isNull", | 30 | name = "deprecated_is_null", |
31 | note = "Found usage of deprecated builtin isNull", | 31 | note = "Found usage of deprecated builtin isNull", |
32 | code = 13, | 32 | code = 13, |
33 | match_with = SyntaxKind::NODE_APPLY | 33 | match_with = SyntaxKind::NODE_APPLY |
diff --git a/lib/src/lints/empty_let_in.rs b/lib/src/lints/empty_let_in.rs index 5a51ea3..d33d0ae 100644 --- a/lib/src/lints/empty_let_in.rs +++ b/lib/src/lints/empty_let_in.rs | |||
@@ -26,7 +26,7 @@ use rnix::{ | |||
26 | /// pkgs.statix | 26 | /// pkgs.statix |
27 | /// ``` | 27 | /// ``` |
28 | #[lint( | 28 | #[lint( |
29 | name = "empty let-in", | 29 | name = "empty_let_in", |
30 | note = "Useless let-in expression", | 30 | note = "Useless let-in expression", |
31 | code = 2, | 31 | code = 2, |
32 | match_with = SyntaxKind::NODE_LET_IN | 32 | match_with = SyntaxKind::NODE_LET_IN |
diff --git a/lib/src/lints/empty_pattern.rs b/lib/src/lints/empty_pattern.rs index c0cb5a4..f66a3b1 100644 --- a/lib/src/lints/empty_pattern.rs +++ b/lib/src/lints/empty_pattern.rs | |||
@@ -35,7 +35,7 @@ use rnix::{ | |||
35 | /// }; | 35 | /// }; |
36 | /// ``` | 36 | /// ``` |
37 | #[lint( | 37 | #[lint( |
38 | name = "empty pattern", | 38 | name = "empty_pattern", |
39 | note = "Found empty pattern in function argument", | 39 | note = "Found empty pattern in function argument", |
40 | code = 10, | 40 | code = 10, |
41 | match_with = SyntaxKind::NODE_PATTERN | 41 | match_with = SyntaxKind::NODE_PATTERN |
diff --git a/lib/src/lints/eta_reduction.rs b/lib/src/lints/eta_reduction.rs index 454c78f..580f4a0 100644 --- a/lib/src/lints/eta_reduction.rs +++ b/lib/src/lints/eta_reduction.rs | |||
@@ -34,7 +34,7 @@ use rnix::{ | |||
34 | /// map double [ 1 2 3 ] | 34 | /// map double [ 1 2 3 ] |
35 | /// ``` | 35 | /// ``` |
36 | #[lint( | 36 | #[lint( |
37 | name = "eta reduction", | 37 | name = "eta_reduction", |
38 | note = "This function expression is eta reducible", | 38 | note = "This function expression is eta reducible", |
39 | code = 7, | 39 | code = 7, |
40 | match_with = SyntaxKind::NODE_LAMBDA | 40 | match_with = SyntaxKind::NODE_LAMBDA |
diff --git a/lib/src/lints/legacy_let_syntax.rs b/lib/src/lints/legacy_let_syntax.rs index cdd012d..5d0028b 100644 --- a/lib/src/lints/legacy_let_syntax.rs +++ b/lib/src/lints/legacy_let_syntax.rs | |||
@@ -36,7 +36,7 @@ use rnix::{ | |||
36 | /// }.body | 36 | /// }.body |
37 | /// ``` | 37 | /// ``` |
38 | #[lint( | 38 | #[lint( |
39 | name = "legacy let syntax", | 39 | name = "legacy_let_syntax", |
40 | note = "Using undocumented `let` syntax", | 40 | note = "Using undocumented `let` syntax", |
41 | code = 5, | 41 | code = 5, |
42 | match_with = SyntaxKind::NODE_LEGACY_LET | 42 | match_with = SyntaxKind::NODE_LEGACY_LET |
diff --git a/lib/src/lints/manual_inherit.rs b/lib/src/lints/manual_inherit.rs index 1813af3..7717dc9 100644 --- a/lib/src/lints/manual_inherit.rs +++ b/lib/src/lints/manual_inherit.rs | |||
@@ -32,7 +32,7 @@ use rnix::{ | |||
32 | /// { inherit a; b = 3; } | 32 | /// { inherit a; b = 3; } |
33 | /// ``` | 33 | /// ``` |
34 | #[lint( | 34 | #[lint( |
35 | name = "manual inherit", | 35 | name = "manual_inherit", |
36 | note = "Assignment instead of inherit", | 36 | note = "Assignment instead of inherit", |
37 | code = 3, | 37 | code = 3, |
38 | match_with = SyntaxKind::NODE_KEY_VALUE | 38 | match_with = SyntaxKind::NODE_KEY_VALUE |
diff --git a/lib/src/lints/manual_inherit_from.rs b/lib/src/lints/manual_inherit_from.rs index ab2579d..05d6bc8 100644 --- a/lib/src/lints/manual_inherit_from.rs +++ b/lib/src/lints/manual_inherit_from.rs | |||
@@ -32,7 +32,7 @@ use rnix::{ | |||
32 | /// null | 32 | /// null |
33 | /// ``` | 33 | /// ``` |
34 | #[lint( | 34 | #[lint( |
35 | name = "manual inherit from", | 35 | name = "manual_inherit_from", |
36 | note = "Assignment instead of inherit from", | 36 | note = "Assignment instead of inherit from", |
37 | code = 4, | 37 | code = 4, |
38 | match_with = SyntaxKind::NODE_KEY_VALUE | 38 | match_with = SyntaxKind::NODE_KEY_VALUE |
diff --git a/lib/src/lints/redundant_pattern_bind.rs b/lib/src/lints/redundant_pattern_bind.rs index 882a660..88ce4b0 100644 --- a/lib/src/lints/redundant_pattern_bind.rs +++ b/lib/src/lints/redundant_pattern_bind.rs | |||
@@ -27,7 +27,7 @@ use rnix::{ | |||
27 | /// inputs: inputs.nixpkgs | 27 | /// inputs: inputs.nixpkgs |
28 | /// ``` | 28 | /// ``` |
29 | #[lint( | 29 | #[lint( |
30 | name = "redundant pattern bind", | 30 | name = "redundant_pattern_bind", |
31 | note = "Found redundant pattern bind in function argument", | 31 | note = "Found redundant pattern bind in function argument", |
32 | code = 11, | 32 | code = 11, |
33 | match_with = SyntaxKind::NODE_PATTERN | 33 | match_with = SyntaxKind::NODE_PATTERN |
diff --git a/lib/src/lints/unquoted_splice.rs b/lib/src/lints/unquoted_splice.rs index ce269b6..7649fbc 100644 --- a/lib/src/lints/unquoted_splice.rs +++ b/lib/src/lints/unquoted_splice.rs | |||
@@ -32,7 +32,7 @@ use rnix::{ | |||
32 | /// pkgs | 32 | /// pkgs |
33 | /// ``` | 33 | /// ``` |
34 | #[lint( | 34 | #[lint( |
35 | name = "unquoted splice", | 35 | name = "unquoted_splice", |
36 | note = "Found unquoted splice expression", | 36 | note = "Found unquoted splice expression", |
37 | code = 9, | 37 | code = 9, |
38 | match_with = SyntaxKind::NODE_DYNAMIC | 38 | match_with = SyntaxKind::NODE_DYNAMIC |
diff --git a/lib/src/lints/unquoted_uri.rs b/lib/src/lints/unquoted_uri.rs index b111f78..8835338 100644 --- a/lib/src/lints/unquoted_uri.rs +++ b/lib/src/lints/unquoted_uri.rs | |||
@@ -38,7 +38,7 @@ use rnix::{types::TypedNode, NodeOrToken, SyntaxElement, SyntaxKind}; | |||
38 | /// } | 38 | /// } |
39 | /// ``` | 39 | /// ``` |
40 | #[lint( | 40 | #[lint( |
41 | name = "unquoted uri", | 41 | name = "unquoted_uri", |
42 | note = "Found unquoted URI expression", | 42 | note = "Found unquoted URI expression", |
43 | code = 12, | 43 | code = 12, |
44 | match_with = SyntaxKind::TOKEN_URI | 44 | match_with = SyntaxKind::TOKEN_URI |
diff --git a/lib/src/lints/useless_parens.rs b/lib/src/lints/useless_parens.rs index dccc717..09d6f04 100644 --- a/lib/src/lints/useless_parens.rs +++ b/lib/src/lints/useless_parens.rs | |||
@@ -33,7 +33,7 @@ use rnix::{ | |||
33 | /// 2 + 3 | 33 | /// 2 + 3 |
34 | /// ``` | 34 | /// ``` |
35 | #[lint( | 35 | #[lint( |
36 | name = "useless parens", | 36 | name = "useless_parens", |
37 | note = "These parentheses can be omitted", | 37 | note = "These parentheses can be omitted", |
38 | code = 8, | 38 | code = 8, |
39 | match_with = [ | 39 | match_with = [ |