Skip to content

Instantly share code, notes, and snippets.

@bh2smith
Created April 27, 2019 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bh2smith/af26bb187b1d1dbc1dc3f1963ac84052 to your computer and use it in GitHub Desktop.
Save bh2smith/af26bb187b1d1dbc1dc3f1963ac84052 to your computer and use it in GitHub Desktop.
Cargo Clippy on Driver
warning: long literal lacking separators
--> src/contract.rs:227:43
|
227 | options.gas = Some(U256::from(5000000));
| ^^^^^^^ help: consider: `5_000_000`
|
= note: #[warn(clippy::unreadable_literal)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal
warning: unneeded return statement
--> src/price_finding/linear_optimization_price_finder.rs:28:9
|
28 | / return LinearOptimisationPriceFinder {
29 | | num_tokens: models::TOKENS,
30 | | previous_prices: (0..models::TOKENS)
31 | | .map(|t| (token_id(t), "1000000000000000000".to_string()))
... |
35 | | read_output,
36 | | }
| |_________^
|
= note: #[warn(clippy::needless_return)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return` as shown
|
28 | LinearOptimisationPriceFinder {
29 | num_tokens: models::TOKENS,
30 | previous_prices: (0..models::TOKENS)
31 | .map(|t| (token_id(t), "1000000000000000000".to_string()))
32 | .collect(),
33 | write_input,
...
warning: unneeded unit return type
--> src/lib.rs:33:3
|
33 | ) -> () {
| ^^^^^ help: remove the `-> ()`
|
= note: #[warn(clippy::unused_unit)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
warning: redundant closure found
--> src/contract.rs:96:22
|
96 | .map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= note: #[warn(clippy::redundant_closure)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:102:26
|
102 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:108:26
|
108 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:114:26
|
114 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:120:26
|
120 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:126:26
|
126 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:132:26
|
132 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:138:26
|
138 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:144:26
|
144 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:150:26
|
150 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:156:26
|
156 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:162:26
|
162 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:168:26
|
168 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:174:26
|
174 | ).wait().map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:190:22
|
190 | .map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:212:22
|
212 | .map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/contract.rs:234:22
|
234 | .map_err(|e| DriverError::from(e))
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `DriverError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: length comparison to zero
--> src/db_interface.rs:85:12
|
85 | if docs.len() == 0 {
| ^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `docs.is_empty()`
|
= note: #[warn(clippy::len_zero)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
warning: you should consider adding a `Default` implementation for `price_finding::linear_optimization_price_finder::LinearOptimisationPriceFinder`
--> src/price_finding/linear_optimization_price_finder.rs:26:5
|
26 | / pub fn new() -> Self {
27 | | // All prices are 1 (10**18)
28 | | return LinearOptimisationPriceFinder {
29 | | num_tokens: models::TOKENS,
... |
36 | | }
37 | | }
| |_____^
|
= note: #[warn(clippy::new_without_default)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try this
|
25 | impl Default for price_finding::linear_optimization_price_finder::LinearOptimisationPriceFinder {
26 | fn default() -> Self {
27 | Self::new()
28 | }
29 | }
|
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/price_finding/linear_optimization_price_finder.rs:59:33
|
59 | fn serialize_balances(balances: &Vec<u128>, num_tokens: u8) -> serde_json::Value {
| ^^^^^^^^^^ help: change this to: `&[u128]`
|
= note: #[warn(clippy::ptr_arg)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
warning: redundant closure found
--> src/price_finding/linear_optimization_price_finder.rs:65:18
|
65 | .map(|t| token_id(t))
| ^^^^^^^^^^^^^^^ help: remove closure as shown: `token_id`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: useless use of `format!`
--> src/price_finding/linear_optimization_price_finder.rs:81:52
|
81 | .ok_or_else(|| PriceFindingError::new(&format!("Could not convert price to string"), ErrorKind::JsonError))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using .to_string(): `"Could not convert price to string".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
warning: redundant closure found
--> src/price_finding/linear_optimization_price_finder.rs:87:61
|
87 | .and_then(|price| price.parse::<u128>().map_err(|e| PriceFindingError::from(e)))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `PriceFindingError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/price_finding/linear_optimization_price_finder.rs:108:63
|
108 | .and_then(|amount| amount.parse::<u128>().map_err(|e| PriceFindingError::from(e)))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `PriceFindingError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/price_finding/linear_optimization_price_finder.rs:116:63
|
116 | .and_then(|amount| amount.parse::<u128>().map_err(|e| PriceFindingError::from(e)))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `PriceFindingError::from`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: redundant closure found
--> src/price_finding/linear_optimization_price_finder.rs:134:18
|
134 | .map(|t| token_id(t))
| ^^^^^^^^^^^^^^^ help: remove closure as shown: `token_id`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
warning: equality checks against true are unnecessary
--> src/price_finding/naive_solver.rs:124:16
|
124 | if found_flag == true {
| ^^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `found_flag`
|
= note: #[warn(clippy::bool_comparison)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/price_finding/price_finder_interface.rs:31:17
|
31 | orders: &Vec<models::Order>,
| ^^^^^^^^^^^^^^^^^^^ help: change this to: `&[models::Order]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/deposit_driver.rs:14:15
|
14 | deposits: &Vec<models::PendingFlux>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&[models::PendingFlux]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
warning: identical conversion
--> src/deposit_driver.rs:54:34
|
54 | let new_state_root = H256::from(updated_balances.rolling_hash());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `H256::from()`: `updated_balances.rolling_hash()`
|
= note: #[warn(clippy::identity_conversion)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion
warning: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> src/order_driver.rs:14:19
|
14 | price_finder: &mut Box<PriceFinding>
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut PriceFinding`
|
= note: #[warn(clippy::borrowed_box)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
warning: length comparison to zero
--> src/order_driver.rs:45:31
|
45 | let solution = if orders.len() > 0 {
| ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `!orders.is_empty()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
warning: identical conversion
--> src/order_driver.rs:65:34
|
65 | let new_state_root = H256::from(state.rolling_hash());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `H256::from()`: `state.rolling_hash()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/order_driver.rs:78:15
|
78 | balances: &Vec<u128>,
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
help: change this to
|
78 | balances: &[u128],
| ^^^^^^^
help: change `balances.clone()` to
|
82 | let mut result = balances.to_owned();
| ^^^^^^^^^^^^^^^^^^^
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/order_driver.rs:79:13
|
79 | orders: &Vec<Order>,
| ^^^^^^^^^^^ help: change this to: `&[Order]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/models.rs:14:38
|
14 | fn root_hash(&self, valid_items: &Vec<bool>) -> H256;
| ^^^^^^^^^^ help: change this to: `&[bool]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
warning: writing `&Vec<_>` instead of `&[_]` involves one more reference and cannot be used with non-Vec-based slices.
--> src/withdraw_driver.rs:13:16
|
13 | withdraws: &Vec<models::PendingFlux>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `&[models::PendingFlux]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
warning: identical conversion
--> src/withdraw_driver.rs:61:34
|
61 | let new_state_root = H256::from(updated_balances.rolling_hash());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `H256::from()`: `updated_balances.rolling_hash()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion
warning: local variable doesnt need to be boxed here
--> src/util.rs:9:5
|
9 | has_slot_been_applied: Box<&Fn(U256) -> Result<bool, DriverError>>
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(clippy::boxed_local)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local
warning: local variable doesnt need to be boxed here
--> src/util.rs:28:5
|
28 | creation_block: Box<&Fn(U256) -> Result<U256, DriverError>>,
| ^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local
warning: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> src/lib.rs:32:19
|
32 | price_finder: &mut Box<PriceFinding>,
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut PriceFinding`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
warning: use of `unwrap_or` followed by a function call
--> src/bin/main.rs:19:65
|
19 | let solver_env_var = env::var("LINEAR_OPTIMIZATION_SOLVER").unwrap_or("0".to_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|_| "0".to_string())`
|
= note: #[warn(clippy::or_fun_call)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call
Finished dev [unoptimized + debuginfo] target(s) in 2m 19s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment