Skip to content

Commit 13c119e

Browse files
committed
Fix clippy lints
1 parent cd0857b commit 13c119e

File tree

10 files changed

+51
-46
lines changed

10 files changed

+51
-46
lines changed

build.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
// You should have received a copy of the MIT License along with this software.
1010
// If not, see <https://opensource.org/licenses/MIT>.
1111

12-
use std::env;
13-
use std::fs;
12+
use std::{env, fs};
1413

1514
use clap::IntoApp;
1615
use clap_complete::generate_to;
@@ -35,9 +34,9 @@ fn main() -> Result<(), configure_me_codegen::Error> {
3534
fs::create_dir_all(outdir).expect("failed to create shell dir");
3635
for app in [rgbd::Opts::command(), bucketd::Opts::command()].iter_mut() {
3736
let name = app.get_name().to_string();
38-
generate_to(Bash, app, &name, &outdir)?;
39-
generate_to(PowerShell, app, &name, &outdir)?;
40-
generate_to(Zsh, app, &name, &outdir)?;
37+
generate_to(Bash, app, &name, outdir)?;
38+
generate_to(PowerShell, app, &name, outdir)?;
39+
generate_to(Zsh, app, &name, outdir)?;
4140
}
4241
// configure_me_codegen::build_script_auto()
4342
}

