From 44e14fbfbae62a5d7c5c9a834bee00392a7221bd Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Sat, 6 Nov 2021 02:43:08 +1000 Subject: [PATCH] updated formatting options --- README.md | 11 ++++++++++- src/main.rs | 8 +++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e3518c8..13f77fc 100644 --- a/README.md +++ b/README.md @@ -199,10 +199,19 @@ number will be updated as follows: when adding the ability to exclude extensions, and when fif gained the ability to output a bash script rather than a list of invalid filenames). The MINOR version will also be bumped when increasing the MSRV. - The PATCH version will be bumped in all other cases, including minor feature additions (in the past, this has occurred -when adding features such as more output formats and the ignore flag). +when adding features such as more output formats and the "ignore unknown extensions" flag). If/when fif hits version 1.0, these rules will likely remain the same as they are now. +## Code style +fif is formatted with `rustfmt` using a nightly toolchain, specifically with the command `cargo +nightly fmt`. Tabs are +used for indentation, and are assumed to be two spaces wide. Lines are 120 characters wide. Braces are placed on the +same line (["OTBS"](https://en.wikipedia.org/wiki/Indentation_style#Variant:_1TBS_(OTBS)) format), except in the case of +`where` clauses in generic parameters. + +For more detailed information on the formatting rules used by this project, see the configured options in +[`rustfmt.toml`](https://gitlab.com/Lynnesbian/fif/-/blob/master/rustfmt.toml). + ## License Copyright (C) 2021 Lynnesbian diff --git a/src/main.rs b/src/main.rs index 764d8cb..7e7fdb2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -215,20 +215,18 @@ fn main() { } else { let mut buffered_stdout = BufWriter::new(stdout()); - let result = match args.output_format { + if match args.output_format { // TODO: simplify this to something like formats::write_all(args.output_format, ...) OutputFormat::Sh => formats::Shell.write_all(&mut buffered_stdout, &findings, &errors), OutputFormat::PowerShell => formats::PowerShell.write_all(&mut buffered_stdout, &findings, &errors), #[cfg(feature = "json")] OutputFormat::Json => formats::Json.write_all(&mut buffered_stdout, &findings, &errors), OutputFormat::Text => formats::Text.write_all(&mut buffered_stdout, &findings, &errors), - }; - - if result.is_err() { + }.is_err() { error!("Failed to write to stdout."); exit(exitcode::IOERR); } - + if buffered_stdout.flush().is_err() { error!("Failed to flush stdout."); exit(exitcode::IOERR);