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

Fix Clippy warnings #886

Merged
merged 1 commit into from
Dec 19, 2019
Merged

Fix Clippy warnings #886

merged 1 commit into from
Dec 19, 2019

Conversation

samford
Copy link
Contributor

@samford samford commented Dec 19, 2019

This fixes the following Clippy warnings:

warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
  --> components/front_matter/src/page.rs:90:17
   |
90 |                 DateTime::parse_from_rfc3339(&d).ok().and_then(|s| Some(s.naive_local()))
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `DateTime::parse_from_rfc3339(&d).ok().map(|s| s.naive_local())`
   |
   = note: `#[warn(clippy::option_and_then_some)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_and_then_some
warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
  --> components/front_matter/src/page.rs:92:17
   |
92 | /                 NaiveDate::parse_from_str(&d, "%Y-%m-%d")
93 | |                     .ok()
94 | |                     .and_then(|s| Some(s.and_hms(0, 0, 0)))
   | |___________________________________________________________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_and_then_some
help: try this
   |
92 |                 NaiveDate::parse_from_str(&d, "%Y-%m-%d")
93 |                     .ok().map(|s| s.and_hms(0, 0, 0))
   |
warning: useless use of `format!`
   --> components/library/src/pagination/mod.rs:193:13
    |
193 |             format!("{}", self.permalink)
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `self.permalink.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

I did not address the following Clippy warning, since it requires more architectural changes and I didn't want to make a decision on how to best approach it:

warning: this function has too many arguments (8/7)
   --> src/cmd/serve.rs:147:1
    |
147 | / pub fn serve(
148 | |     interface: &str,
149 | |     port: u16,
150 | |     output_dir: &str,
...   |
155 | |     include_drafts: bool,
156 | | ) -> Result<()> {
    | |_______________^
    |
    = note: `#[warn(clippy::too_many_arguments)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments

This addresses the following Clippy warnings:

* clippy::option_and_then_some
* clippy::useless_format
@Keats Keats merged commit b83321f into getzola:next Dec 19, 2019
@Keats
Copy link
Collaborator

Keats commented Dec 19, 2019

Thanks!

@samford samford deleted the fix-clippy-warnings branch December 19, 2019 14:27
Keats pushed a commit that referenced this pull request Feb 3, 2020
This addresses the following Clippy warnings:

* clippy::option_and_then_some
* clippy::useless_format
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