1 Commits

Author SHA1 Message Date
Erik Johnston
29037e3ca1 Fix clippy lints 2022-06-06 09:59:17 +01:00
9 changed files with 35 additions and 57 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"rust-analyzer.checkOnSave.command": "clippy"
}

View File

@@ -49,8 +49,8 @@ fn run_succeeds_without_crashing() {
let verify = true;
let config = Config::new(
db_url.clone(),
room_id.clone(),
db_url,
room_id,
output_file,
min_state_group,
groups_to_compress,
@@ -525,14 +525,14 @@ fn run_is_idempotent_when_run_on_whole_room() {
.unwrap();
let config2 = Config::new(
db_url.clone(),
room_id.clone(),
db_url,
room_id,
output_file2,
min_state_group,
groups_to_compress,
min_saved_rows,
max_state_group,
level_sizes.clone(),
level_sizes,
transactions,
graphs,
commit_changes,

View File

@@ -56,7 +56,7 @@ fn continue_run_called_twice_same_as_run() {
let start = Some(6);
let chunk_size = 7;
let level_info = chunk_stats_1.new_level_info.clone();
let level_info = chunk_stats_1.new_level_info;
// Run the compressor with those settings
let chunk_stats_2 = continue_run(start, chunk_size, &db_url, &room_id, &level_info).unwrap();

View File

@@ -181,12 +181,11 @@ impl<'a> Compressor<'a> {
panic!("Can only call `create_new_tree` once");
}
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
let pb: ProgressBar = if cfg!(feature = "no-progress-bars") {
ProgressBar::hidden()
} else {
pb = ProgressBar::new(self.original_state_map.len() as u64);
}
ProgressBar::new(self.original_state_map.len() as u64)
};
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);

View File

@@ -93,14 +93,7 @@ fn create_new_tree_does_nothing_if_already_compressed() {
for i in 0i64..=13i64 {
// edge from map
let pred_group = initial_edges.get(&i);
// Need Option<i64> not Option<&i64>
let prev;
match pred_group {
Some(i) => prev = Some(*i),
None => prev = None,
}
let prev = initial_edges.get(&i).copied();
// insert that edge into the initial map
initial.insert(

View File

@@ -54,7 +54,7 @@ fn get_head_returns_head() {
#[test]
fn has_space_returns_true_if_empty() {
let l = Level::new(15);
assert_eq!(l.has_space(), true);
assert!(l.has_space());
}
#[test]
@@ -65,7 +65,7 @@ fn has_space_returns_true_if_part_full() {
l.update(1, true);
l.update(143, true);
l.update(15, true);
assert_eq!(l.has_space(), true);
assert!(l.has_space());
}
#[test]
@@ -76,5 +76,5 @@ fn has_space_returns_false_if_full() {
l.update(3, true);
l.update(4, true);
l.update(5, true);
assert_eq!(l.has_space(), false);
assert!(!l.has_space());
}

View File

@@ -142,14 +142,7 @@ fn stats_correct_if_no_changes() {
for i in 0i64..=13i64 {
// edge from map
let pred_group = initial_edges.get(&i);
// Need Option<i64> not Option<&i64>
let prev;
match pred_group {
Some(i) => prev = Some(*i),
None => prev = None,
}
let prev = initial_edges.get(&i).copied();
// insert that edge into the initial map
initial.insert(

View File

@@ -372,12 +372,11 @@ fn get_initial_data_from_db(
// Copy the data from the database into a map
let mut state_group_map: BTreeMap<i64, StateGroupEntry> = BTreeMap::new();
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
let pb: ProgressBar = if cfg!(feature = "no-progress-bars") {
ProgressBar::hidden()
} else {
pb = ProgressBar::new_spinner();
}
ProgressBar::new_spinner()
};
pb.set_style(
ProgressStyle::default_spinner().template("{spinner} [{elapsed}] {pos} rows retrieved"),
);
@@ -537,12 +536,11 @@ pub fn send_changes_to_db(
debug!("Writing changes...");
// setup the progress bar
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
let pb: ProgressBar = if cfg!(feature = "no-progress-bars") {
ProgressBar::hidden()
} else {
pb = ProgressBar::new(old_map.len() as u64);
}
ProgressBar::new(old_map.len() as u64)
};
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);

View File

@@ -507,12 +507,11 @@ fn output_sql(
info!("Writing changes...");
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
let pb: ProgressBar = if cfg!(feature = "no-progress-bars") {
ProgressBar::hidden()
} else {
pb = ProgressBar::new(old_map.len() as u64);
}
ProgressBar::new(old_map.len() as u64)
};
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);
@@ -622,12 +621,11 @@ fn check_that_maps_match(
) {
info!("Checking that state maps match...");
let pb: ProgressBar;
if cfg!(feature = "no-progress-bars") {
pb = ProgressBar::hidden();
let pb: ProgressBar = if cfg!(feature = "no-progress-bars") {
ProgressBar::hidden()
} else {
pb = ProgressBar::new(old_map.len() as u64);
}
ProgressBar::new(old_map.len() as u64)
};
pb.set_style(
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
);
@@ -975,7 +973,6 @@ mod lib_tests {
#[test]
fn check_that_maps_match_returns_if_both_empty() {
check_that_maps_match(&BTreeMap::new(), &BTreeMap::new());
assert!(true);
}
#[test]
@@ -1008,7 +1005,6 @@ mod lib_tests {
}
check_that_maps_match(&old_map, &BTreeMap::new());
assert!(true);
}
#[test]
@@ -1044,7 +1040,6 @@ mod lib_tests {
}
check_that_maps_match(&BTreeMap::new(), &new_map);
assert!(true);
}
#[test]
@@ -1076,7 +1071,6 @@ mod lib_tests {
}
check_that_maps_match(&BTreeMap::new(), &old_map.clone());
assert!(true);
}
#[test]
@@ -1139,7 +1133,6 @@ mod lib_tests {
}
check_that_maps_match(&old_map, &new_map);
assert!(true);
}
#[test]
@@ -1221,7 +1214,6 @@ mod lib_tests {
);
check_that_maps_match(&old_map, &new_map);
assert!(true);
}
//TODO: tests for correct SQL code produced by output_sql
@@ -1311,7 +1303,7 @@ mod pyo3_tests {
.unwrap();
assert_eq!(config.db_url, db_url);
assert!(!config.output_file.is_none());
assert!(config.output_file.is_some());
assert_eq!(config.room_id, room_id);
assert_eq!(config.min_state_group, Some(3225));
assert_eq!(config.groups_to_compress, Some(970));