Skip to content

Fix clippy warnings #744

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 1 commit into from
Jul 12, 2019
Merged

Fix clippy warnings #744

merged 1 commit into from
Jul 12, 2019

Conversation

traviscross
Copy link
Contributor

@traviscross traviscross commented Jul 11, 2019

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 HashMaps 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.

@Keats
Copy link
Collaborator

Keats commented Jul 11, 2019

In which version was copied added? I'll have a look at the CI failures for sass...

@traviscross
Copy link
Contributor Author

.copied went in (along with the updated clippy warning) in Rust v1.36.

rust-lang/rust#60333

@Keats
Copy link
Collaborator

Keats commented Jul 11, 2019

Ah I would probably remove that change then, I usually target a couple of versions older than the latest stable (currently 1.34). I'll add that copied change in a couple of months

@traviscross traviscross force-pushed the fix-clippy-warnings branch from 75a000b to a3707d3 Compare July 11, 2019 08:33
@traviscross
Copy link
Contributor Author

That works; I've updated the branch to use .cloned() instead for now, which still resolves the warnings without depending on a recent version of rustc.

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.
@traviscross traviscross force-pushed the fix-clippy-warnings branch from a3707d3 to 561ef14 Compare July 11, 2019 08:56
@traviscross
Copy link
Contributor Author

Doing a clean build revealed some other clippy warnings that this branch now also fixes.

@Keats Keats merged commit b75bf8c into getzola:next Jul 12, 2019
@Keats
Copy link
Collaborator

Keats commented Jul 12, 2019

Thanks!

Keats pushed a commit that referenced this pull request Jul 12, 2019
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.
Keats added a commit that referenced this pull request Sep 28, 2019
* chore: Update toml to 0.5 everywhere

Signed-off-by: Igor Gnatenko <[email protected]>

* v0.8.1

* Update cli-usage.md (#729)

* Update cli-usage.md

* clarify that it's only the links from markdown files that are being checked;

* Update LiveReload.js to v3.0.0 (#730)

* Mention the id variable for the anchor link template

Closes #727

* Update sitemaps namespace

Closes #722

* Add --open flag to serve command, to open URL in default browser (#739)

* Add --open flag to serve command, to open URL in default browser

* Mention serve --open flag in CLI documentation

* Fix warnings caused by unnecessary `mut` qualifiers (#735)

* Remove hardcoded DOCKER_TAG

Closes #732

* Add an option to hard link files from static/ instead of copying. (#723)

* Add hard_link_static config option.

* Copy or hardlink file depending on an argument.

Modify the call sites for `copy_file` to account for the extra argument.

* Plug the config setting through to copy_file.

Don't apply the config option to theme's static directory.

* Update documentation.

* Backticks make no sense in this comment.

* Addressing PR comments.

* Be consistent with argument naming.

* Start changelog

* Some updates

* Fix Netlify auto-deploy instructions

Closes #745

* 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.

* Do not load draft pages

Part fix of #742

* Add warning for old style internal link + fix one

* Add counts in zola check

Closes #726

* Update site summary in zola check

* Render draft pages in serve mode

* Update all themes

* Add tests for custom url scheme

* Update deps

* Add Tomorrow theme (#749)

* Do not use serve remove dir result

Closes #752

* fixed tags in draft not found error (#753)

* Update current year :) (#755)

* Set up CI with Azure Pipelines (#750)

* Set up CI with Azure Pipelines

[skip ci]

* Remove other CI + remove newline in anchor link tpl

* Some more Windows specific changes

* Remove all draft specific code

* Ensure public exists for search index

Closes #756

* Allow relative paths in new_file()/new_section() (#763)

These functions expect that file_path can have base_path stripped from
it, but during reloading they can be given relative paths.  Maybe this
behaviour varies between the notify backends?

This fixes two zola serve panics on FreeBSD (poll backend).

* Allow ignored_content to support markdown files (#759)

* Allow ignored_content to support markdown files

* Add test for markdown supported ignored_content

* Slugify given slugs as well

* Update deps

* Min version is now 1.35 it seems

* Update deps & re-render on anchor-link.html changes

Closes #719

* Allow multiple taxonomies with same name in different language

Closes #766

* Fix test

* Add back subsections in basic section ser

Closes #733

* cargo update

* Add trailing slash to multilingual section path (#772)

* Use fixed version for syntect

>3.2.0 has an updated onig version which requires llvm
which isn't built in azure pipelines in Windows

* Clarify a bit the pager term

Closes #775

* zola init works inside existing directories (closes #406) (#777)

* zola init works without argument (defaults to current directory)

* zola init works with existing folders (no non-hidden files permitted)

* Update zola init documentation

* [docs] Optional argument is on a separate line for clarity

* Add tests for init subcommand's respect of existing folders

* Add to changelog + rustfmt

* Add some more text to zola init

Closes #773

* Missing argument in resize_image docs (#778)

* Fix ToC generation for heading levels > 3 (bugfix) (#774)

* Fix ToC generation for heading levels > 3

* typo

* Add tests for deep ToCs

* Code style change

* Use new Tera escape_xml filter for xml files

* Add lang to get_taxonomy & get_taxonomy_url

* ADD: reload when themes change (#771)

* ADD: reload when themes change

close #713

* MOD: test can_detect_kind_of_changes

* Universalize the GitHub pages publishing scheme (#780)

Added instructions on how to publish to <username>.github.io or <org>.github.io by changing the publishing branch in the repo to `master`. This should work for any type of GitHub publishing, including custom domains.

Fixes #765

* Add one-dark syntax highlight theme (#784)

* Update changelog

* Add --drafts flag + rustfmt

* Update completions

* Process images on rebuild

Closes #790

* Fix the issue when checking the changes for multiple language section index file (#787)

* Fix the issue when checking the changes of multiple language section

* Fix crash of trans() function called on absent translation key (#793)

Add method get_translation(lang, key) into Config struct that retrieves
translated term from parsed configuration or error when either
desired language or key is missing.

Use the new method in Trans struct implementing global Tera function
trans().

Add unit test to cover both happy and error path for translation
retrieval in both config and templates crate.

* Fix the issue of generating the search index for multiple language (#794)

* fix the issue of generating the search index for multiple language

* updat docs for generating the search index for multiple language

* fix failed tests

* add tests for the search index of multiple language

* Remove pub visibility from Config::translations hash (#796)

The access to translations is not straightforward and requires checks if
language and key exists. It is better to forbit direct access to
attribute and provide method - `get_translation()` - that will handle
all details of key translations.

Remove unit tests that use direct access and test only public method.

* Add anchor existence checking to link_checker component (#786)

* Add anchor existant checking to link_checker component

* Oops, forgot some changes

* Drop scraper dependency and rework tests

* Handle name attributes

* Bump pulldown_cmark to version 0.6.0 (#797)

* Bump pulldown_cmark to version 0.6.0

* Rename headers to headings

* Update slotmap

* Mention feed_url in docs

* Only shrink when resizing with fit (#803)

* Ready for release

* Change release date
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