mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Fix clippy warnings (#3726)
This commit is contained in:
@@ -554,7 +554,11 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
||||
sql::housekeeping(&context).await.ok_or_log(&context);
|
||||
}
|
||||
"listchats" | "listarchived" | "chats" => {
|
||||
let listflags = if arg0 == "listarchived" { 0x01 } else { 0 };
|
||||
let listflags = if arg0 == "listarchived" {
|
||||
DC_GCL_ARCHIVED_ONLY
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let time_start = std::time::SystemTime::now();
|
||||
let chatlist = Chatlist::try_load(
|
||||
&context,
|
||||
|
||||
@@ -446,7 +446,7 @@ async fn handle_cmd(
|
||||
}
|
||||
println!("{}", qr);
|
||||
let output = Command::new("qrencode")
|
||||
.args(&["-t", "ansiutf8", qr.as_str(), "-o", "-"])
|
||||
.args(["-t", "ansiutf8", qr.as_str(), "-o", "-"])
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
io::stdout().write_all(&output.stdout).unwrap();
|
||||
|
||||
@@ -2439,7 +2439,7 @@ pub async fn get_chat_media(
|
||||
AND hidden=0
|
||||
ORDER BY timestamp, id;",
|
||||
paramsv![
|
||||
if chat_id.is_none() { 1i32 } else { 0i32 },
|
||||
chat_id.is_none(),
|
||||
chat_id.unwrap_or_else(|| ChatId::new(0)),
|
||||
msg_type,
|
||||
if msg_type2 != Viewtype::Unknown {
|
||||
|
||||
@@ -94,7 +94,7 @@ impl HtmlMsgParser {
|
||||
|
||||
let parsedmail = mailparse::parse_mail(rawmime)?;
|
||||
|
||||
parser.collect_texts_recursive(context, &parsedmail).await?;
|
||||
parser.collect_texts_recursive(&parsedmail).await?;
|
||||
|
||||
if parser.html.is_empty() {
|
||||
if let Some(plain) = &parser.plain {
|
||||
@@ -117,7 +117,6 @@ impl HtmlMsgParser {
|
||||
/// therefore we use the first one.
|
||||
fn collect_texts_recursive<'a>(
|
||||
&'a mut self,
|
||||
context: &'a Context,
|
||||
mail: &'a mailparse::ParsedMail<'a>,
|
||||
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a + Send>> {
|
||||
// Boxed future to deal with recursion
|
||||
@@ -125,7 +124,7 @@ impl HtmlMsgParser {
|
||||
match get_mime_multipart_type(&mail.ctype) {
|
||||
MimeMultipartType::Multiple => {
|
||||
for cur_data in mail.subparts.iter() {
|
||||
self.collect_texts_recursive(context, cur_data).await?
|
||||
self.collect_texts_recursive(cur_data).await?
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -135,7 +134,7 @@ impl HtmlMsgParser {
|
||||
return Ok(());
|
||||
}
|
||||
let mail = mailparse::parse_mail(&raw).context("failed to parse mail")?;
|
||||
self.collect_texts_recursive(context, &mail).await
|
||||
self.collect_texts_recursive(&mail).await
|
||||
}
|
||||
MimeMultipartType::Single => {
|
||||
let mimetype = mail.ctype.mimetype.parse::<Mime>()?;
|
||||
@@ -207,7 +206,7 @@ impl HtmlMsgParser {
|
||||
Ok(re) => {
|
||||
self.html = re
|
||||
.replace_all(
|
||||
&*self.html,
|
||||
&self.html,
|
||||
format!("${{1}}{}${{3}}", replacement).as_str(),
|
||||
)
|
||||
.as_ref()
|
||||
|
||||
@@ -18,7 +18,11 @@
|
||||
clippy::mixed_read_write_in_expression,
|
||||
clippy::bool_assert_comparison,
|
||||
clippy::manual_split_once,
|
||||
clippy::format_push_string
|
||||
clippy::format_push_string,
|
||||
clippy::bool_to_int_with_if,
|
||||
// This lint can be re-enabled once we don't target
|
||||
// Rust 1.56 anymore:
|
||||
clippy::collapsible_str_replace
|
||||
)]
|
||||
|
||||
#[macro_use]
|
||||
|
||||
@@ -1311,7 +1311,7 @@ impl<'a> MimeFactory<'a> {
|
||||
/// This line length limit is an
|
||||
/// [RFC5322 requirement](https://tools.ietf.org/html/rfc5322#section-2.1.1).
|
||||
fn wrapped_base64_encode(buf: &[u8]) -> String {
|
||||
let base64 = base64::encode(&buf);
|
||||
let base64 = base64::encode(buf);
|
||||
let mut chars = base64.chars();
|
||||
std::iter::repeat_with(|| chars.by_ref().take(78).collect::<String>())
|
||||
.take_while(|s| !s.is_empty())
|
||||
|
||||
@@ -44,12 +44,12 @@ impl PlainText {
|
||||
let line = line.to_string().replace('\r', "");
|
||||
|
||||
let mut line = LINKIFY_MAIL_RE
|
||||
.replace_all(&*line, "\rLTa href=\rQUOTmailto:$1\rQUOT\rGT$1\rLT/a\rGT")
|
||||
.replace_all(&line, "\rLTa href=\rQUOTmailto:$1\rQUOT\rGT$1\rLT/a\rGT")
|
||||
.as_ref()
|
||||
.to_string();
|
||||
|
||||
line = LINKIFY_URL_RE
|
||||
.replace_all(&*line, "\rLTa href=\rQUOT$1\rQUOT\rGT$1\rLT/a\rGT")
|
||||
.replace_all(&line, "\rLTa href=\rQUOT$1\rQUOT\rGT$1\rLT/a\rGT")
|
||||
.as_ref()
|
||||
.to_string();
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
||||
.await
|
||||
.with_context(|| format!("can't check if address {:?} is our address", addr))?
|
||||
{
|
||||
if token::exists(context, token::Namespace::InviteNumber, &*invitenumber).await {
|
||||
if token::exists(context, token::Namespace::InviteNumber, &invitenumber).await {
|
||||
Ok(Qr::WithdrawVerifyGroup {
|
||||
grpname,
|
||||
grpid,
|
||||
@@ -260,7 +260,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
||||
})
|
||||
}
|
||||
} else if context.is_self_addr(addr).await? {
|
||||
if token::exists(context, token::Namespace::InviteNumber, &*invitenumber).await {
|
||||
if token::exists(context, token::Namespace::InviteNumber, &invitenumber).await {
|
||||
Ok(Qr::WithdrawVerifyContact {
|
||||
contact_id,
|
||||
fingerprint,
|
||||
|
||||
@@ -57,7 +57,7 @@ impl From<&str> for Reaction {
|
||||
.split_ascii_whitespace()
|
||||
.filter(|&emoji| emoji.len() < 30)
|
||||
.collect();
|
||||
emojis.sort();
|
||||
emojis.sort_unstable();
|
||||
emojis.dedup();
|
||||
let reaction = emojis.join(" ");
|
||||
Self { reaction }
|
||||
@@ -84,7 +84,7 @@ impl Reaction {
|
||||
pub fn add(&self, other: Self) -> Self {
|
||||
let mut emojis: Vec<&str> = self.emojis();
|
||||
emojis.append(&mut other.emojis());
|
||||
emojis.sort();
|
||||
emojis.sort_unstable();
|
||||
emojis.dedup();
|
||||
let reaction = emojis.join(" ");
|
||||
Self { reaction }
|
||||
|
||||
@@ -1904,7 +1904,7 @@ async fn apply_mailinglist_changes(
|
||||
Contact::add_or_lookup(context, "", list_post, Origin::Hidden).await?;
|
||||
let mut contact = Contact::load_from_db(context, contact_id).await?;
|
||||
if contact.param.get(Param::ListId) != Some(listid) {
|
||||
contact.param.set(Param::ListId, &listid);
|
||||
contact.param.set(Param::ListId, listid);
|
||||
contact.update_param(context).await?;
|
||||
}
|
||||
|
||||
|
||||
@@ -405,7 +405,7 @@ impl Context {
|
||||
ret += " <b>";
|
||||
ret += &*escaper::encode_minimal(&foldername);
|
||||
ret += ":</b> ";
|
||||
ret += &*escaper::encode_minimal(&*detailed.to_string_imap(self).await);
|
||||
ret += &*escaper::encode_minimal(&detailed.to_string_imap(self).await);
|
||||
ret += "</li>";
|
||||
|
||||
folder_added = true;
|
||||
|
||||
@@ -272,7 +272,7 @@ pub(crate) fn create_id() -> String {
|
||||
rng.fill(&mut arr[..]);
|
||||
|
||||
// Take 11 base64 characters containing 66 random bits.
|
||||
base64::encode_config(&arr, base64::URL_SAFE)
|
||||
base64::encode_config(arr, base64::URL_SAFE)
|
||||
.chars()
|
||||
.take(11)
|
||||
.collect()
|
||||
|
||||
@@ -496,7 +496,7 @@ impl Context {
|
||||
for update_item in updates.updates {
|
||||
self.create_status_update_record(
|
||||
&mut instance,
|
||||
&*serde_json::to_string(&update_item)?,
|
||||
&serde_json::to_string(&update_item)?,
|
||||
timestamp,
|
||||
can_info_msg,
|
||||
from_id,
|
||||
@@ -545,7 +545,7 @@ impl Context {
|
||||
let (update_item_str, serial) = row;
|
||||
let update_item = StatusUpdateItemAndSerial
|
||||
{
|
||||
item: serde_json::from_str(&*update_item_str)?,
|
||||
item: serde_json::from_str(&update_item_str)?,
|
||||
serial,
|
||||
max_serial,
|
||||
};
|
||||
@@ -553,7 +553,7 @@ impl Context {
|
||||
if !json.is_empty() {
|
||||
json.push_str(",\n");
|
||||
}
|
||||
json.push_str(&*serde_json::to_string(&update_item)?);
|
||||
json.push_str(&serde_json::to_string(&update_item)?);
|
||||
}
|
||||
Ok(json)
|
||||
},
|
||||
@@ -1825,7 +1825,7 @@ sth_for_the = "future""#
|
||||
|
||||
let instance = t.get_last_msg().await;
|
||||
let html = instance.get_webxdc_blob(&t, "index.html").await?;
|
||||
assert!(String::from_utf8_lossy(&*html).contains("requires a newer Delta Chat version"));
|
||||
assert!(String::from_utf8_lossy(&html).contains("requires a newer Delta Chat version"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user