aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-19 17:57:23 +0100
committerAkshay <[email protected]>2021-10-19 17:57:23 +0100
commitb26272ba3e9067197e0aff16ba2ce8780e0acb96 (patch)
treedd97ddf664bd2255e9617bbdf41364134003c8cb
parentea2e23496672257dd1728ce36259249c3efb8aec (diff)
minor refactor
-rw-r--r--bin/src/main.rs8
-rw-r--r--lib/src/lints/legacy_let_syntax.rs7
-rw-r--r--lib/src/lints/manual_inherit.rs2
-rw-r--r--lib/src/lints/manual_inherit_from.rs2
-rw-r--r--vfs/src/lib.rs2
5 files changed, 10 insertions, 11 deletions
diff --git a/bin/src/main.rs b/bin/src/main.rs
index a3f04d7..161dcab 100644
--- a/bin/src/main.rs
+++ b/bin/src/main.rs
@@ -21,14 +21,14 @@ fn _main() -> Result<(), StatixErr> {
21 let vfs = lint_config.vfs()?; 21 let vfs = lint_config.vfs()?;
22 let (reports, errors): (Vec<_>, Vec<_>) = 22 let (reports, errors): (Vec<_>, Vec<_>) =
23 vfs.iter().map(lint::lint).partition(Result::is_ok); 23 vfs.iter().map(lint::lint).partition(Result::is_ok);
24 let lint_results: Vec<_> = reports.into_iter().map(Result::unwrap).collect(); 24 let lint_results = reports.into_iter().map(Result::unwrap);
25 let errors: Vec<_> = errors.into_iter().map(Result::unwrap_err).collect(); 25 let errors = errors.into_iter().map(Result::unwrap_err);
26 26
27 let mut stderr = io::stderr(); 27 let mut stderr = io::stderr();
28 lint_results.into_iter().for_each(|r| { 28 lint_results.for_each(|r| {
29 stderr.write(&r, &vfs).unwrap(); 29 stderr.write(&r, &vfs).unwrap();
30 }); 30 });
31 errors.into_iter().for_each(|e| { 31 errors.for_each(|e| {
32 eprintln!("{}", e); 32 eprintln!("{}", e);
33 }); 33 });
34 } 34 }
diff --git a/lib/src/lints/legacy_let_syntax.rs b/lib/src/lints/legacy_let_syntax.rs
index c5588e2..2087e27 100644
--- a/lib/src/lints/legacy_let_syntax.rs
+++ b/lib/src/lints/legacy_let_syntax.rs
@@ -23,15 +23,14 @@ impl Rule for ManualInherit {
23 23
24 if legacy_let 24 if legacy_let
25 .entries() 25 .entries()
26 .find(|kv| matches!(kv.key(), Some(k) if key_is_ident(&k, "body"))) 26 .any(|kv| matches!(kv.key(), Some(k) if key_is_ident(&k, "body")));
27 .is_some();
28 27
29 then { 28 then {
30 let inherits = legacy_let.inherits(); 29 let inherits = legacy_let.inherits();
31 let entries = legacy_let.entries(); 30 let entries = legacy_let.entries();
32 let attrset = make::attrset(inherits, entries, true); 31 let attrset = make::attrset(inherits, entries, true);
33 let parenthesized = make::parenthesize(&attrset.node()); 32 let parenthesized = make::parenthesize(attrset.node());
34 let selected = make::select(parenthesized.node(), &make::ident("body").node()); 33 let selected = make::select(parenthesized.node(), make::ident("body").node());
35 34
36 let at = node.text_range(); 35 let at = node.text_range();
37 let message = "Prefer `rec` over undocumented `let` syntax"; 36 let message = "Prefer `rec` over undocumented `let` syntax";
diff --git a/lib/src/lints/manual_inherit.rs b/lib/src/lints/manual_inherit.rs
index 3524dd3..69f032b 100644
--- a/lib/src/lints/manual_inherit.rs
+++ b/lib/src/lints/manual_inherit.rs
@@ -32,7 +32,7 @@ impl Rule for ManualInherit {
32 then { 32 then {
33 let at = node.text_range(); 33 let at = node.text_range();
34 let replacement = make::inherit_stmt(&[key]).node().clone(); 34 let replacement = make::inherit_stmt(&[key]).node().clone();
35 let message = format!("This assignment is better written with `inherit`"); 35 let message = "This assignment is better written with `inherit`";
36 Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) 36 Some(Self::report().suggest(at, message, Suggestion::new(at, replacement)))
37 } else { 37 } else {
38 None 38 None
diff --git a/lib/src/lints/manual_inherit_from.rs b/lib/src/lints/manual_inherit_from.rs
index d7a00b2..2bff5f8 100644
--- a/lib/src/lints/manual_inherit_from.rs
+++ b/lib/src/lints/manual_inherit_from.rs
@@ -37,7 +37,7 @@ impl Rule for ManualInherit {
37 let set = value.set()?; 37 let set = value.set()?;
38 make::inherit_from_stmt(set, &[key]).node().clone() 38 make::inherit_from_stmt(set, &[key]).node().clone()
39 }; 39 };
40 let message = format!("This assignment is better written with `inherit`"); 40 let message = "This assignment is better written with `inherit`";
41 Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) 41 Some(Self::report().suggest(at, message, Suggestion::new(at, replacement)))
42 } else { 42 } else {
43 None 43 None
diff --git a/vfs/src/lib.rs b/vfs/src/lib.rs
index f620ab9..98bd1c3 100644
--- a/vfs/src/lib.rs
+++ b/vfs/src/lib.rs
@@ -58,7 +58,7 @@ impl ReadOnlyVfs {
58 let file_id = self.alloc_file_id(path); 58 let file_id = self.alloc_file_id(path);
59 self.data.insert(file_id, contents.to_owned()); 59 self.data.insert(file_id, contents.to_owned());
60 } 60 }
61 pub fn iter<'ρ>(&self) -> impl Iterator<Item = VfsEntry<'ρ>> { 61 pub fn iter(&self) -> impl Iterator<Item = VfsEntry> {
62 self.data.iter().map(move |(file_id, _)| VfsEntry { 62 self.data.iter().map(move |(file_id, _)| VfsEntry {
63 file_id: *file_id, 63 file_id: *file_id,
64 file_path: self.file_path(*file_id), 64 file_path: self.file_path(*file_id),