Skip to content

Commit

Permalink
Cargo clipy
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed May 17, 2024
1 parent adec5bb commit d2c61a8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
7 changes: 6 additions & 1 deletion src/ignore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ impl Ignore {
}
}

pub fn get_ignore(line: &str, i: usize, ignore: Ignore, filename: &str) -> Ignore {
pub fn get_ignore(
line: &str,
i: usize,
ignore: Ignore,
filename: &str,
) -> Ignore {
let skip = contains_ignore_skip(line);
let start = contains_ignore_start(line);
let end = contains_ignore_end(line);
Expand Down
4 changes: 1 addition & 3 deletions src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ pub fn apply_indent(file: &str, filename: &str, args: &Cli) -> String {
);

if (indent.visual < 0) || (indent.actual < 0) {

log::warn!(
"{}tex-fmt {}{}: {}Line {}. \
{}Indent is negative: \
Expand All @@ -143,8 +142,7 @@ pub fn apply_indent(file: &str, filename: &str, args: &Cli) -> String {
YELLOW,
RESET,
line,
);

);
}

if !args.debug {
Expand Down
4 changes: 2 additions & 2 deletions src/print.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::colors::*;

pub fn print_script_name() {
println!("{}{}{}", PINK, "tex-fmt", RESET);
println!("{}tex-fmt{}", PINK, RESET);
}

pub fn print_filename(filename: &str) {
println!("{}{}{}{}{}", PINK, "tex-fmt ", PURPLE, filename, RESET);
println!("{}tex-fmt {}{}{}", PINK, PURPLE, filename, RESET);
}

pub fn print_file(new_file: &str) {
Expand Down
4 changes: 2 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_in_file(filename: &str, extension: &str) {
let out_filename = format!("tests/{}_out.{}", filename, extension);
let in_file = fs::read_to_string(&in_filename).expect("");
let out_file = fs::read_to_string(&out_filename).expect("");
let fmt_in_file = format_file(&in_file, &args);
let fmt_in_file = format_file(&in_file, &in_filename, &args);
assert!(fmt_in_file == out_file,
"\n{}Test failed: {}{}{} -> {}{}{}\n\n{}Output:\n{}{}{}\nDesired:\n{}{}",
&RED,
Expand All @@ -56,7 +56,7 @@ fn test_out_file(filename: &str, extension: &str) {
let args = Cli::new();
let out_filename = format!("tests/{}_out.{}", filename, extension);
let out_file = fs::read_to_string(&out_filename).expect("");
let fmt_out_file = format_file(&out_file, &args);
let fmt_out_file = format_file(&out_file, &out_filename, &args);
assert!(fmt_out_file == out_file,
"\n{}Test failed: {}{}{} -> {}{}{}\n\n{}Output:\n{}{}{}\nDesired:\n{}{}",
&RED,
Expand Down
12 changes: 5 additions & 7 deletions src/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ pub fn wrap(file: &str, filename: &str) -> String {
YELLOW,
RESET,
line,
);
);
}
}
}



new_file
}

Expand All @@ -122,22 +120,22 @@ fn test_wrap_line() {
Therefore it should be split.";
let s_out = "This line is too long because it has more than eighty characters inside it.\n \
Therefore it should be split.";
assert_eq!(wrap_line(s_in, 0), s_out);
assert_eq!(wrap_line(s_in), s_out);
// break before comment
let s_in = "This line is too long because it has more than eighty characters inside it. \
Therefore it % should be split.";
let s_out = "This line is too long because it has more than eighty characters inside it.\n \
Therefore it % should be split.";
assert_eq!(wrap_line(s_in, 0), s_out);
assert_eq!(wrap_line(s_in), s_out);
// break after comment
let s_in = "This line is too long because % it has more than eighty characters inside it. \
Therefore it should be split.";
let s_out = "This line is too long because % it has more than eighty characters inside it.\n\
% Therefore it should be split.";
assert_eq!(wrap_line(s_in, 0), s_out);
assert_eq!(wrap_line(s_in), s_out);
// leading spaces
let s_in = " Thislineistoolongbecauseithasmorethaneightycharactersinsideiteventhoughitstartswithspaces. \
Thereforeitshouldbesplit.";
let s_out = s_in;
assert_eq!(wrap_line(s_in, 0), s_out);
assert_eq!(wrap_line(s_in), s_out);
}
2 changes: 0 additions & 2 deletions tests/wrap_out.tex
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@
This line would usually be split at the special character part with a
slash\ but it's best to break the line earlier.

))

\end{document}

0 comments on commit d2c61a8

Please sign in to comment.