From d2c61a8c5010d7614c26cb292d81044787dc156a Mon Sep 17 00:00:00 2001 From: William G Underwood <42812654+WGUNDERWOOD@users.noreply.github.com> Date: Fri, 17 May 2024 00:25:13 -0400 Subject: [PATCH] Cargo clipy --- src/ignore.rs | 7 ++++++- src/indent.rs | 4 +--- src/print.rs | 4 ++-- src/tests.rs | 4 ++-- src/wrap.rs | 12 +++++------- tests/wrap_out.tex | 2 -- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/ignore.rs b/src/ignore.rs index 2a7e203..b9178c4 100644 --- a/src/ignore.rs +++ b/src/ignore.rs @@ -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); diff --git a/src/indent.rs b/src/indent.rs index c3173b0..b546a9e 100644 --- a/src/indent.rs +++ b/src/indent.rs @@ -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: \ @@ -143,8 +142,7 @@ pub fn apply_indent(file: &str, filename: &str, args: &Cli) -> String { YELLOW, RESET, line, - ); - + ); } if !args.debug { diff --git a/src/print.rs b/src/print.rs index c07930b..e95e747 100644 --- a/src/print.rs +++ b/src/print.rs @@ -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) { diff --git a/src/tests.rs b/src/tests.rs index 90747c2..6e7b8bc 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -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, @@ -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, diff --git a/src/wrap.rs b/src/wrap.rs index d1cebe4..773c88b 100644 --- a/src/wrap.rs +++ b/src/wrap.rs @@ -104,13 +104,11 @@ pub fn wrap(file: &str, filename: &str) -> String { YELLOW, RESET, line, - ); + ); } } } - - new_file } @@ -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); } diff --git a/tests/wrap_out.tex b/tests/wrap_out.tex index 552f4fd..70fda6f 100644 --- a/tests/wrap_out.tex +++ b/tests/wrap_out.tex @@ -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}