Skip to content

Commit 5a0fff1

Browse files
committed
report all errors on command line
1 parent 2eacd13 commit 5a0fff1

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "enforcer"
3-
version = "0.8.5"
3+
version = "0.8.6"
44
authors = ["Oliver Mueller <oliver.mueller@gmail.com>"]
55

66
[dependencies]

src/check.rs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ fn check_content<'a>(input: &'a str,
2727
i += 1;
2828
if max_line_length.is_some() && line.len() > max_line_length.unwrap() {
2929
result |= LINE_TOO_LONG;
30+
let _ = logger.send(Some(format!("{}, line {}: error: LINE_TOO_LONG\n", filename, i)));
3031
}
3132
if line.ends_with(' ') || line.ends_with('\t') {
3233
result |= TRAILING_SPACES;
34+
let _ =
35+
logger.send(Some(format!("{}, line {}: error: TRAILING_SPACES\n", filename, i)));
3336
}
3437
if s == clean::TabStrategy::Untabify && line.contains("\t") {
3538
result |= HAS_TABS;
39+
let _ = logger.send(Some(format!("{}, line {}: error: HAS_TABS\n", filename, i)));
3640
}
3741
if line.as_bytes().iter().any(|x| *x > 127) {
3842
if verbose {
@@ -62,8 +66,10 @@ fn report_offending_line(path: &Path, logger: SyncSender<Option<String>>) -> std
6266
match line.ok() {
6367
Some(_) => i = i + 1,
6468
None => {
65-
let _ = logger.send(
66-
Some(format!("{}, line {}: error: non UTF-8 character in line\n", path.display(), i)));
69+
let _ =
70+
logger.send(Some(format!("{}, line {}: error: non UTF-8 character in line\n",
71+
path.display(),
72+
i)));
6773
}
6874
}
6975
}
@@ -96,26 +102,26 @@ pub fn check_path(path: &Path,
96102
s,
97103
logger.clone()));
98104
}
105+
let no_trailing_ws = if (check & TRAILING_SPACES) > 0 && clean {
106+
if verbose {
107+
let _ =
108+
logger.send(Some(format!("TRAILING_SPACES:[{}] -> removing\n",
109+
path.display())));
110+
}
111+
clean::remove_trailing_whitespaces(buffer)
112+
} else {
113+
buffer.to_string()
114+
};
115+
let res_string = if (check & HAS_TABS) > 0 && clean {
116+
if verbose {
117+
let _ = logger.send(Some(format!("HAS_TABS:[{}] -> converting to spaces\n",
118+
path.display())));
119+
}
120+
clean::space_tabs_conversion(no_trailing_ws, clean::TabStrategy::Untabify)
121+
} else {
122+
no_trailing_ws
123+
};
99124
if clean {
100-
let no_trailing_ws = if (check & TRAILING_SPACES) > 0 {
101-
if verbose {
102-
let _ = logger.send(Some(format!("TRAILING_SPACES:[{}] -> removing\n",
103-
path.display())));
104-
}
105-
clean::remove_trailing_whitespaces(buffer)
106-
} else {
107-
buffer.to_string()
108-
};
109-
let res_string = if (check & HAS_TABS) > 0 {
110-
if verbose {
111-
let _ = logger.send(Some(format!("HAS_TABS:[{}] -> converting to \
112-
spaces\n",
113-
path.display())));
114-
}
115-
clean::space_tabs_conversion(no_trailing_ws, clean::TabStrategy::Untabify)
116-
} else {
117-
no_trailing_ws
118-
};
119125
let mut file = try!(File::create(path));
120126
try!(file.write_all(res_string.as_bytes()));
121127
}

0 commit comments

Comments
 (0)