aboutsummaryrefslogtreecommitdiff
path: root/bin/src
diff options
context:
space:
mode:
authorfigsoda <[email protected]>2021-11-02 02:34:22 +0000
committerfigsoda <[email protected]>2021-11-02 02:34:22 +0000
commit831bd7e91d1f97f565d6ea15d816e638a983ad00 (patch)
treec042af6b11ff77ac462c19f84bff748f210729cc /bin/src
parent90ea9335b55efb38802a2983a58580b3bc568c5f (diff)
apply clippy lints
Diffstat (limited to 'bin/src')
-rw-r--r--bin/src/config.rs6
-rw-r--r--bin/src/fix/single.rs3
-rw-r--r--bin/src/lint.rs2
-rw-r--r--bin/src/main.rs7
-rw-r--r--bin/src/traits.rs5
5 files changed, 10 insertions, 13 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
156fn parse_line_col(src: &str) -> Result<(usize, usize), ConfigErr> { 156fn 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> {
187fn build_ignore_set(ignores: &[String]) -> Result<GlobSet, GlobError> { 187fn 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
98fn main() { 98fn 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)]