Skip to content

Fix clippy reported problems #49

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

Merged
merged 5 commits into from
Dec 21, 2018
Merged

Fix clippy reported problems #49

merged 5 commits into from
Dec 21, 2018

Conversation

d-e-s-o
Copy link
Contributor

@d-e-s-o d-e-s-o commented Dec 21, 2018

This change set fixes a couple of clippy reported problems that I noticed while integrating this package into one of my crates. While not all of them are serious, they should be pretty uncontroversial and at least the ignored write amount should definitely be fixed.

This change fixes occurrences flagged by the clippy lint
`single_char_pattern`. E.g.,

> warning: single-character string constant used as pattern
>  --> src/print.rs:6:29
>   |
> 6 |         if self.0.ends_with("\n") {
>   |                             ^^^^ help: try using a char instead: `'\n'`
>   |
>   = help: for further information visit
>     https://rust-lang-nursery.github.io/rust-clippy/master/index.html#single_char_pattern
This change fixes occurrences flagged by the clippy lint
`unused_io_amount`. E.g.,

> warning: handle written amount returned or use `Write::write_all` instead
>   --> src/help.rs:74:13
>    |
> 74 |             try!(buf.write(word.as_bytes()));
>    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>    |
>    = note: #[warn(clippy::unused_io_amount)] on by default
>    = help: for further information visit
>      https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unused_io_amount
This change fixes occurrences flagged by the clippy lint `len_zero`.
E.g.,

> warning: length comparison to one
>    --> src/parser.rs:694:12
>     |
> 694 |         if names.len() < 1 {
>     |            ^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `names.is_empty()`
>     |
>     = help: for further information visit
>       https://rust-lang-nursery.github.io/rust-clippy/master/index.html#len_zero
This change fixes occurrences flagged by the clippy lint
`write_with_newline`. E.g.,

> warning: using `write!()` with a format string that ends in a single
>          newline, consider using `writeln!()` instead
>    --> src/parser.rs:410:29
>     |
> 410 | /                             write!(self.stderr,
> 411 | |                                 "WARNING: Environment variable {}: {}\n",
> 412 | |                                 evar.name, err).ok();
>     | |_______________________________________________^
>     |
>     = note: #[warn(clippy::write_with_newline)] on by default
>     = help: for further information visit
>       https://rust-lang-nursery.github.io/rust-clippy/master/index.html#write_with_newline
This change fixes occurrences flagged by the clippy lint
`double_parens`. E.g.,

> warning: Consider removing unnecessary double parentheses
>   --> src/help.rs:38:36
>    |
> 38 |                 Some((idx, ch)) => ((idx, ch)),
>    |                                    ^^^^^^^^^^^
>    |
>    = note: #[warn(clippy::double_parens)] on by default
>    = help: for further information visit
>      https://rust-lang-nursery.github.io/rust-clippy/master/index.html#double_parens
@tailhook tailhook merged commit 3b3848a into tailhook:master Dec 21, 2018
@tailhook
Copy link
Owner

Looks god. Thanks!

@d-e-s-o d-e-s-o deleted the fix-clippy-reported-problems branch January 15, 2019 18:04
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.

2 participants