Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate tweaks #148

Merged
merged 6 commits into from
Jan 22, 2022
Merged

Validate tweaks #148

merged 6 commits into from
Jan 22, 2022

Conversation

jqnatividad
Copy link
Owner

Some tweaks:

  • apply clippy recommendations
  • rustfmt
  • use captured identifiers in format! strings
  • move progress bar finish outside loop

```warning: use of `unwrap_or` followed by a function call
  --> src/cmd/validate.rs:81:44
   |
81 |     let input_path: &str = &args.arg_input.unwrap_or("stdin.csv".to_string());
   |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "stdin.csv".to_string())`
   |
   = note: `#[warn(clippy::or_fun_call)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

warning: use of `unwrap_or` followed by a function call
  --> src/cmd/validate.rs:83:47
   |
83 |     let valid_suffix: &str = &args.flag_valid.unwrap_or("valid".to_string());
   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "valid".to_string())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

warning: use of `unwrap_or` followed by a function call
  --> src/cmd/validate.rs:86:51
   |
86 |     let invalid_suffix: &str = &args.flag_invalid.unwrap_or("invalid".to_string());
   |                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| "invalid".to_string())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

warning: `to_string` applied to a type that implements `Display` in `format!` args
   --> src/cmd/validate.rs:112:96
    |
112 | ...                   return fail!(format!("Cannot compile schema json. error: {}", e.to_string()));
    |                                                                                      ^^^^^^^^^^^^ help: remove this
    |
    = note: `#[warn(clippy::to_string_in_format_args)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args

warning: `to_string` applied to a type that implements `Display` in `format!` args
   --> src/cmd/validate.rs:118:89
    |
118 |                         return fail!(format!("Unable to parse schema json. error: {}", e.to_string()));
    |                                                                                         ^^^^^^^^^^^^ help: remove this
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args

warning: `to_string` applied to a type that implements `Display` in `format!` args
   --> src/cmd/validate.rs:123:77
    |
123 |                 return fail!(format!("Unable to retrieve json. error: {}", e.to_string()));
    |                                                                             ^^^^^^^^^^^^ help: remove this
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args

warning: `to_string` applied to a type that implements `Display` in `format!` args
   --> src/cmd/validate.rs:145:107
    |
145 |                     return fail!(format!("Unable to convert CSV to json. row: {}, error: {}", row_index, e.to_string()));
    |                                                                                                           ^^^^^^^^^^^^ help: remove this
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args

warning: `to_string` applied to a type that implements `Display` in `format!` args
   --> src/cmd/validate.rs:210:96
    |
210 |                     return fail!(format!("Unable to validate. row: {}, error: {}", row_index, e.to_string()));
    |                                                                                                ^^^^^^^^^^^^ help: remove this
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args

warning: useless use of `format!`
   --> src/cmd/validate.rs:242:19
    |
242 |         let msg = format!("Can't validate without schema, but csv looks good.");
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"Can't validate without schema, but csv looks good.".to_string()`
    |
    = note: `#[warn(clippy::useless_format)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

warning: this loop could be written as a `for` loop
   --> src/cmd/validate.rs:262:9
    |
262 |         while let Some((i, header)) = headers_iter.next() {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for (i, header) in headers_iter`
    |
    = note: `#[warn(clippy::while_let_on_iterator)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator

warning: writing `&String` instead of `&str` involves a new object where a slice will do
   --> src/cmd/validate.rs:520:19
    |
520 | fn load_json(uri: &String) -> Result<String> {
    |                   ^^^^^^^ help: change this to: `&str`
    |
    = note: `#[warn(clippy::ptr_arg)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

warning: `qsv` (bin "qsvlite") generated 11 warnings (7 duplicates)
warning: `qsv` (bin "qsv") generated 11 warnings (4 duplicates)

```
@jqnatividad jqnatividad merged commit a3c5093 into master Jan 22, 2022
@jqnatividad jqnatividad mentioned this pull request Jan 22, 2022
@jqnatividad jqnatividad deleted the validate_tweaks branch February 1, 2022 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant