diff options
author | figsoda <[email protected]> | 2021-11-02 02:34:22 +0000 |
---|---|---|
committer | figsoda <[email protected]> | 2021-11-02 02:34:22 +0000 |
commit | 831bd7e91d1f97f565d6ea15d816e638a983ad00 (patch) | |
tree | c042af6b11ff77ac462c19f84bff748f210729cc | |
parent | 90ea9335b55efb38802a2983a58580b3bc568c5f (diff) |
apply clippy lints
-rw-r--r-- | bin/src/config.rs | 6 | ||||
-rw-r--r-- | bin/src/fix/single.rs | 3 | ||||
-rw-r--r-- | bin/src/lint.rs | 2 | ||||
-rw-r--r-- | bin/src/main.rs | 7 | ||||
-rw-r--r-- | bin/src/traits.rs | 5 | ||||
-rw-r--r-- | lib/src/lints/eta_reduction.rs | 4 | ||||
-rw-r--r-- | lib/src/lints/unquoted_splice.rs | 2 | ||||
-rw-r--r-- | macros/src/metadata.rs | 2 |
8 files changed, 14 insertions, 17 deletions
diff --git a/bin/src/config.rs b/bin/src/config.rs index 1649017..46bf60f 100644 --- a/bin/src/config.rs +++ b/bin/src/config.rs | |||
@@ -154,7 +154,7 @@ mod dirs { | |||
154 | } | 154 | } |
155 | 155 | ||
156 | fn parse_line_col(src: &str) -> Result<(usize, usize), ConfigErr> { | 156 | fn parse_line_col(src: &str) -> Result<(usize, usize), ConfigErr> { |
157 | let parts = src.split(","); | 157 | let parts = src.split(','); |
158 | match parts.collect::<Vec<_>>().as_slice() { | 158 | match parts.collect::<Vec<_>>().as_slice() { |
159 | [line, col] => { | 159 | [line, col] => { |
160 | let l = line | 160 | let l = line |
@@ -173,7 +173,7 @@ fn parse_warning_code(src: &str) -> Result<u32, ConfigErr> { | |||
173 | let mut char_stream = src.chars(); | 173 | let mut char_stream = src.chars(); |
174 | let severity = char_stream | 174 | let severity = char_stream |
175 | .next() | 175 | .next() |
176 | .ok_or(ConfigErr::InvalidWarningCode(src.to_owned()))? | 176 | .ok_or_else(|| ConfigErr::InvalidWarningCode(src.to_owned()))? |
177 | .to_ascii_lowercase(); | 177 | .to_ascii_lowercase(); |
178 | match severity { | 178 | match severity { |
179 | 'w' => char_stream | 179 | 'w' => char_stream |
@@ -187,7 +187,7 @@ fn parse_warning_code(src: &str) -> Result<u32, ConfigErr> { | |||
187 | fn build_ignore_set(ignores: &[String]) -> Result<GlobSet, GlobError> { | 187 | fn build_ignore_set(ignores: &[String]) -> Result<GlobSet, GlobError> { |
188 | let mut set = GlobSetBuilder::new(); | 188 | let mut set = GlobSetBuilder::new(); |
189 | for pattern in ignores { | 189 | for pattern in ignores { |
190 | let glob = GlobBuilder::new(&pattern).build()?; | 190 | let glob = GlobBuilder::new(pattern).build()?; |
191 | set.add(glob); | 191 | set.add(glob); |
192 | } | 192 | } |
193 | set.build() | 193 | set.build() |
diff --git a/bin/src/fix/single.rs b/bin/src/fix/single.rs index 15a2ef4..b91dc45 100644 --- a/bin/src/fix/single.rs +++ b/bin/src/fix/single.rs | |||
@@ -40,8 +40,7 @@ fn find(offset: TextSize, src: &str) -> Result<Report, SingleFixErr> { | |||
40 | rules | 40 | rules |
41 | .iter() | 41 | .iter() |
42 | .filter_map(|rule| rule.validate(&child)) | 42 | .filter_map(|rule| rule.validate(&child)) |
43 | .filter(|report| report.total_suggestion_range().is_some()) | 43 | .find(|report| report.total_suggestion_range().is_some()) |
44 | .next() | ||
45 | }), | 44 | }), |
46 | _ => None, | 45 | _ => None, |
47 | }) | 46 | }) |
diff --git a/bin/src/lint.rs b/bin/src/lint.rs index e889d31..b5856c1 100644 --- a/bin/src/lint.rs +++ b/bin/src/lint.rs | |||
@@ -16,7 +16,7 @@ pub fn lint(vfs_entry: VfsEntry) -> LintResult { | |||
16 | let error_reports = parsed | 16 | let error_reports = parsed |
17 | .errors() | 17 | .errors() |
18 | .into_iter() | 18 | .into_iter() |
19 | .map(|e| Report::from_parse_err(e)); | 19 | .map(Report::from_parse_err); |
20 | 20 | ||
21 | let reports = parsed | 21 | let reports = parsed |
22 | .node() | 22 | .node() |
diff --git a/bin/src/main.rs b/bin/src/main.rs index 31f6823..4090701 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs | |||
@@ -71,7 +71,7 @@ fn _main() -> Result<(), StatixErr> { | |||
71 | let single_fix_result = fix::single(line, col, &src)?; | 71 | let single_fix_result = fix::single(line, col, &src)?; |
72 | if single_config.diff_only { | 72 | if single_config.diff_only { |
73 | let text_diff = TextDiff::from_lines(src.as_str(), &single_fix_result.src); | 73 | let text_diff = TextDiff::from_lines(src.as_str(), &single_fix_result.src); |
74 | let old_file = format!("{}", path_id); | 74 | let old_file = path_id.to_string(); |
75 | let new_file = format!("{} [fixed]", path_id); | 75 | let new_file = format!("{} [fixed]", path_id); |
76 | println!( | 76 | println!( |
77 | "{}", | 77 | "{}", |
@@ -96,8 +96,7 @@ fn _main() -> Result<(), StatixErr> { | |||
96 | } | 96 | } |
97 | 97 | ||
98 | fn main() { | 98 | fn main() { |
99 | match _main() { | 99 | if let Err(e) = _main() { |
100 | Err(e) => eprintln!("{}", e), | 100 | eprintln!("{}", e); |
101 | _ => (), | ||
102 | } | 101 | } |
103 | } | 102 | } |
diff --git a/bin/src/traits.rs b/bin/src/traits.rs index a8ec70f..303d12d 100644 --- a/bin/src/traits.rs +++ b/bin/src/traits.rs | |||
@@ -101,8 +101,8 @@ fn write_errfmt<T: Write>( | |||
101 | let path = vfs.file_path(file_id); | 101 | let path = vfs.file_path(file_id); |
102 | for report in lint_result.reports.iter() { | 102 | for report in lint_result.reports.iter() { |
103 | for diagnostic in report.diagnostics.iter() { | 103 | for diagnostic in report.diagnostics.iter() { |
104 | let line = line(diagnostic.at.start(), &src); | 104 | let line = line(diagnostic.at.start(), src); |
105 | let col = column(diagnostic.at.start(), &src); | 105 | let col = column(diagnostic.at.start(), src); |
106 | writeln!( | 106 | writeln!( |
107 | writer, | 107 | writer, |
108 | "{filename}>{linenumber}:{columnnumber}:{errortype}:{errornumber}:{errormessage}", | 108 | "{filename}>{linenumber}:{columnnumber}:{errortype}:{errornumber}:{errormessage}", |
@@ -131,7 +131,6 @@ mod json { | |||
131 | use lib::Severity; | 131 | use lib::Severity; |
132 | use rnix::TextRange; | 132 | use rnix::TextRange; |
133 | use serde::Serialize; | 133 | use serde::Serialize; |
134 | use serde_json; | ||
135 | use vfs::ReadOnlyVfs; | 134 | use vfs::ReadOnlyVfs; |
136 | 135 | ||
137 | #[derive(Serialize)] | 136 | #[derive(Serialize)] |
diff --git a/lib/src/lints/eta_reduction.rs b/lib/src/lints/eta_reduction.rs index 9df3f1e..454c78f 100644 --- a/lib/src/lints/eta_reduction.rs +++ b/lib/src/lints/eta_reduction.rs | |||
@@ -67,7 +67,7 @@ impl Rule for EtaReduction { | |||
67 | let message = | 67 | let message = |
68 | format!( | 68 | format!( |
69 | "Found eta-reduction: `{}`", | 69 | "Found eta-reduction: `{}`", |
70 | replacement.text().to_string() | 70 | replacement.text() |
71 | ); | 71 | ); |
72 | Some(self.report().suggest(at, message, Suggestion::new(at, replacement))) | 72 | Some(self.report().suggest(at, message, Suggestion::new(at, replacement))) |
73 | } else { | 73 | } else { |
@@ -81,6 +81,6 @@ fn mentions_ident(ident: &Ident, node: &SyntaxNode) -> bool { | |||
81 | if let Some(node_ident) = Ident::cast(node.clone()) { | 81 | if let Some(node_ident) = Ident::cast(node.clone()) { |
82 | node_ident.as_str() == ident.as_str() | 82 | node_ident.as_str() == ident.as_str() |
83 | } else { | 83 | } else { |
84 | node.children().any(|child| mentions_ident(&ident, &child)) | 84 | node.children().any(|child| mentions_ident(ident, &child)) |
85 | } | 85 | } |
86 | } | 86 | } |
diff --git a/lib/src/lints/unquoted_splice.rs b/lib/src/lints/unquoted_splice.rs index 4700d31..ce269b6 100644 --- a/lib/src/lints/unquoted_splice.rs +++ b/lib/src/lints/unquoted_splice.rs | |||
@@ -46,7 +46,7 @@ impl Rule for UnquotedSplice { | |||
46 | if Dynamic::cast(node.clone()).is_some(); | 46 | if Dynamic::cast(node.clone()).is_some(); |
47 | then { | 47 | then { |
48 | let at = node.text_range(); | 48 | let at = node.text_range(); |
49 | let replacement = make::quote(&node).node().clone(); | 49 | let replacement = make::quote(node).node().clone(); |
50 | let message = "Consider quoting this splice expression"; | 50 | let message = "Consider quoting this splice expression"; |
51 | Some(self.report().suggest(at, message, Suggestion::new(at, replacement))) | 51 | Some(self.report().suggest(at, message, Suggestion::new(at, replacement))) |
52 | } else { | 52 | } else { |
diff --git a/macros/src/metadata.rs b/macros/src/metadata.rs index b41eb9c..98e2a72 100644 --- a/macros/src/metadata.rs +++ b/macros/src/metadata.rs | |||
@@ -156,7 +156,7 @@ impl<'μ> LintMeta<'μ> { | |||
156 | } | 156 | } |
157 | 157 | ||
158 | pub fn generate_meta_impl(struct_name: &Ident, meta: &RawLintMeta) -> TokenStream2 { | 158 | pub fn generate_meta_impl(struct_name: &Ident, meta: &RawLintMeta) -> TokenStream2 { |
159 | let not_raw = LintMeta::from_raw(&meta); | 159 | let not_raw = LintMeta::from_raw(meta); |
160 | let name_fn = not_raw.generate_name_fn(); | 160 | let name_fn = not_raw.generate_name_fn(); |
161 | let note_fn = not_raw.generate_note_fn(); | 161 | let note_fn = not_raw.generate_note_fn(); |
162 | let code_fn = not_raw.generate_code_fn(); | 162 | let code_fn = not_raw.generate_code_fn(); |