Browse Source

chore: Fix clippy warnings

Triggered by the `uninlined_format_args` lint in nightly
merge-requests/1327/merge
Kévin Commaille 3 years ago committed by Kévin Commaille
parent
commit
96237c5271
  1. 3
      src/components/auth_dialog.rs
  2. 4
      src/components/badge.rs
  3. 4
      src/components/video_player.rs
  4. 2
      src/login/homeserver_page.rs
  5. 2
      src/login/method_page.rs
  6. 6
      src/session/avatar.rs
  7. 2
      src/session/content/room_details/general_page/mod.rs
  8. 2
      src/session/content/room_details/member_page/members_list_view/membership_subpage_row.rs
  9. 2
      src/session/content/room_history/message_row/text.rs
  10. 18
      src/session/content/verification/identity_verification_widget.rs
  11. 2
      src/session/media_viewer.rs
  12. 2
      src/session/sidebar/row.rs
  13. 2
      src/utils/matrix.rs
  14. 2
      src/utils/media.rs
  15. 2
      src/utils/mod.rs

3
src/components/auth_dialog.rs

@ -366,8 +366,7 @@ impl AuthDialog {
}
let uri = format!(
"{}_matrix/client/r0/auth/{}/fallback/web?session={}",
homeserver, auth_type, session
"{homeserver}_matrix/client/r0/auth/{auth_type}/fallback/web?session={session}"
);
let handler = imp

4
src/components/badge.rs

@ -94,13 +94,13 @@ impl Badge {
match role {
MemberRole::ADMIN => {
label.set_text(&format!("{} {}", role, power_level));
label.set_text(&format!("{role} {power_level}"));
self.add_css_class("admin");
self.remove_css_class("mod");
self.show();
}
MemberRole::MOD => {
label.set_text(&format!("{} {}", role, power_level));
label.set_text(&format!("{role} {power_level}"));
self.add_css_class("mod");
self.remove_css_class("admin");
self.show();

4
src/components/video_player.rs

@ -162,11 +162,11 @@ impl VideoPlayer {
if hour > 0 {
// FIXME: Find how to localize this.
// hour:minutes:seconds
format!("{}:{:02}:{:02}", hour, min, sec)
format!("{hour}:{min:02}:{sec:02}")
} else {
// FIXME: Find how to localize this.
// minutes:seconds
format!("{:02}:{:02}", min, sec)
format!("{min:02}:{sec:02}")
}
} else {
"--:--".to_owned()

2
src/login/homeserver_page.rs

@ -163,6 +163,6 @@ fn build_homeserver_url(server: &str) -> Result<Url, ParseError> {
if server.starts_with("http://") || server.starts_with("https://") {
Url::parse(server)
} else {
Url::parse(&format!("https://{}", server))
Url::parse(&format!("https://{server}"))
}
}

2
src/login/method_page.rs

@ -159,7 +159,7 @@ impl LoginMethodPage {
"Connecting to {domain_name}",
&[(
"domain_name",
&format!("<span segment=\"word\">{}</span>", domain_name),
&format!("<span segment=\"word\">{domain_name}</span>"),
)],
))
}

6
src/session/avatar.rs

@ -311,10 +311,10 @@ impl std::fmt::Display for AvatarError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
use AvatarError::*;
match self {
Filesystem(e) => write!(f, "Could not open room avatar file: {}", e),
Upload(e) => write!(f, "Could not upload room avatar: {}", e),
Filesystem(e) => write!(f, "Could not open room avatar file: {e}"),
Upload(e) => write!(f, "Could not upload room avatar: {e}"),
NotAMember => write!(f, "Room avatar can’t be changed when not a member."),
UnknownFiletype(e) => write!(f, "Room avatar file has an unknown filetype: {}", e),
UnknownFiletype(e) => write!(f, "Room avatar file has an unknown filetype: {e}"),
}
}
}

2
src/session/content/room_details/general_page/mod.rs

@ -257,6 +257,6 @@ impl GeneralPage {
}
fn member_count_changed(&self, n: u32) {
self.imp().members_count.set_text(&format!("{}", n));
self.imp().members_count.set_text(&format!("{n}"));
}
}

2
src/session/content/room_details/member_page/members_list_view/membership_subpage_row.rs

@ -151,6 +151,6 @@ impl MembershipSubpageRow {
}
fn member_count_changed(&self, n: u32) {
self.imp().members_count.set_text(&format!("{}", n));
self.imp().members_count.set_text(&format!("{n}"));
}
}

2
src/session/content/room_history/message_row/text.rs

@ -212,7 +212,7 @@ fn create_widget_for_html_block(
}
let w = LabelWithWidgets::with_label_and_widgets(&label, widgets);
w.set_use_markup(true);
w.add_css_class(&format!("h{}", n));
w.add_css_class(&format!("h{n}"));
w.set_ellipsize(ellipsize);
w.upcast()
}