cli/build.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ fn main() -> Result<(), configure_me_codegen::Error> {
2727
if env::var("DOCS_RS").is_err() {
2828
let outdir = "../shell";
2929
fs::create_dir_all(outdir).expect("failed to create shell dir");
30-
for app in [cli::Opts::command()].iter_mut() {
31-
let name = app.get_name().to_string();
32-
generate_to(Bash, app, &name, &outdir)?;
33-
generate_to(PowerShell, app, &name, &outdir)?;
34-
generate_to(Zsh, app, &name, &outdir)?;
35-
}
30+
let mut app = cli::Opts::command();
31+
let name = app.get_name().to_string();
32+
generate_to(Bash, &mut app, &name, outdir)?;
33+
generate_to(PowerShell, &mut app, &name, outdir)?;
34+
generate_to(Zsh, &mut app, &name, outdir)?;
3635
}
3736
// configure_me_codegen::build_script_auto()
3837
Ok(())

cli/src/command.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl Exec for Opts {
239239

240240
let outpoints: BTreeSet<_> =
241241
psbt.inputs.iter().map(|input| input.previous_outpoint).collect();
242-
let state_map = client.outpoint_state(outpoints.clone(), progress)?;
242+
let state_map = client.outpoint_state(outpoints, progress)?;
243243
for (cid, outpoint_map) in state_map {
244244
if cid == contract_id {
245245
continue;
@@ -286,7 +286,7 @@ impl Exec for Opts {
286286
consignment,
287287
reveal,
288288
} => {
289-
let consignment = StateTransfer::strict_file_load(&consignment)?;
289+
let consignment = StateTransfer::strict_file_load(consignment)?;
290290
let status = client.consume_transfer(consignment, force, reveal, progress)?;
291291
report_validation(status);
292292
}

rpc/src/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,6 @@ impl esb::Handler<RpcBus> for Handler {
320320

321321
fn handle_err(&mut self, _: &mut Bus, err: esb::Error<ServiceId>) -> Result<(), Self::Error> {
322322
// We simply propagate the error since it already has been reported
323-
Err(err.into())
323+
Err(err)
324324
}
325325
}

rpc/src/error.rs

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ impl Display for FailureCode {
5252
impl From<u16> for FailureCode {
5353
fn from(value: u16) -> Self {
5454
match value {
55+
x if x == FailureCode::ChainMismatch as u16 => FailureCode::ChainMismatch,
56+
x if x == FailureCode::Encoding as u16 => FailureCode::Encoding,
57+
x if x == FailureCode::Esb as u16 => FailureCode::Esb,
58+
x if x == FailureCode::Store as u16 => FailureCode::Store,
59+
x if x == FailureCode::Stash as u16 => FailureCode::Stash,
60+
x if x == FailureCode::Absent as u16 => FailureCode::Absent,
61+
x if x == FailureCode::Finalize as u16 => FailureCode::Finalize,
62+
x if x == FailureCode::ElectrumConnectivity as u16 => FailureCode::ElectrumConnectivity,
63+
x if x == FailureCode::UnexpectedRequest as u16 => FailureCode::UnexpectedRequest,
64+
x if x == FailureCode::Launcher as u16 => FailureCode::Launcher,
5565
_ => FailureCode::Unknown,
5666
}
5767
}

rpc/src/reveal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ::core::str::FromStr for Reveal {
4343
return Err(ParseRevealError::TooLong);
4444
}
4545
let find_method = s.find('@');
46-
if find_method == None {
46+
if find_method.is_none() {
4747
return Err(ParseRevealError::Format);
4848
}
4949

@@ -53,7 +53,7 @@ impl ::core::str::FromStr for Reveal {
5353
}
5454

5555
let find_blind = s.find('#');
56-
if find_blind == None {
56+
if find_blind.is_none() {
5757
return Err(ParseRevealError::Format);
5858
}
5959

src/bucketd/processor.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl Runtime {
157157
let chunk = self
158158
.store
159159
.retrieve_chunk(storm_rpc::DB_TABLE_CHUNKS, chunk_id)?
160-
.expect(&format!("Chunk {} is absent", chunk_id));
160+
.unwrap_or_else(|| panic!("Chunk {} is absent", chunk_id));
161161
writer.write_all(chunk.as_slice()).expect("memory writers do not error");
162162
}
163163

@@ -227,7 +227,7 @@ impl Runtime {
227227
method: close_method,
228228
blinding: blinding_factor,
229229
txid: Some(outpoint.txid),
230-
vout: outpoint.vout as u32,
230+
vout: outpoint.vout,
231231
};
232232

233233
let concealed_seals = consignment
@@ -289,7 +289,7 @@ impl Runtime {
289289
method: close_method,
290290
blinding: blinding_factor,
291291
txid: Some(outpoint.txid),
292-
vout: outpoint.vout as u32,
292+
vout: outpoint.vout,
293293
};
294294

295295
let mut owned_rights: BTreeMap<OwnedRightType, TypedAssignments> = bmap! {};
@@ -400,7 +400,7 @@ impl Runtime {
400400
debug!("Processing state extension {}", node_id);
401401
trace!("State transition: {:?}", extension);
402402

403-
state.add_extension(&extension);
403+
state.add_extension(extension);
404404
trace!("Contract state now is {:?}", state);
405405

406406
self.store.store_sten(db::NODE_CONTRACTS, node_id, &contract_id)?;
@@ -425,7 +425,7 @@ impl Runtime {
425425
.retrieve_sten(db::DISCLOSURES, txid)?
426426
.ok_or(StashError::DisclosureAbsent(txid))?;
427427

428-
for (_anchor_id, (anchor, bundle_map)) in disclosure.anchored_bundles() {
428+
for (anchor, bundle_map) in disclosure.anchored_bundles().values() {
429429
for (contract_id, bundle) in bundle_map {
430430
let mut state: ContractState = self
431431
.store

src/bucketd/service.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,8 @@ impl Runtime {
154154
_client_id: ClientId,
155155
message: RpcMsg,
156156
) -> Result<(), DaemonError> {
157-
match message {
158-
wrong_msg => {
159-
error!("Request is not supported by the RPC interface");
160-
return Err(DaemonError::wrong_esb_msg(ServiceBus::Rpc, &wrong_msg));
161-
}
162-
}
157+
error!("Request is not supported by the RPC interface");
158+
Err(DaemonError::wrong_esb_msg(ServiceBus::Rpc, &message))
163159
}
164160

165161
fn handle_ctl(

src/db.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
// You should have received a copy of the MIT License along with this software.
99
// If not, see <https://opensource.org/licenses/MIT>.
1010

11-
pub const SCHEMATA: &'static str = "schemata";
12-
pub const CONTRACTS: &'static str = "contracts";
13-
pub const BUNDLES: &'static str = "bundles";
14-
pub const GENESIS: &'static str = "genesis";
15-
pub const TRANSITIONS: &'static str = "transitions";
16-
pub const ANCHORS: &'static str = "anchors";
17-
pub const EXTENSIONS: &'static str = "extensions";
18-
pub const ALU_LIBS: &'static str = "alu";
19-
20-
pub const OUTPOINTS: &'static str = "outpoints";
21-
pub const NODE_CONTRACTS: &'static str = "node_contracts";
22-
pub const TRANSITION_WITNESS: &'static str = "transition_txid";
23-
pub const CONTRACT_TRANSITIONS: &'static str = "contract_transitions";
24-
25-
pub const DISCLOSURES: &'static str = "disclosures";
11+
pub const SCHEMATA: &str = "schemata";
12+
pub const CONTRACTS: &str = "contracts";
13+
pub const BUNDLES: &str = "bundles";
14+
pub const GENESIS: &str = "genesis";
15+
pub const TRANSITIONS: &str = "transitions";
16+
pub const ANCHORS: &str = "anchors";
17+
pub const EXTENSIONS: &str = "extensions";
18+
pub const ALU_LIBS: &str = "alu";
19+
20+
pub const OUTPOINTS: &str = "outpoints";
21+
pub const NODE_CONTRACTS: &str = "node_contracts";
22+
pub const TRANSITION_WITNESS: &str = "transition_txid";
23+
pub const CONTRACT_TRANSITIONS: &str = "contract_transitions";
24+
25+
pub const DISCLOSURES: &str = "disclosures";
2626

2727
// Storm intgration
28-
pub const ATTACHMENT_CHUNKS: &'static str = "chunks";
29-
pub const ATTACHMENT_INDEX: &'static str = "attachments";
30-
pub const ATTACHMENT_CONTAINER_HEADERS: &'static str = "container_headers";
31-
pub const ATTACHMENT_CONTAINERS: &'static str = "containers";
28+
pub const ATTACHMENT_CHUNKS: &str = "chunks";
29+
pub const ATTACHMENT_INDEX: &str = "attachments";
30+
pub const ATTACHMENT_CONTAINER_HEADERS: &str = "container_headers";
31+
pub const ATTACHMENT_CONTAINERS: &str = "containers";
3232

3333
pub(crate) trait StoreRpcExt {
3434
fn retrieve_sten<T>(

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
dead_code,
1919
//missing_docs
2020
)]
21+
#![allow(clippy::result_large_err)]
2122
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2223

2324
#[macro_use]

0 commit comments

Comments
 (0)