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

chore: Fix remaining lint warnings #531

Merged
merged 3 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/src/sinks/gcp_pubsub.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ max_backoff = 100000
The GCP authentication process relies on the following conventions:

- If the `GOOGLE_APPLICATION_CREDENTIALS` environmental variable is specified, the value will be used as the file path to retrieve the JSON file with the credentials.
- If the server is running on GCP, the credentials will be retrieved from the metadata server.
- If the server is running on GCP, the credentials will be retrieved from the metadata server.
4 changes: 2 additions & 2 deletions src/bin/oura/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub(crate) fn command_definition<'a>() -> clap::Command<'a> {
clap::Arg::new("bearer")
.long("bearer")
.takes_value(true)
.possible_values(&["tcp", "unix"]),
.possible_values(["tcp", "unix"]),
)
.arg(clap::Arg::new("magic").long("magic").takes_value(true))
.arg(
Expand All @@ -184,7 +184,7 @@ pub(crate) fn command_definition<'a>() -> clap::Command<'a> {
clap::Arg::new("mode")
.long("mode")
.takes_value(true)
.possible_values(&["node", "client"]),
.possible_values(["node", "client"]),
)
.arg(
clap::Arg::new("output")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/oura/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
};

if let Err(err) = &result {
eprintln!("ERROR: {:#?}", err);
eprintln!("ERROR: {err:#?}");
process::exit(1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/bin/oura/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub(crate) fn command_definition<'a>() -> clap::Command<'a> {
clap::Arg::new("bearer")
.long("bearer")
.takes_value(true)
.possible_values(&["tcp", "unix"]),
.possible_values(["tcp", "unix"]),
)
.arg(clap::Arg::new("magic").long("magic").takes_value(true))
.arg(
Expand All @@ -166,6 +166,6 @@ pub(crate) fn command_definition<'a>() -> clap::Command<'a> {
clap::Arg::new("mode")
.long("mode")
.takes_value(true)
.possible_values(&["node", "client"]),
.possible_values(["node", "client"]),
)
}
2 changes: 1 addition & 1 deletion src/filters/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl FingerprintBuilder {
let slot = self.slot.ok_or("missing slot value")?;
let prefix = self.prefix.ok_or("missing prefix value")?;
let hash = murmur3::murmur3_x64_128(&mut Cursor::new(self.hasheable), self.seed)?;
Ok(format!("{}.{}.{}", slot, prefix, hash))
Ok(format!("{slot}.{prefix}.{hash}"))
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/mapper/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ fn relay_to_string(relay: &Relay) -> String {
};

match port {
Some(port) => format!("{}:{}", ip, port),
Some(port) => format!("{ip}:{port}"),
None => ip,
}
}
Relay::SingleHostName(port, host) => match port {
Some(port) => format!("{}:{}", host, port),
Some(port) => format!("{host}:{port}"),
None => host.clone(),
},
Relay::MultiHostName(host) => host.clone(),
Expand Down
6 changes: 3 additions & 3 deletions src/sinks/elastic/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ async fn index_event<'b>(
}
x => {
if let Ok(body) = response.text().await {
log::debug!("error response from ES: {}", body);
log::debug!("error response from ES: {body}");
}

Err(format!("response with status code {}", x))
Err(format!("response with status code {x}"))
}
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ pub fn writer_loop(
utils.track_sink_progress(&event);
}
Err(err) => {
format!("error indexing record in Elasticsearch: {}", err);
format!("error indexing record in Elasticsearch: {err}");
return Err(err);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/sinks/gcp_pubsub/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ use crate::{

async fn send_pubsub_msg(publisher: &Publisher, event: &Event) -> Result<(), crate::Error> {
let body = json!(event).to_string();
let mut msg = PubsubMessage::default();
msg.data = body.into();
let msg = PubsubMessage {
data: body.into(),
..Default::default()
};

publisher
.publish_immediately(vec![msg], None, None)
Expand Down
67 changes: 23 additions & 44 deletions src/sinks/terminal/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ impl LogLine {
"ENDBLK",
Color::DarkMagenta,
max_width,
format!(
"{{ slot: {}, hash: {}, number: {} }}",
slot,
hash,
number,
)),
format!("{{ slot: {slot}, hash: {hash}, number: {number} }}")),

EventData::Transaction(TransactionRecord {
total_output,
Expand All @@ -98,27 +93,21 @@ impl LogLine {
"TX",
Color::DarkBlue,
max_width,
format!(
"{{ total_output: {}, fee: {}, hash: {}, ttl: {:?} }}",
total_output, fee, hash, ttl
),
format!("{{ total_output: {total_output}, fee: {fee}, hash: {hash}, ttl: {ttl:?} }}"),
),
EventData::TransactionEnd(TransactionRecord { hash, .. }) => LogLine::new_raw(
source,
"ENDTX",
Color::DarkBlue,
max_width,
format!(
"{{ hash: {} }}",
hash
),
format!("{{ hash: {hash} }}"),
),
EventData::TxInput(TxInputRecord { tx_id, index }) => LogLine::new_raw(
source,
"STXI",
Color::Blue,
max_width,
format!("{{ tx_id: {}, index: {} }}", tx_id, index),
format!("{{ tx_id: {tx_id}, index: {index} }}"),
),
EventData::TxOutput(TxOutputRecord {
address, amount, ..
Expand All @@ -127,7 +116,7 @@ impl LogLine {
"UTXO",
Color::Blue,
max_width,
format!("{{ to: {}, amount: {} }}", address, amount),
format!("{{ to: {address}, amount: {amount} }}"),
),
EventData::OutputAsset(OutputAssetRecord {
policy,
Expand Down Expand Up @@ -166,7 +155,7 @@ impl LogLine {
"META",
Color::Yellow,
max_width,
format!("{{ label: {}, content: {} }}", label, content),
format!("{{ label: {label}, content: {content} }}"),
),
EventData::Mint(MintRecord {
policy,
Expand All @@ -178,72 +167,70 @@ impl LogLine {
Color::DarkGreen,
max_width,
format!(
"{{ policy: {}, asset: {}, quantity: {} }}",
policy, asset, quantity
),
"{{ policy: {policy}, asset: {asset}, quantity: {quantity} }}"),
),
EventData::NativeScript { policy_id, script } => LogLine::new_raw(
source,
"NATIVE",
Color::White,
max_width,
format!("{{ policy: {}, script: {} }}", policy_id, script),
format!("{{ policy: {policy_id}, script: {script} }}"),
),
EventData::PlutusScript { hash, .. } => LogLine::new_raw(
source,
"PLUTUS",
Color::White,
max_width,
format!("{{ hash: {} }}", hash),
format!("{{ hash: {hash} }}"),
),
EventData::PlutusDatum(PlutusDatumRecord { datum_hash, .. }) => LogLine::new_raw(
source,
"DATUM",
Color::White,
max_width,
format!("{{ hash: {} }}", datum_hash),
format!("{{ hash: {datum_hash} }}"),
),
EventData::PlutusRedeemer(PlutusRedeemerRecord { purpose, input_idx, .. }) => LogLine::new_raw(
source,
"REDEEM",
Color::White,
max_width,
format!("{{ purpose: {}, input: {} }}", purpose, input_idx),
format!("{{ purpose: {purpose}, input: {input_idx} }}"),
),
EventData::PlutusWitness(PlutusWitnessRecord { script_hash, .. }) => LogLine::new_raw(
source,
"WITNESS",
Color::White,
max_width,
format!("{{ plutus script: {} }}", script_hash ),
format!("{{ plutus script: {script_hash} }}"),
),
EventData::NativeWitness(NativeWitnessRecord { policy_id, .. }) => LogLine::new_raw(
source,
"WITNESS",
Color::White,
max_width,
format!("{{ native policy: {} }}", policy_id),
format!("{{ native policy: {policy_id} }}"),
),
EventData::VKeyWitness(VKeyWitnessRecord { vkey_hex, .. }) => LogLine::new_raw(
source,
"WITNESS",
Color::White,
max_width,
format!("{{ vkey: {} }}", vkey_hex),
format!("{{ vkey: {vkey_hex} }}"),
),
EventData::StakeRegistration { credential } => LogLine::new_raw(
source,
"STAKE+",
Color::Magenta,
max_width,
format!("{{ credential: {:?} }}", credential),
format!("{{ credential: {credential:?} }}"),
),
EventData::StakeDeregistration { credential } => LogLine::new_raw(
source,
"STAKE-",
Color::DarkMagenta,
max_width,
format!("{{ credential: {:?} }}", credential),
format!("{{ credential: {credential:?} }}"),
),
EventData::StakeDelegation {
credential,
Expand All @@ -253,7 +240,7 @@ impl LogLine {
"DELE",
Color::Magenta,
max_width,
format!("{{ credential: {:?}, pool: {} }}", credential, pool_hash),
format!("{{ credential: {credential:?}, pool: {pool_hash} }}"),
),
EventData::PoolRegistration {
operator,
Expand All @@ -272,16 +259,14 @@ impl LogLine {
Color::Magenta,
max_width,
format!(
"{{ operator: {}, pledge: {}, cost: {}, margin: {}, metadata: {:?} }}",
operator, pledge, cost, margin, pool_metadata
),
"{{ operator: {operator}, pledge: {pledge}, cost: {cost}, margin: {margin}, metadata: {pool_metadata:?} }}"),
),
EventData::PoolRetirement { pool, epoch } => LogLine::new_raw(
source,
"POOL-",
Color::DarkMagenta,
max_width,
format!("{{ pool: {}, epoch: {} }}", pool, epoch),
format!("{{ pool: {pool}, epoch: {epoch} }}"),
),
EventData::GenesisKeyDelegation { } => LogLine::new_raw(
source,
Expand All @@ -301,9 +286,7 @@ impl LogLine {
Color::Magenta,
max_width,
format!(
"{{ reserves: {}, treasury: {}, to_credentials: {:?}, to_other_pot: {:?} }}",
from_reserves, from_treasury, to_stake_credentials, to_other_pot
),
"{{ reserves: {from_reserves}, treasury: {from_treasury}, to_credentials: {to_stake_credentials:?}, to_other_pot: {to_other_pot:?} }}"),
),
EventData::RollBack {
block_slot,
Expand All @@ -313,14 +296,14 @@ impl LogLine {
"RLLBCK",
Color::Red,
max_width,
format!("{{ slot: {}, hash: {} }}", block_slot, block_hash),
format!("{{ slot: {block_slot}, hash: {block_hash} }}"),
),
EventData::Collateral { tx_id, index } => LogLine::new_raw(
source,
"COLLAT",
Color::Blue,
max_width,
format!("{{ tx_id: {}, index: {} }}", tx_id, index),
format!("{{ tx_id: {tx_id}, index: {index} }}"),
),
EventData::CIP25Asset(CIP25AssetRecord {
policy,
Expand Down Expand Up @@ -350,11 +333,7 @@ impl LogLine {
"CIP15",
Color::DarkYellow,
max_width,
format!(
"{{ voting key: {}, stake pub: {} }}",
voting_key,
stake_pub,
),
format!("{{ voting key: {voting_key}, stake pub: {stake_pub} }}"),
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sources/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ pub fn unknown_block_to_events(writer: &EventWriter, body: &Vec<u8>) -> Result<(
.ok_or_warn("error crawling babbage block for events");
}
x => {
return Err(format!("This version of Oura can't handle era: {}", x).into());
return Err(format!("This version of Oura can't handle era: {x}").into());
}
},
probe::Outcome::EpochBoundary => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl ChainWellKnownInfo {
TESTNET_MAGIC => Ok(Self::testnet()),
PREVIEW_MAGIC => Ok(Self::preview()),
PREPROD_MAGIC => Ok(Self::preprod()),
_ => Err(format!("can't identify chain from specified magic value: {}", magic).into()),
_ => Err(format!("can't identify chain from specified magic value: {magic}").into()),
}
}
}
Expand Down