18
src/session/content/verification/identity_verification_widget.rs

@ -583,55 +583,55 @@ impl IdentityVerificationWidget {
.accept_request_instructions
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
.set_markup(&gettext_f("{user} asked to be verified. Verifying a user increases the security of the conversation.", &[("user", &format!("<b>{}</b>", name))]));
.set_markup(&gettext_f("{user} asked to be verified. Verifying a user increases the security of the conversation.", &[("user", &format!("<b>{name}</b>"))]));
imp.scan_qrcode_title
.set_markup(&gettext("Verification Request"));
imp.scan_qrcode_instructions.set_markup(&gettext_f(
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
"Scan the QR code shown on the device of {user}.",
&[("user", &format!("<b>{}</b>", name))],
&[("user", &format!("<b>{name}</b>"))],
));
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
imp.qrcode_scanned_message.set_markup(&gettext_f("You scanned the QR code successfully. {user} may need to confirm the verification.", &[("user", &format!("<b>{}</b>", name))]));
imp.qrcode_scanned_message.set_markup(&gettext_f("You scanned the QR code successfully. {user} may need to confirm the verification.", &[("user", &format!("<b>{name}</b>"))]));
imp.qrcode_title
.set_markup(&gettext("Verification Request"));
imp.qrcode_instructions.set_markup(&gettext_f(
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
"Ask {user} to scan this QR code from their session.",
&[("user", &format!("<b>{}</b>", name))],
&[("user", &format!("<b>{name}</b>"))],
));
imp.emoji_title.set_markup(&gettext("Verification Request"));
imp.emoji_instructions.set_markup(&gettext_f(
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
"Ask {user} if they see the following emoji appear in the same order on their screen.",
&[("user", &format!("<b>{}</b>", name))]
&[("user", &format!("<b>{name}</b>"))]
));
imp.completed_title
.set_markup(&gettext("Verification Complete"));
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
imp.completed_message.set_markup(&gettext_f("{user} is verified and you can now be sure that your communication will be private.", &[("user", &format!("<b>{}</b>", name))]));
imp.completed_message.set_markup(&gettext_f("{user} is verified and you can now be sure that your communication will be private.", &[("user", &format!("<b>{name}</b>"))]));
imp.wait_for_other_party_title.set_markup(&gettext_f(
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
"Waiting for {user}",
&[("user", &format!("<b>{}</b>", name))],
&[("user", &format!("<b>{name}</b>"))],
));
imp.wait_for_other_party_instructions.set_markup(&gettext_f(
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
"Ask {user} to accept the verification request.",
&[("user", &format!("<b>{}</b>", name))],
&[("user", &format!("<b>{name}</b>"))],
));
imp.confirm_scanned_qr_code_question.set_markup(&gettext_f(
// Translators: Do NOT translate the content between '{' and '}', this is a
// variable name.
"Does {user} see a confirmation on their session?",
&[("user", &format!("<b>{}</b>", name))],
&[("user", &format!("<b>{name}</b>"))],
));
}
}

2
src/session/media_viewer.rs

@ -240,7 +240,7 @@ impl MediaViewer {
// we need to store the file.
// See: https://gitlab.gnome.org/GNOME/gtk/-/issues/4062
let mut path = cache_dir();
path.push(format!("{}_{}", uid, filename));
path.push(format!("{uid}_{filename}"));
let file = gio::File::for_path(path);
file.replace_contents(
&data,

2
src/session/sidebar/row.rs

@ -230,7 +230,7 @@ impl Row {
list_item.set_css_classes(&["room"]);
}
} else {
panic!("Wrong row item: {:?}", item);
panic!("Wrong row item: {item:?}");
}
self.activate_action("sidebar.update-drop-targets", None)
.unwrap();

2
src/utils/matrix.rs

@ -13,7 +13,7 @@ use crate::gettext_f;
/// the `transaction_id`.
pub fn pending_event_ids() -> (OwnedTransactionId, OwnedEventId) {
let txn_id = TransactionId::new();
let event_id = EventId::parse(format!("${}:fractal.gnome.org", txn_id)).unwrap();
let event_id = EventId::parse(format!("${txn_id}:fractal.gnome.org")).unwrap();
(txn_id, event_id)
}

2
src/utils/media.rs

@ -57,7 +57,7 @@ pub fn filename_for_mime(mime_type: Option<&str>, fallback: Option<mime::Name>)
};
extension
.map(|extension| format!("{}.{}", name, extension))
.map(|extension| format!("{name}.{extension}"))
.unwrap_or(name)
}

2
src/utils/mod.rs

@ -107,7 +107,7 @@ pub fn freplace(s: String, args: &[(&str, &str)]) -> String {
let mut s = s;
for (k, v) in args {
s = s.replace(&format!("{{{}}}", k), v);
s = s.replace(&format!("{{{k}}}"), v);
}
s

Loading…
Cancel
Save