Skip to content

Commit a0e9f84

Browse files
committed
lint
1 parent a882adf commit a0e9f84

File tree

11 files changed

+41
-57
lines changed

11 files changed

+41
-57
lines changed

apps/log_parser/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ fn main() -> Result<()> {
6767
let (group, _) = bo.test_talk_in_new_group_with(&alix).await?;
6868
group.add_members(&[caro.inbox_id()]).await?;
6969

70-
alix.save_snapshot_to_file("alix.db3");
71-
tester!(alix2, snapshot_file: "alix.db3", stream);
70+
// alix.save_snapshot_to_file("alix.db3");
71+
// tester!(alix2, snapshot_file: "alix.db3", stream);
7272

7373
group.update_group_name("Fellows".into()).await?;
7474
caro.sync_all_welcomes_and_groups(None).await?;

apps/log_parser/src/state/assertions/account_for_drift.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl LogAssertion for AccountForDrift {
1414
let mut drift: HashMap<InstallationId, i64> = HashMap::new();
1515

1616
// Collect when all of the commits went out.
17-
for (_source, events) in &*sources {
17+
for events in sources.values() {
1818
for event in events {
1919
if !matches!(event.event, Event::GroupSyncStagedCommitPresent) {
2020
continue;
@@ -31,7 +31,7 @@ impl LogAssertion for AccountForDrift {
3131

3232
// Now find all commits that were received, and push the timeline forward until
3333
// they are AFTER when the commit is sent.
34-
for (_source, events) in &*sources {
34+
for events in sources.values() {
3535
for event in events {
3636
if !matches!(event.event, Event::MLSReceivedStagedCommit) {
3737
continue;
@@ -54,7 +54,7 @@ impl LogAssertion for AccountForDrift {
5454
}
5555
}
5656

57-
for (_source, events) in &*sources {
57+
for events in sources.values() {
5858
for event in events {
5959
let Some(&drift) = drift.get(&event.installation) else {
6060
continue;

apps/log_parser/src/state/assertions/build_timeline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ impl LogAssertion for BuildTimeline {
88
let groups = state.groups.lock();
99

1010
// Collect the states
11-
for (_group_id, group) in &*groups {
11+
for group in groups.values() {
1212
let mut group = group.lock();
1313

1414
let mut timeline = Vec::new();
1515
for state_map in &group.states {
16-
for (_installation_id, state) in state_map {
16+
for state in state_map.values() {
1717
timeline.push(StateOrEvent::State(state.clone()));
1818
}
1919
}

apps/log_parser/src/state/assertions/epoch_auth_consistency.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ impl LogAssertion for EpochAuthConsistency {
1212

1313
// First build the set
1414
for (group_id, inst_epochs) in &*epochs {
15-
for (_inst, epochs) in inst_epochs {
15+
for epochs in inst_epochs.values() {
1616
for (epoch_id, epoch) in &epochs.epochs {
1717
for state in &epoch.states {
1818
let state = state.lock();
1919
if let Some(auth) = &state.epoch_auth {
2020
let auths = auths
2121
.entry(format!("{group_id}-{epoch_id}"))
22-
.or_insert_with(|| HashSet::new());
22+
.or_insert_with(HashSet::new);
2323
if !auths.contains(auth) {
2424
auths.insert(auth.clone());
2525
}
@@ -31,23 +31,22 @@ impl LogAssertion for EpochAuthConsistency {
3131

3232
// Then check
3333
for (group_id, inst_epochs) in &*epochs {
34-
for (_inst, epochs) in inst_epochs {
34+
for epochs in inst_epochs.values() {
3535
for (epoch_id, epoch) in &epochs.epochs {
3636
for state in &epoch.states {
3737
let state = state.lock();
3838
if state.epoch.is_none() {
3939
continue;
4040
}
4141

42-
if let Some(auth) = auths.get(&format!("{group_id}-{epoch_id}")) {
43-
if auth.len() > 1 {
42+
if let Some(auth) = auths.get(&format!("{group_id}-{epoch_id}"))
43+
&& auth.len() > 1 {
4444
state
4545
.event
4646
.problems
4747
.lock()
48-
.push(format!("Multiple epoch auths among clients detected."));
48+
.push("Multiple epoch auths among clients detected.".to_string());
4949
}
50-
}
5150
}
5251
}
5352
}

apps/log_parser/src/state/assertions/epoch_continuity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl LogAssertion for EpochContinuityAssertion {
8181

8282
// Add the important non-group events.
8383
let mut outer_events = HashMap::new();
84-
for (_group_id, installation) in &mut *state.grouped_epochs.lock() {
84+
for installation in &mut state.grouped_epochs.lock().values_mut() {
8585
for (installation_id, epochs) in installation {
8686
let outer_events = outer_events
8787
.entry(installation_id.to_string())

apps/log_parser/src/state/assertions/flag_groups_for_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ impl LogAssertion for FlagGroupsForErrors {
88
fn assert(state: &State) -> Result<()> {
99
let groups = state.groups.lock();
1010

11-
for (_group_id, group) in &*groups {
11+
for group in groups.values() {
1212
let group = group.lock();
1313

1414
for event in &*group.timeline {

apps/log_parser/src/state/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl PartialEq for LogEvent {
3939

4040
impl PartialOrd for LogEvent {
4141
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
42-
self.time().partial_cmp(&other.time())
42+
Some(self.cmp(other))
4343
}
4444
}
4545

apps/log_parser/src/state/mod.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl State {
125125
let group = groups.get(group_id)?;
126126
let group = group.lock();
127127
for states_by_installation in &group.states {
128-
for (_installation_id, state) in states_by_installation {
128+
for state in states_by_installation.values() {
129129
let state = state.lock();
130130
if state.unique_id == unique_id {
131131
return Some(state.clone());
@@ -153,7 +153,7 @@ impl State {
153153

154154
{
155155
let sources = self.sources.lock();
156-
for (_source, events) in &*sources {
156+
for events in sources.values() {
157157
for event in events {
158158
if let Err(err) = self.ingest(event) {
159159
tracing::error!("Event ingest error: {err}");
@@ -231,8 +231,8 @@ impl State {
231231
}
232232
}
233233

234-
let mut group = client.group(group_id, &event);
235-
let mut group_state = group.new_event(&event);
234+
let mut group = client.group(group_id, event);
235+
let mut group_state = group.new_event(event);
236236

237237
if let Ok(epoch) = ctx("epoch").and_then(|e| e.as_int()) {
238238
// Reset the auth.
@@ -251,11 +251,8 @@ impl State {
251251
group_state.originator = Some(originator);
252252
}
253253

254-
match raw_event {
255-
Event::CreatedDM => {
256-
group_state.dm_target = Some(ctx("target_inbox")?.as_str()?.to_string());
257-
}
258-
_ => {}
254+
if raw_event == Event::CreatedDM {
255+
group_state.dm_target = Some(ctx("target_inbox")?.as_str()?.to_string());
259256
}
260257
}
261258
_ => {}

apps/log_parser/src/state/state_or_event.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl StateOrEvent {
1717
}
1818
}
1919

20-
pub fn event<'a>(&'a self) -> Arc<LogEvent> {
20+
pub fn event(&self) -> Arc<LogEvent> {
2121
match self {
2222
Self::State(state) => state.lock().event.clone(),
2323
Self::Event(event) => event.clone(),
@@ -53,24 +53,7 @@ impl Eq for StateOrEvent {}
5353

5454
impl PartialOrd for StateOrEvent {
5555
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
56-
let state;
57-
let event = match self {
58-
Self::Event(event) => event,
59-
Self::State(s) => {
60-
state = s.lock();
61-
&state.event
62-
}
63-
};
64-
65-
let other_state;
66-
let other_event = match other {
67-
Self::Event(e) => e,
68-
Self::State(s) => {
69-
other_state = s.lock();
70-
&other_state.event
71-
}
72-
};
73-
event.partial_cmp(other_event)
56+
Some(self.cmp(other))
7457
}
7558
}
7659
impl PartialEq for StateOrEvent {

apps/log_parser/src/state/ui/mod.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ impl State {
5555
let start = events_page * PAGE_SIZE;
5656
let end = ((events_page + 1) * PAGE_SIZE).min(total_events);
5757

58-
for event in client.events.iter().skip(start).take(end - start) {
58+
for event in client
59+
.events
60+
.iter()
61+
.skip(start)
62+
.take(end.saturating_sub(start))
63+
{
5964
let color = event.ui_group_color();
6065
stream.push(UIEvent {
6166
event: SharedString::from(event.msg),
@@ -83,7 +88,7 @@ impl State {
8388
let events_total_pages = if max_events_count == 0 {
8489
1
8590
} else {
86-
(max_events_count + PAGE_SIZE - 1) / PAGE_SIZE
91+
max_events_count.div_ceil(PAGE_SIZE)
8792
};
8893
ui.set_events_page(events_page as i32);
8994
ui.set_events_total_pages(events_total_pages as i32);
@@ -128,7 +133,7 @@ impl State {
128133
let groups_total_pages = if total_groups == 0 {
129134
1
130135
} else {
131-
(total_groups + PAGE_SIZE - 1) / PAGE_SIZE
136+
total_groups.div_ceil(PAGE_SIZE)
132137
};
133138

134139
let start = groups_page * PAGE_SIZE;
@@ -139,7 +144,7 @@ impl State {
139144

140145
// Sort epochs by epoch number
141146
let mut epoch_numbers = BTreeSet::new();
142-
for (_inst, epochs) in inst_epochs_map {
147+
for epochs in inst_epochs_map.values() {
143148
epoch_numbers.extend(epochs.epochs.keys());
144149
}
145150

@@ -215,7 +220,7 @@ impl State {
215220
} else {
216221
// No epoch data, but still drain outer events if this is the last epoch
217222
if i + 1 == epoch_numbers.len() {
218-
while let Some(event) = outer_events.next() {
223+
for event in outer_events.by_ref() {
219224
ui_states.push(event.ui_group_state());
220225
}
221226
}
@@ -390,7 +395,7 @@ impl State {
390395
group_id_short: SharedString::from(short_id(group_id)),
391396
group_color,
392397
installation_rows: ModelRc::new(VecModel::from(installation_rows)),
393-
total_entries: total_entries as i32,
398+
total_entries,
394399
total_slots,
395400
});
396401
}
@@ -434,7 +439,7 @@ impl LogEvent {
434439
.problems
435440
.lock()
436441
.iter()
437-
.map(|p| SharedString::from(p))
442+
.map(SharedString::from)
438443
.collect();
439444

440445
UITimelineEntry {
@@ -459,7 +464,7 @@ impl LogEvent {
459464
.problems
460465
.lock()
461466
.iter()
462-
.map(|p| SharedString::from(p))
467+
.map(SharedString::from)
463468
.collect();
464469

465470
UIGroupState {
@@ -483,7 +488,7 @@ impl GroupState {
483488
.problems
484489
.lock()
485490
.iter()
486-
.map(|p| SharedString::from(p))
491+
.map(SharedString::from)
487492
.collect();
488493

489494
UIGroupState {
@@ -511,7 +516,7 @@ impl GroupState {
511516
.problems
512517
.lock()
513518
.iter()
514-
.map(|p| SharedString::from(p))
519+
.map(SharedString::from)
515520
.collect();
516521

517522
UITimelineEntry {
@@ -538,7 +543,7 @@ impl GroupState {
538543
.problems
539544
.lock()
540545
.iter()
541-
.map(|p| SharedString::from(p))
546+
.map(SharedString::from)
542547
.collect();
543548

544549
UIGroupStateDetail {

0 commit comments

Comments
 (0)