Skip to content

Commit c6aa52d

Browse files
authored
chore: fix clippy (#4599)
* chore: fix clippy * WIP: allow dead code * chore: more fixes using all features * unused --------- Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
1 parent c2ab861 commit c6aa52d

File tree

62 files changed

+391
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+391
-407
lines changed

crates/cargo-builder/src/package.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ impl PackageInfo {
4747

4848
let package = if let Some(root_package) = metadata.root_package() {
4949
// we found a root project already, if the user is expecting something else raise an error
50-
if let Some(package_name) = &options.package_name {
51-
if package_name != &root_package.name {
52-
return Err(anyhow!(
53-
"Current package name ({}) does not match the supplied package name ({}).",
54-
root_package.name,
55-
package_name
56-
));
57-
}
50+
if let Some(package_name) = &options.package_name
51+
&& package_name != &root_package.name
52+
{
53+
return Err(anyhow!(
54+
"Current package name ({}) does not match the supplied package name ({}).",
55+
root_package.name,
56+
package_name
57+
));
5858
}
5959
root_package
6060
} else if let Some(package_name) = &options.package_name {

crates/fluvio-channel-cli/src/bin/main.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,12 @@ fn main() -> Result<()> {
290290
)
291291
};
292292

293-
if let RootCmd::Other(args) = channel_cli.command {
294-
if args.contains(&"update".to_string())
295-
&& fluvio_channel::is_pinned_version_channel(channel_name.as_str())
296-
{
297-
println!("Unsupported Feature: The `fluvio update` command is not supported use fvm");
298-
std::process::exit(1);
299-
}
293+
if let RootCmd::Other(args) = channel_cli.command
294+
&& args.contains(&"update".to_string())
295+
&& fluvio_channel::is_pinned_version_channel(channel_name.as_str())
296+
{
297+
println!("Unsupported Feature: The `fluvio update` command is not supported use fvm");
298+
std::process::exit(1);
300299
}
301300

302301
// Set env vars

crates/fluvio-channel-cli/src/cli/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ pub fn current_channel() -> String {
1313

1414
// Check if exe is in the standard fluvio home dir
1515
// If it isn't, assume dev channel
16-
if let Ok(exe) = std::env::current_exe() {
17-
if let Some(dir) = exe.parent() {
18-
if !cli_config_path.starts_with(dir) {
19-
return DEV_CHANNEL_NAME.to_string();
20-
}
21-
}
16+
if let Ok(exe) = std::env::current_exe()
17+
&& let Some(dir) = exe.parent()
18+
&& !cli_config_path.starts_with(dir)
19+
{
20+
return DEV_CHANNEL_NAME.to_string();
2221
}
2322

2423
// Open file

crates/fluvio-cli-common/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ fn main() {
22
#[cfg(feature = "version-cmd")]
33
{
44
// Copy VERSION file. Do not fail e.g. when built via `cargo publish`
5-
if let Ok(verpath) = std::fs::canonicalize("../../VERSION") {
6-
if verpath.exists() {
7-
println!("cargo:rerun-if-changed=../../VERSION");
8-
}
5+
if let Ok(verpath) = std::fs::canonicalize("../../VERSION")
6+
&& verpath.exists()
7+
{
8+
println!("cargo:rerun-if-changed=../../VERSION");
99
}
1010
println!("cargo:rerun-if-changed=build.rs");
1111

crates/fluvio-cli/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use std::process::Command;
22

33
fn main() {
44
// Copy VERSION file. Do not fail e.g. when built via `cargo publish`
5-
if let Ok(verpath) = std::fs::canonicalize("../../VERSION") {
6-
if verpath.exists() {
7-
println!("cargo:rerun-if-changed=../../VERSION");
8-
}
5+
if let Ok(verpath) = std::fs::canonicalize("../../VERSION")
6+
&& verpath.exists()
7+
{
8+
println!("cargo:rerun-if-changed=../../VERSION");
99
}
1010
println!("cargo:rerun-if-changed=build.rs");
1111

crates/fluvio-cli/src/client/consume/mod.rs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -368,19 +368,16 @@ mod cmd {
368368
builder.disable_continuous(true);
369369
}
370370

371-
if let Some(end_offset) = self.end {
372-
if let Some(start_offset) = self.start {
373-
if end_offset < start_offset {
374-
eprintln!(
375-
"Argument end-offset must be greater than or equal to specified start offset"
376-
);
377-
return Err(CliError::from(FluvioError::CrossingOffsets(
378-
start_offset,
379-
end_offset,
380-
))
381-
.into());
382-
}
383-
}
371+
if let Some(end_offset) = self.end
372+
&& let Some(start_offset) = self.start
373+
&& end_offset < start_offset
374+
{
375+
eprintln!(
376+
"Argument end-offset must be greater than or equal to specified start offset"
377+
);
378+
return Err(
379+
CliError::from(FluvioError::CrossingOffsets(start_offset, end_offset)).into(),
380+
);
384381
}
385382

386383
if let Some(isolation) = self.isolation {
@@ -507,12 +504,11 @@ mod cmd {
507504
&pb,
508505
);
509506

510-
if let Some(potential_offset) = maybe_potential_end_offset {
511-
if record.offset >= potential_offset as i64 {
507+
if let Some(potential_offset) = maybe_potential_end_offset
508+
&& record.offset >= potential_offset as i64 {
512509
eprintln!("End-offset has been reached; exiting");
513510
break;
514511
}
515-
}
516512
},
517513
None => break,
518514
},
@@ -567,12 +563,11 @@ mod cmd {
567563
&pb,
568564
);
569565

570-
if let Some(potential_offset) = maybe_potential_end_offset {
571-
if record.offset >= potential_offset as i64 {
566+
if let Some(potential_offset) = maybe_potential_end_offset
567+
&& record.offset >= potential_offset as i64 {
572568
eprintln!("End-offset has been reached; exiting");
573569
break;
574570
}
575-
}
576571
},
577572
None => break,
578573
},
@@ -584,12 +579,12 @@ mod cmd {
584579
}
585580
}
586581

587-
if let Some(ConsumeOutputType::full_table) = &self.output {
588-
if let Some(mut terminal_stdout) = maybe_terminal_stdout {
589-
disable_raw_mode()?;
590-
execute!(terminal_stdout.backend_mut(), LeaveAlternateScreen,)?;
591-
terminal_stdout.show_cursor()?;
592-
}
582+
if let Some(ConsumeOutputType::full_table) = &self.output
583+
&& let Some(mut terminal_stdout) = maybe_terminal_stdout
584+
{
585+
disable_raw_mode()?;
586+
execute!(terminal_stdout.backend_mut(), LeaveAlternateScreen,)?;
587+
terminal_stdout.show_cursor()?;
593588
}
594589

595590
debug!("fetch loop exited");
@@ -697,10 +692,10 @@ mod cmd {
697692
// (Some(_), None) only if JSON cannot be printed, so skip.
698693
_ => debug!("Skipping record that cannot be formatted"),
699694
}
700-
} else if let Some(term) = terminal {
701-
if let Some(table) = table_model {
702-
table.render(term);
703-
}
695+
} else if let Some(term) = terminal
696+
&& let Some(table) = table_model
697+
{
698+
table.render(term);
704699
}
705700
}
706701

crates/fluvio-cli/src/client/consume/table_format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ impl TableModel {
149149
let mut primary_keys = Vec::new();
150150

151151
for c in &self.columns {
152-
if let Some(is_primary_key) = c.primary_key {
153-
if is_primary_key {
154-
primary_keys.push(c.key_path.clone());
155-
}
152+
if let Some(is_primary_key) = c.primary_key
153+
&& is_primary_key
154+
{
155+
primary_keys.push(c.key_path.clone());
156156
}
157157
}
158158

crates/fluvio-cli/src/client/produce/mod.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,11 @@ mod cmd {
241241
let partitions_maps =
242242
Vec::<PartitionMap>::from(home_mirror_config.as_partition_maps());
243243
partitions_maps.iter().find_map(|p| {
244-
if let Some(PartitionMirrorConfig::Home(remote)) = &p.mirror {
245-
if remote.remote_cluster == *mirror && remote.source {
246-
return Some(p.id);
247-
}
244+
if let Some(PartitionMirrorConfig::Home(remote)) = &p.mirror
245+
&& remote.remote_cluster == *mirror
246+
&& remote.source
247+
{
248+
return Some(p.id);
248249
}
249250
None
250251
})
@@ -253,10 +254,11 @@ mod cmd {
253254
let partitions_maps =
254255
Vec::<PartitionMap>::from(remote_mirror_config.as_partition_maps());
255256
partitions_maps.iter().find_map(|p| {
256-
if let Some(PartitionMirrorConfig::Remote(remote)) = &p.mirror {
257-
if remote.home_cluster == *mirror && remote.target {
258-
return Some(p.id);
259-
}
257+
if let Some(PartitionMirrorConfig::Remote(remote)) = &p.mirror
258+
&& remote.home_cluster == *mirror
259+
&& remote.target
260+
{
261+
return Some(p.id);
260262
}
261263
None
262264
})
@@ -405,11 +407,11 @@ mod cmd {
405407
while let Some(Ok(line)) = lines.next() {
406408
let produce_output = self.produce_line(producer, &line).await?;
407409

408-
if let Some(produce_output) = produce_output {
409-
if self.delivery_semantic != DeliverySemantic::AtMostOnce {
410-
// ensure it was properly sent
411-
produce_output.wait().await?;
412-
}
410+
if let Some(produce_output) = produce_output
411+
&& self.delivery_semantic != DeliverySemantic::AtMostOnce
412+
{
413+
// ensure it was properly sent
414+
produce_output.wait().await?;
413415
}
414416

415417
if self.interactive_mode() {

crates/fluvio-cli/src/version.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ impl VersionOpt {
4545

4646
println!("{version_printer}");
4747

48-
if let Some(metadata) = self.format_subcommand_metadata() {
49-
if !metadata.is_empty() {
50-
println!("=== Plugin Versions ===");
48+
if let Some(metadata) = self.format_subcommand_metadata()
49+
&& !metadata.is_empty()
50+
{
51+
println!("=== Plugin Versions ===");
5152

52-
for (name, version) in metadata {
53-
self.print_width(&name, &version, 30);
54-
}
53+
for (name, version) in metadata {
54+
self.print_width(&name, &version, 30);
5555
}
5656
}
5757

@@ -80,11 +80,11 @@ impl VersionOpt {
8080
// Attempt to connect to a Fluvio cluster to get platform version
8181
// Even if we fail to connect, we should not fail the other printouts
8282
let mut platform_version = String::from("Not available");
83-
if let Ok(fluvio_config) = target.load() {
84-
if let Ok(fluvio) = Fluvio::connect_with_config(&fluvio_config).await {
85-
let version = fluvio.platform_version();
86-
platform_version = version.to_string();
87-
}
83+
if let Ok(fluvio_config) = target.load()
84+
&& let Ok(fluvio) = Fluvio::connect_with_config(&fluvio_config).await
85+
{
86+
let version = fluvio.platform_version();
87+
platform_version = version.to_string();
8888
}
8989

9090
let profile_name = ConfigFile::load(None)

crates/fluvio-cluster/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::process::Command;
22

33
fn main() {
4-
if let Ok(verpath) = std::fs::canonicalize("../../VERSION") {
5-
if verpath.exists() {
6-
println!("cargo:rerun-if-changed=../../VERSION");
7-
}
4+
if let Ok(verpath) = std::fs::canonicalize("../../VERSION")
5+
&& verpath.exists()
6+
{
7+
println!("cargo:rerun-if-changed=../../VERSION");
88
}
99
println!("cargo:rerun-if-changed=build.rs");
1010
println!("cargo:rerun-if-changed=../../k8-util/helm/pkg_sys/fluvio-chart-sys.tgz");

0 commit comments

Comments
 (0)