Skip to content

Commit 319e95f

Browse files
committed
Fix code formatting to pass CI checks
Applied cargo fmt to resolve formatting issues in: - storage/gcs.rs: Fixed test code formatting and spacing - storage/factory.rs: Fixed test assertions and line breaks - vote.rs: Fixed import statement formatting - ledger.rs: Applied general formatting fixes - ranked_vote.rs: Applied general formatting fixes
1 parent 7f54923 commit 319e95f

File tree

5 files changed

+120
-91
lines changed

5 files changed

+120
-91
lines changed

server/src/ledger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Ledger {
3838
if matching_objects.is_empty() {
3939
// Try partial hash matching for debugging
4040
let partial_matches: Vec<&String> =
41-
objects.iter().filter(|key| hash.len() >= 10 && key.contains(&hash[.. 10])).collect();
41+
objects.iter().filter(|key| hash.len() >= 10 && key.contains(&hash[..10])).collect();
4242

4343
tracing::warn!(
4444
"No exact hash matches found. Partial matches (first 10 chars): {:?}",

server/src/ranked_vote.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl RankedVote {
9090
let decoded =
9191
bs58::decode(&self.memo).into_vec().with_context(|| format!("failed to decode memo {} - bs58", &self.memo))?;
9292

93-
let value = &decoded[3 .. decoded[2] as usize + 3];
93+
let value = &decoded[3..decoded[2] as usize + 3];
9494

9595
let result =
9696
String::from_utf8(value.to_vec()).with_context(|| format!("failed to decode memo {} - from_utf8", &self.memo))?;
@@ -1001,13 +1001,13 @@ fn advance_voting(
10011001
if let Some((idx, cid)) = first_candidate {
10021002
// A valid candidate was found, but still look in the initial slice to find if
10031003
// some overvote or multiple blanks occured.
1004-
let initial_slice = &choices[.. idx];
1004+
let initial_slice = &choices[..idx];
10051005

10061006
if check_advance_rules(initial_slice, duplicate_policy, overvote, skipped_ranks).is_some() {
10071007
return None;
10081008
}
10091009

1010-
let final_slice = &choices[idx + 1 ..];
1010+
let final_slice = &choices[idx + 1..];
10111011
Some((*cid, final_slice.to_vec()))
10121012
} else {
10131013
None
@@ -1031,14 +1031,14 @@ fn advance_voting_initial(
10311031
if let Some(idx) = first_candidate {
10321032
// A valid candidate was found, but still look in the initial slice to find if
10331033
// some overvote or multiple blanks occured.
1034-
let initial_slice = &choices[.. idx];
1034+
let initial_slice = &choices[..idx];
10351035

10361036
if check_advance_rules(initial_slice, duplicate_policy, overvote, skipped_ranks).is_some() {
10371037
return None;
10381038
}
10391039

10401040
// This final slice includes the pivot element.
1041-
let final_slice = &choices[idx ..];
1041+
let final_slice = &choices[idx..];
10421042
Some(final_slice.to_vec())
10431043
} else {
10441044
None
@@ -1108,7 +1108,7 @@ fn checks(coll: &[Ballot], reg_candidates: &[Candidate], rules: &VoteRules) -> R
11081108
if let Some(initial_advance) = initial_advance_opt {
11091109
// Check the head of the ballot.
11101110
if let Some(Choice::Filled(cid)) = initial_advance.first() {
1111-
let candidates = RankedVoteCandidates { first_valid: *cid, rest: initial_advance[1 ..].to_vec() };
1111+
let candidates = RankedVoteCandidates { first_valid: *cid, rest: initial_advance[1..].to_vec() };
11121112
validated_votes.push(VoteInternal { candidates, count });
11131113
} else if let Some(Choice::Undeclared) = initial_advance.first() {
11141114
// Valid and first choice is undeclared. See if the rest is a valid vote.

server/src/storage/factory.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ mod tests {
4545
async fn test_create_gcs_provider_success() {
4646
let config = create_test_config("gcs", Some("test-project-123".to_string()));
4747
let result = create_storage_provider(&config).await;
48-
48+
4949
assert!(result.is_ok());
5050
let provider = result.unwrap();
5151
assert_eq!(provider.provider_name(), "Google Cloud Storage");
5252
}
5353

54-
#[tokio::test]
54+
#[tokio::test]
5555
async fn test_create_gcs_provider_missing_project_id() {
5656
let config = create_test_config("gcs", None);
5757
let result = create_storage_provider(&config).await;
58-
58+
5959
assert!(result.is_err());
6060
if let Err(error) = result {
6161
let error_msg = error.to_string();
@@ -74,15 +74,15 @@ mod tests {
7474
Err(_) => true, // Expected if AWS config is not available
7575
}
7676
});
77-
77+
7878
assert!(result.is_ok());
7979
}
8080

8181
#[tokio::test]
8282
async fn test_unsupported_storage_provider() {
8383
let config = create_test_config("unsupported", None);
8484
let result = create_storage_provider(&config).await;
85-
85+
8686
assert!(result.is_err());
8787
if let Err(error) = result {
8888
let error_msg = error.to_string();
@@ -95,7 +95,7 @@ mod tests {
9595
async fn test_empty_storage_provider() {
9696
let config = create_test_config("", None);
9797
let result = create_storage_provider(&config).await;
98-
98+
9999
assert!(result.is_err());
100100
if let Err(error) = result {
101101
let error_msg = error.to_string();
@@ -107,7 +107,7 @@ mod tests {
107107
async fn test_case_sensitive_storage_provider() {
108108
let config = create_test_config("GCS", Some("test-project".to_string()));
109109
let result = create_storage_provider(&config).await;
110-
110+
111111
// Should fail because we expect lowercase "gcs", not "GCS"
112112
assert!(result.is_err());
113113
if let Err(error) = result {

0 commit comments

Comments
 (0)