chore: Fix several style lints (#17488)

It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-06 11:58:39 +02:00 committed by GitHub
parent 93249fc82b
commit e6c1c51b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
361 changed files with 3530 additions and 3587 deletions

View file

@ -218,9 +218,9 @@ impl From<proto::ChannelRole> for ChannelRole {
}
}
impl Into<proto::ChannelRole> for ChannelRole {
fn into(self) -> proto::ChannelRole {
match self {
impl From<ChannelRole> for proto::ChannelRole {
fn from(val: ChannelRole) -> Self {
match val {
ChannelRole::Admin => proto::ChannelRole::Admin,
ChannelRole::Member => proto::ChannelRole::Member,
ChannelRole::Talker => proto::ChannelRole::Talker,
@ -230,9 +230,9 @@ impl Into<proto::ChannelRole> for ChannelRole {
}
}
impl Into<i32> for ChannelRole {
fn into(self) -> i32 {
let proto: proto::ChannelRole = self.into();
impl From<ChannelRole> for i32 {
fn from(val: ChannelRole) -> Self {
let proto: proto::ChannelRole = val.into();
proto.into()
}
}
@ -259,18 +259,18 @@ impl From<proto::ChannelVisibility> for ChannelVisibility {
}
}
impl Into<proto::ChannelVisibility> for ChannelVisibility {
fn into(self) -> proto::ChannelVisibility {
match self {
impl From<ChannelVisibility> for proto::ChannelVisibility {
fn from(val: ChannelVisibility) -> Self {
match val {
ChannelVisibility::Public => proto::ChannelVisibility::Public,
ChannelVisibility::Members => proto::ChannelVisibility::Members,
}
}
}
impl Into<i32> for ChannelVisibility {
fn into(self) -> i32 {
let proto: proto::ChannelVisibility = self.into();
impl From<ChannelVisibility> for i32 {
fn from(val: ChannelVisibility) -> Self {
let proto: proto::ChannelVisibility = val.into();
proto.into()
}
}

View file

@ -391,7 +391,7 @@ impl Database {
drop(rows);
if collaborators.is_empty() {
self.snapshot_channel_buffer(channel_id, &tx).await?;
self.snapshot_channel_buffer(channel_id, tx).await?;
}
Ok(LeftChannelBuffer {

View file

@ -188,17 +188,16 @@ impl Database {
.anyhow())?;
}
}
} else if visibility == ChannelVisibility::Members {
if self
} else if visibility == ChannelVisibility::Members
&& self
.get_channel_descendants_excluding_self([&channel], &tx)
.await?
.into_iter()
.any(|channel| channel.visibility == ChannelVisibility::Public)
{
Err(ErrorCode::BadPublicNesting
.with_tag("direction", "children")
.anyhow())?;
}
{
Err(ErrorCode::BadPublicNesting
.with_tag("direction", "children")
.anyhow())?;
}
let mut model = channel.into_active_model();
@ -308,7 +307,7 @@ impl Database {
fn sanitize_channel_name(name: &str) -> Result<&str> {
let new_name = name.trim().trim_start_matches('#');
if new_name == "" {
if new_name.is_empty() {
Err(anyhow!("channel name can't be blank"))?;
}
Ok(new_name)
@ -985,7 +984,7 @@ impl Database {
.all(&*tx)
.await?
.into_iter()
.map(|c| Channel::from_model(c))
.map(Channel::from_model)
.collect::<Vec<_>>();
Ok((root_id, channels))

View file

@ -86,14 +86,13 @@ impl Database {
avoid_duplicates: bool,
tx: &DatabaseTransaction,
) -> Result<Option<(UserId, proto::Notification)>> {
if avoid_duplicates {
if self
if avoid_duplicates
&& self
.find_notification(recipient_id, &notification, tx)
.await?
.is_some()
{
return Ok(None);
}
{
return Ok(None);
}
let proto = notification.to_proto();

View file

@ -459,7 +459,7 @@ impl Database {
.await?;
}
let (channel, room) = self.get_channel_room(room_id, &tx).await?;
let (channel, room) = self.get_channel_room(room_id, tx).await?;
let channel = channel.ok_or_else(|| anyhow!("no channel for room"))?;
Ok(JoinRoom {
room,
@ -766,13 +766,13 @@ impl Database {
})
.collect::<Vec<_>>();
return Ok(Some(RejoinedProject {
Ok(Some(RejoinedProject {
id: project_id,
old_connection_id,
collaborators,
worktrees,
language_servers,
}));
}))
}
pub async fn leave_room(
@ -1108,15 +1108,14 @@ impl Database {
.count(tx)
.await?
> 0;
if requires_zed_cla {
if contributor::Entity::find()
if requires_zed_cla
&& contributor::Entity::find()
.filter(contributor::Column::UserId.eq(user_id))
.one(tx)
.await?
.is_none()
{
Err(anyhow!("user has not signed the Zed CLA"))?;
}
{
Err(anyhow!("user has not signed the Zed CLA"))?;
}
}
Ok(())

View file

@ -48,7 +48,7 @@ impl Model {
id: self.id.to_proto(),
project_id: project.map(|p| p.id.to_proto()),
dev_server_id: self.dev_server_id.to_proto(),
path: self.paths().get(0).cloned().unwrap_or_default(),
path: self.paths().first().cloned().unwrap_or_default(),
paths: self.paths().clone(),
}
}

View file

@ -22,19 +22,17 @@ async fn test_already_processed_stripe_event(db: &Arc<Database>) {
.await
.unwrap();
assert_eq!(
assert!(
db.already_processed_stripe_event(&processed_event_id)
.await
.unwrap(),
true,
"Expected {processed_event_id} to already be processed"
);
assert_eq!(
db.already_processed_stripe_event(&unprocessed_event_id)
assert!(
!db.already_processed_stripe_event(&unprocessed_event_id)
.await
.unwrap(),
false,
"Expected {unprocessed_event_id} to be unprocessed"
);
}