Skip to content

Commit

Permalink
💥 make clippy break CI
Browse files Browse the repository at this point in the history
  • Loading branch information
AucaCoyan committed Jun 10, 2023
1 parent f9c108a commit b50f26c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// set clippy to pedantic lint
#![warn(clippy::all, clippy::pedantic, clippy::cargo)]

use anyhow::Result;

#[derive(Debug)]
Expand Down
5 changes: 4 additions & 1 deletion src/formatting.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// set clippy to pedantic lint
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]

use crate::config::Config;
use log::trace;
use nu_parser::{flatten_block, parse, FlatShape};
Expand Down Expand Up @@ -80,7 +83,7 @@ pub fn format_inner(contents: &[u8], _config: &Config) -> Vec<u8> {
// The pipe is just a pipe `|`.
//
// return the pipe AND a space after that
out.extend("| ".to_string().bytes())
out.extend("| ".to_string().bytes());
}
FlatShape::External => {
// External are some key commands
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
//!
//! It does not do anything more than that, which makes it so fast.

// set clippy to pedantic lint
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]

use config::Config;
use formatting::format_inner;
use log::{debug, trace};
Expand All @@ -24,7 +27,7 @@ pub fn format_single_file(file: &PathBuf, config: &Config) {

// compare the contents
if formatted_bytes == contents {
debug!("File is formatted correctly.")
debug!("File is formatted correctly.");
}

// write down the file to path
Expand All @@ -33,7 +36,7 @@ pub fn format_single_file(file: &PathBuf, config: &Config) {
writer
.write_all(file_bites)
.expect("something went wrong writing");
trace!("written")
trace!("written");
}

pub fn format_string(input_string: &String, config: &Config) -> String {
Expand Down
30 changes: 14 additions & 16 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
//!
//! - `-v` or `--version` prints the version and exit

// set clippy to pedantic lint
#![warn(clippy::all, clippy::pedantic, clippy::cargo)]
// throw error if finds a broken link in doc
#![deny(rustdoc::broken_intra_doc_links)]
// or docs are missing for public members
Expand Down Expand Up @@ -81,15 +83,12 @@ fn main() -> Result<(), Box<dyn Error>> {
trace!("recieved cli.stdin: {:?}", cli.stdin);
trace!("recieved cli.config: {:?}", cli.config);

let cli_config = match cli.config {
None => Config::default(),
Some(input_cli) => {
todo!(
"cannot read from {:?} Reading a config from file not implemented!",
input_cli
)
}
};
let cli_config = cli.config.map_or_else(Config::default, |input_cli| {
todo!(
"cannot read from {:?} Reading a config from file not implemented!",
input_cli
)
});

// Note the deref and reborrow here to obtain a slice
// so rust doesnt complain for the [] arm
Expand Down Expand Up @@ -123,21 +122,20 @@ fn execute_string(string: Option<String>, options: &Config) -> Result<i32> {
/// Sends the files to format in lib.rs
fn execute_files(files: Vec<PathBuf>, options: &Config) -> Result<i32> {
// walk the files in the vec of files
for file in files.iter() {
for file in &files {
if !file.exists() {
eprintln!("Error: {} not found!", file.to_str().unwrap());
return Ok(FAILED_EXIT);
} else if file.is_dir() {
eprintln!(
"Error: {} is a directory. Please pass files only.",
file.to_str().unwrap()
"Error: {:?} is a directory. Please pass files only.",
file.to_str()
);
return Ok(FAILED_EXIT);
} else {
// send the file to lib.rs
println!("formatting file: {:?}", file);
format_single_file(file, options);
}
// send the file to lib.rs
println!("formatting file: {file:?}");
format_single_file(file, options);
}

Ok(SUCCESSFUL_EXIT)
Expand Down

0 comments on commit b50f26c

Please sign in to comment.