Skip to content

Commit 327a6a0

Browse files
committed
fix nits
1 parent 4578196 commit 327a6a0

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

check_diff/src/lib.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,16 @@ fn create_config_arg(config: &Option<Vec<String>>) -> String {
143143
let config_arg: String = match config {
144144
Some(configs) => {
145145
let mut result = String::new();
146-
result.push(',');
147146
for arg in configs.iter() {
148-
result.push_str(arg.as_str());
149147
result.push(',');
148+
result.push_str(arg.as_str());
150149
}
151-
result.pop();
152150
result
153151
}
154152
None => String::new(),
155153
};
156154
let config = format!(
157-
"error_on_line_overflow=false,error_on_unformatted=false{}",
155+
"--config=error_on_line_overflow=false,error_on_unformatted=false{}",
158156
config_arg.as_str()
159157
);
160158
config
@@ -361,22 +359,25 @@ fn search_for_rs_files(repo: &Path) -> impl Iterator<Item = PathBuf> {
361359

362360
pub fn check_diff(config: Option<Vec<String>>, runners: CheckDiffRunners, repo: &Path) -> i32 {
363361
let mut errors = 0;
364-
search_for_rs_files(repo).for_each(|file| match runners.create_diff(file.as_path(), &config) {
365-
Ok(diff) => {
366-
if !diff.is_empty() {
367-
eprint!("{diff}");
362+
let iter = search_for_rs_files(repo);
363+
for file in iter {
364+
match runners.create_diff(file.as_path(), &config) {
365+
Ok(diff) => {
366+
if !diff.is_empty() {
367+
eprint!("{diff}");
368+
errors += 1;
369+
}
370+
}
371+
Err(e) => {
372+
eprintln!(
373+
"Error creating diff for {:?}: {:?}",
374+
file.as_path().display(),
375+
e
376+
);
368377
errors += 1;
369378
}
370379
}
371-
Err(e) => {
372-
eprintln!(
373-
"Error creating diff for {:?}: {:?}",
374-
file.as_path().display(),
375-
e
376-
);
377-
errors += 1;
378-
}
379-
});
380+
}
380381

381382
return errors;
382383
}

0 commit comments

Comments
 (0)