You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

check.rs 712B

Fix clippy warnings (#744) Clippy is returning some warnings. Let's fix or explicitly ignore them. In particular: - In `components/imageproc/src/lib.rs`, we implement `Hash` explicitly but derive `PartialEq`. We need to maintain the property that two keys being equal implies the hashes of those two keys are equal. Our `Hash` implementations preserve this, so we'll explicitly ignore the warnings. - In `components/site/src/lib.rs`, we were calling `.into()` on some values that are already of the correct type. - In `components/site/src/lib.rs`, we were using `.map(|x| *x)` in iterator chains to remove a level of indirection; we can instead say `.copied()` (introduced in Rust v1.36) or `.cloned()`. Using `.copied` here is better from a type-checking point of view, but we'll use `.cloned` for now as Rust v1.36 was only recently released. - In `components/templates/src/filters.rs` and `components/utils/src/site.rs`, we were taking `HashMap`s as function arguments but not generically accepting alternate `Hasher` implementations. - In `src/cmd/check.rs`, we use `env::current_dir()` as a default value, but our use of `unwrap_or` meant that we would always retrieve the current directory even when not needed. - In `components/errors/src/lib.rs`, we can use `if let` rather than `match`. - In `components/library/src/content/page.rs`, we can collapse a nested conditional into `else if let ...`. - In `components/library/src/sorting.rs`, a function takes `&&Page` arguments. Clippy warns about this for efficiency reasons, but we're doing it here to match a particular sorting API, so we'll explicitly ignore the warning.
4 years ago
1234567891011121314151617181920212223242526272829
  1. use std::env;
  2. use std::path::PathBuf;
  3. use errors::Result;
  4. use site::Site;
  5. use crate::console;
  6. pub fn check(
  7. config_file: &str,
  8. base_path: Option<&str>,
  9. base_url: Option<&str>,
  10. include_drafts: bool,
  11. ) -> Result<()> {
  12. let bp = base_path.map(PathBuf::from).unwrap_or_else(|| env::current_dir().unwrap());
  13. let mut site = Site::new(bp, config_file)?;
  14. // Force the checking of external links
  15. site.config.enable_check_mode();
  16. if let Some(b) = base_url {
  17. site.set_base_url(b.to_string());
  18. }
  19. if include_drafts {
  20. site.include_drafts();
  21. }
  22. site.load()?;
  23. console::check_site_summary(&site);
  24. console::warn_about_ignored_pages(&site);
  25. Ok(())
  26. }