Fix Clippy warnings blocking release checks
Some checks failed
Validate authentication / Validate authentication (push) Failing after 1s
Some checks failed
Validate authentication / Validate authentication (push) Failing after 1s
This commit is contained in:
parent
e71d9c3118
commit
976ffde7a8
42 changed files with 315 additions and 346 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Contact {
|
||||
pub user_id: i64,
|
||||
pub principal: Option<iota_identity::PrincipalHandle>,
|
||||
|
|
@ -9,20 +9,6 @@ pub struct Contact {
|
|||
pub notifications_read_at: i64,
|
||||
}
|
||||
|
||||
impl Default for Contact {
|
||||
fn default() -> Self {
|
||||
Contact {
|
||||
user_id: 0,
|
||||
principal: None,
|
||||
user_name: None,
|
||||
created_at: 0,
|
||||
last_message_at: None,
|
||||
notifications: 0,
|
||||
notifications_read_at: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Contact {
|
||||
pub fn new(user_id: i64) -> Self {
|
||||
let created_at = std::time::SystemTime::now()
|
||||
|
|
|
|||
|
|
@ -682,12 +682,12 @@ pub fn load_users_sync() -> std::io::Result<()> {
|
|||
if content.trim().is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
if let Ok(parsed) = json::parse(&content) {
|
||||
if let json::JsonValue::Array(arr) = parsed {
|
||||
for j in arr.iter() {
|
||||
if let Some(up) = UserProfile::from_json(j) {
|
||||
try_add_user(up).map_err(|error| std::io::Error::other(error.to_string()))?;
|
||||
}
|
||||
if let Ok(parsed) = json::parse(&content)
|
||||
&& let json::JsonValue::Array(arr) = parsed
|
||||
{
|
||||
for j in arr.iter() {
|
||||
if let Some(up) = UserProfile::from_json(j) {
|
||||
try_add_user(up).map_err(|error| std::io::Error::other(error.to_string()))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ impl UserProfile {
|
|||
"username" => self.username.clone(),
|
||||
"public_key" => self.public_key.clone(),
|
||||
"created_at" => self.created_at,
|
||||
"storage" => used_dir_space(&format!("users/{}", self.user_id.to_string())),
|
||||
"storage" => used_dir_space(&format!("users/{}", self.user_id)),
|
||||
};
|
||||
if let Some(d) = &self.display_name {
|
||||
obj["display_name"] = d.clone().into();
|
||||
|
|
@ -113,7 +113,7 @@ impl UserProfile {
|
|||
pub fn randomize_reset_token(&mut self) -> String {
|
||||
let mut bytes = [0u8; 192];
|
||||
OsRng.fill(bytes.as_mut());
|
||||
let new_token = general_purpose::STANDARD.encode(&bytes);
|
||||
let new_token = general_purpose::STANDARD.encode(bytes);
|
||||
self.reset_token = Some(new_token.clone());
|
||||
new_token
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ pub struct CallEnvelope {
|
|||
pub fn store(envelope: &CallEnvelope, now: i64) -> Result<bool, StorageError> {
|
||||
db::with_immediate_transaction(|tx| {
|
||||
tx.execute("DELETE FROM call_envelopes WHERE expires_at <= ?1", [now])?;
|
||||
#[expect(clippy::type_complexity, reason = "tuple matches the selected database columns")]
|
||||
let existing: Option<(i64, i64, i64, String, i64, Vec<u8>, Vec<u8>, String)> = tx.query_row(
|
||||
"SELECT owner_omikron_id, inviter_id, created_at, secret_id, version_number, encrypted_secret, kem_ciphertext, wrapping_scheme FROM call_envelopes WHERE recipient_id = ?1 AND call_id = ?2",
|
||||
params![envelope.recipient_id, envelope.call_id],
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ impl MessageState {
|
|||
}
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::should_implement_trait,
|
||||
reason = "unknown stored states fall back rather than fail parsing"
|
||||
)]
|
||||
pub fn from_str(value: &str) -> Self {
|
||||
match value.to_lowercase().as_str() {
|
||||
"read" => MessageState::Read,
|
||||
|
|
@ -1024,6 +1028,10 @@ pub fn change_message_state_by_relay_id(
|
|||
})
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "explicit persisted receipt fields"
|
||||
)]
|
||||
pub fn record_message_receipt(
|
||||
storage_owner: i64,
|
||||
target_signer_id: i64,
|
||||
|
|
@ -1232,7 +1240,7 @@ pub fn change_message_state(
|
|||
tx.commit()?;
|
||||
Ok(())
|
||||
})
|
||||
.map_err(|e: StorageError| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))
|
||||
.map_err(|e: StorageError| std::io::Error::other(e.to_string()))
|
||||
}
|
||||
|
||||
fn load_reactions(
|
||||
|
|
@ -1275,10 +1283,9 @@ fn load_reactions(
|
|||
if reactions
|
||||
.iter()
|
||||
.any(|stored: &StoredReaction| stored.reaction == row.1.reaction)
|
||||
|| reactions.len() < MAX_UNIQUE_REACTIONS_PER_MESSAGE
|
||||
{
|
||||
reactions.push(row.1);
|
||||
} else if reactions.len() < MAX_UNIQUE_REACTIONS_PER_MESSAGE {
|
||||
reactions.push(row.1);
|
||||
}
|
||||
}
|
||||
Ok(map)
|
||||
|
|
|
|||
|
|
@ -127,16 +127,13 @@ pub struct RelayRouterSettings {
|
|||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Default)]
|
||||
pub enum WebMode {
|
||||
#[default]
|
||||
Disabled,
|
||||
Loopback,
|
||||
Network,
|
||||
}
|
||||
impl Default for WebMode {
|
||||
fn default() -> Self {
|
||||
Self::Disabled
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
|
@ -340,14 +337,14 @@ pub fn save_config() {
|
|||
|
||||
pub fn save_config_to(path: &Path) {
|
||||
if let Ok(yaml) = serde_yaml::to_string(&**CONFIG.load()) {
|
||||
if let Some(parent) = path.parent() {
|
||||
if let Err(error) = fs::create_dir_all(parent) {
|
||||
eprintln!(
|
||||
"Cannot create configuration directory {}: {error}",
|
||||
parent.display()
|
||||
);
|
||||
return;
|
||||
}
|
||||
if let Some(parent) = path.parent()
|
||||
&& let Err(error) = fs::create_dir_all(parent)
|
||||
{
|
||||
eprintln!(
|
||||
"Cannot create configuration directory {}: {error}",
|
||||
parent.display()
|
||||
);
|
||||
return;
|
||||
}
|
||||
if let Err(error) = iota_util::atomic_file::replace(path, yaml.as_bytes(), 3) {
|
||||
eprintln!("Cannot save {}: {error}", path.display());
|
||||
|
|
@ -495,8 +492,10 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn zero_ipc_capacity_is_rejected() {
|
||||
let mut config = IotaConfig::default();
|
||||
config.max_ipc_clients = 0;
|
||||
let config = IotaConfig {
|
||||
max_ipc_clients: 0,
|
||||
..IotaConfig::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
validate_config(&config),
|
||||
Err(ConfigError::InvalidMaxIpcClients)
|
||||
|
|
|
|||
|
|
@ -2116,7 +2116,7 @@ where
|
|||
let guard = shared
|
||||
.lock()
|
||||
.map_err(|e| format!("DB mutex poisoned: {:?}", e))?;
|
||||
f(&*guard).map_err(|e| e.to_string())
|
||||
f(&guard).map_err(|e| e.to_string())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ fn validate(user_id: i64, retention: MessageRetention) -> Result<(), StorageErro
|
|||
"invalid message storage policy owner".into(),
|
||||
));
|
||||
}
|
||||
if let MessageRetention::Duration { duration_ms } = retention {
|
||||
if !(MIN_RETENTION_DURATION_MS..=MAX_RETENTION_DURATION_MS).contains(&duration_ms) {
|
||||
return Err(StorageError::Other("invalid retention duration".into()));
|
||||
}
|
||||
if let MessageRetention::Duration { duration_ms } = retention
|
||||
&& !(MIN_RETENTION_DURATION_MS..=MAX_RETENTION_DURATION_MS).contains(&duration_ms)
|
||||
{
|
||||
return Err(StorageError::Other("invalid retention duration".into()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ fn validate(user_id: i64, blob_id: &str, blob: Option<&[u8]>) -> Result<(), Stor
|
|||
if blob_id.is_empty() || blob_id.len() > MAX_BLOB_ID_BYTES {
|
||||
return Err(StorageError::Other("invalid blob id".into()));
|
||||
}
|
||||
if let Some(blob) = blob {
|
||||
if blob.len() > MAX_BLOB_BYTES {
|
||||
return Err(StorageError::Other("blob exceeds size limit".into()));
|
||||
}
|
||||
if let Some(blob) = blob
|
||||
&& blob.len() > MAX_BLOB_BYTES
|
||||
{
|
||||
return Err(StorageError::Other("blob exceeds size limit".into()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue