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

refactor(storage-proofs): fix clippy warnings #1147

Merged
merged 33 commits into from
Jun 18, 2020
Merged

refactor(storage-proofs): fix clippy warnings #1147

merged 33 commits into from
Jun 18, 2020

Commits on Jun 18, 2020

  1. style(storage-proofs): collapse else if block

    clippy emits error:
    
            error: this `else { if .. }` block can be collapsed
    
    Do what clippy suggests, collapse the else if block.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    6861b07 View commit details
    Browse the repository at this point in the history
  2. style(storage-proofs): remove unused import

    In test module we bring into scope `rand` but do not use
    it (thread_rng() is called using a qualified path).
    
    Remove the unused `rand` import.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    68ec2f7 View commit details
    Browse the repository at this point in the history
  3. refactor(storage-proofs): use iter() instead of into_iter()

    As suggested by clippy we can use `iter()` instead of `into_iter() in
    a bunch of places.`
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    339ed4e View commit details
    Browse the repository at this point in the history
  4. refactor(storage-proofs): use slice directly

    Clippy emits a bunch of warnings of type:
    
            warning: useless use of `vec!`
    
    And suggests that we can use a slice direcly
    
            help: you can use a slice directly: `&[None; 256]`
    
    Do as clippy suggests; use slices directly.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    6b00682 View commit details
    Browse the repository at this point in the history
  5. refactor(storage-proofs): use iterator instead of for loop

    Found with clippy; we are using a for loop but the current lint level
    requires us to use an iterator.
    
    As suggested; use an iterator instead of the for loop.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    8fc2a3e View commit details
    Browse the repository at this point in the history
  6. refactor(storage-proofs): remove unneeded mutable reference

    Found with clippy; `bytes_to_fr` does not need a mutable reference.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    a5ff82f View commit details
    Browse the repository at this point in the history
  7. refactor(storage-proofs): remove unnecessary into()

    Remove  unnecessary usage of `into()`, found by clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    71f094d View commit details
    Browse the repository at this point in the history
  8. refactor(storage-proofs): remove unnecessary clone()

    Remove  unnecessary usage of `clone()`, found by clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    5f5c4cd View commit details
    Browse the repository at this point in the history
  9. refactor(storage-proofs): remove reference from match pattern

    Clippy emits error:
    
            error: you don't need to add `&` to all patterns
    
    Along with the suggestion to dereference the expression instead of
    prefixing all patters with `&`.
    
    Do as suggested by clippy and dereference the expressions.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    b24a50a View commit details
    Browse the repository at this point in the history
  10. refactor(storage-proofs): use dedicated copied method

    Clippy emits two errors of type:
    
            error: You are using an explicit closure for copying elements
    
    Along with the suggestion to us `copied` instead. Do as clippy
    suggests.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    26f6675 View commit details
    Browse the repository at this point in the history
  11. refactor(storage-proofs): include function in criterion_group

    The function `pedersen_md_circuit_benchmark` is defined but not used,
    it appears that this function should be added to the `criterion_group`
    marcro call.
    
    Found by clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    8d1b060 View commit details
    Browse the repository at this point in the history
  12. refactor(storage-proofs): remove unnecessary use

    `tempfile` is brought into scope but is never used. Found by clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    1ca55ff View commit details
    Browse the repository at this point in the history
  13. refactor(storage-proofs): remove unnecessary ()

    Plain old `return;` is idiomatic Rust these days, found by clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    27a4174 View commit details
    Browse the repository at this point in the history
  14. refactor(storage-proofs): remove unused local variable

    We declare a local buffer and never use it. Found by clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    afadb20 View commit details
    Browse the repository at this point in the history
  15. refactor(storage-proofs): use separators

    Clippy emits error:
    
            error: long literal lacking separators
    
    Use separators, as suggested by clippy, to assist reading.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    097349c View commit details
    Browse the repository at this point in the history
  16. refactor(storage-proofs): pass unit directly

    Clippy emits warning:
    
            warning: passing a unit value to a function
    
    The argument in question is not actually used by the function
    `circuit` (if I've jumped to the correct definition).
    
    We can safely pass in unit `()` instead. Does this result in any loss
    of meaning?
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    747bbcc View commit details
    Browse the repository at this point in the history
  17. refactor(filecoin-proofs): use consistent underscoring

    Clippy emits warning
    
            warning: digits grouped inconsistently by underscores
    
    Add an underscore, as suggested, in order to be consistent.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    ff23373 View commit details
    Browse the repository at this point in the history
  18. refactor(filecoin-proofs): remove redundant import

    Import is unused; found by clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    c43cf3c View commit details
    Browse the repository at this point in the history
  19. refactor(filecoin-proofs): remove unnecessary into_iter()

    Clippy emits error:
    
            error: identical conversion
    
    Remove, as suggested by clippy, unnecessary `into_iter()`.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    5f80973 View commit details
    Browse the repository at this point in the history
  20. refactor(filecoin-proofs): use iterator instead of indexing

    Clippy emits error:
    
            error: the loop variable `i` is used to index `val`
    
    Use an iterator, as suggested, to loop over the arrays of bytes. Use
    combinators `skip` and `take` as needed.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    ea04524 View commit details
    Browse the repository at this point in the history
  21. refactor(filecoin-proofs): use _f64 type

    Clippy emits error:
    
            error: casting integer literal to `f64` is unnecessary
    
    Use `32_f64` as suggested instead of casting to an `f64`.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    6c2b6b3 View commit details
    Browse the repository at this point in the history
  22. refactor(filecoin-proofs): allow identity_op in test

    Clippy emits error:
    
      error: the operation is ineffective. Consider reducing it to `127`
    
    This is caused because we use `1 * 127` in order to be consistent with
    other usages i.e., `2 * 127` and `8 * 127`. Clippy is wrong in this
    instance, the ineffective operation makes the code easier to read.
    
    Instruct clippy to allow this lint.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    0e3fc2e View commit details
    Browse the repository at this point in the history
  23. refactor(filecoin-proofs): remove useless use of vec!

    Clippy emits warning/error;
    
            useless use of `vec!`
    
    Do as suggested by clippy and use a slice directly.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    108f8df View commit details
    Browse the repository at this point in the history
  24. refactor(filecoin-proofs): remove redundant clone

    Clippy emits warning:
    
            warning: redundant clone
    
    Do as clippy suggests; remove redundant calls to `clone()`
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    255d681 View commit details
    Browse the repository at this point in the history
  25. refactor(filecoin-proofs): remove clone on double reference

    Clippy emits error:
    
            error: using `clone` on a double-reference; this will copy the
            reference instead of cloning the inner type
    
    This error is caused by code that is mildly convoluted by the fact
    that the only method on  `TempDir` that returns a `PathBuf` consumes
    self. We cannot use that because at the call site we cannot consume
    the temp dir. To get around this we do a little dance of getting a
    reference to a `Path` and then calling `to_path_buf()` on it. We end
    up with code that looks kind of funky:
    
            self.cache_dire.path().to_path_buf()
    
    That's the best I could come up with :)
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    bd5c693 View commit details
    Browse the repository at this point in the history
  26. refactor(filecoin-proofs): use unwrap_or_else

    `unwrap_or_else()` is more performant than `unwrap_or`. Found by
    clippy.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    d30ab86 View commit details
    Browse the repository at this point in the history
  27. refactor(filecoin-proofs): use iter() directly

    Clippy emits warning:
    
            warning: this `.into_iter()` call is equivalent to `.iter()`
            and will not move the `slice`
    
    Do as clippy suggests and use `iter()` directly.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    f9d5822 View commit details
    Browse the repository at this point in the history
  28. refactor(filecoin-proofs): use write_all

    Clippy emits error:
    
     error: written amount is not handled. Use `Write::write_all` instead
    
    Use `write_all` as clippy suggests since we do not use the return
    result.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    3c2a891 View commit details
    Browse the repository at this point in the history
  29. refactor(filecoin-proofs): remove identical conversion

    Clippy emits warning:
    
            warning: identical conversion
    
    Remove the call to `into_iter()`, as suggested by clippy, and use
    `iter()`.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    61eed54 View commit details
    Browse the repository at this point in the history
  30. refactor(filecoin-proofs): no function call after expect

    Clippy emits error:
    
            error: use of `expect` followed by a function call
    
    Do as suggested by clippy and use `unwrap_or_else()` coupled with
    `panic!` instead of calling `format!` as an argument to `expect()`.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    6e198bb View commit details
    Browse the repository at this point in the history
  31. refactor(fil-proofs-tooling): add separators

    Clippy emits warning:
    
            warning: long literal lacking separators
    
    Add separators as suggested by clippy to assist reading.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    7aba1d0 View commit details
    Browse the repository at this point in the history
  32. refactor(fil-proofs-tooling): all clippy lint float_cmp

    We use a couple of strict float comparisons to test. In each case the
    strict comparison is ok.
    
    Add a lint ignore and also comment each site that does strict float
    comparison.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    ed71a56 View commit details
    Browse the repository at this point in the history
  33. refactor(storage-proofs): all clippy lint unit_arg

    We use the `black_box` function in a bunch of places, at times the
    function argument returns unit, this is to be expected since the
    argument is not used for its return value.
    
    Instruct clippy to set the `unit_arg` lint to allow.
    tcharding authored and cryptonemo committed Jun 18, 2020
    Configuration menu
    Copy the full SHA
    6aa355f View commit details
    Browse the repository at this point in the history