Add rustfmt and clippy to CI and address clippy warnings.
This commit is contained in:
parent
dc7d71c79c
commit
16347d7209
@ -1 +0,0 @@
|
|||||||
merge_imports = true
|
|
@ -1,4 +1,12 @@
|
|||||||
language: "rust"
|
language: "rust"
|
||||||
|
before_script:
|
||||||
|
- "rustup component add rustfmt"
|
||||||
|
- "rustup component add clippy"
|
||||||
|
script:
|
||||||
|
- "cargo fmt --all -- --check"
|
||||||
|
- "cargo clippy --all-targets --all-features -- -D warnings"
|
||||||
|
- "cargo build --verbose"
|
||||||
|
- "cargo test --verbose"
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
irc:
|
irc:
|
||||||
|
@ -26,6 +26,7 @@ use serde_json::{from_value, Value};
|
|||||||
|
|
||||||
/// A basic event, room event, or state event.
|
/// A basic event, room event, or state event.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
/// m.call.answer
|
/// m.call.answer
|
||||||
CallAnswer(AnswerEvent),
|
CallAnswer(AnswerEvent),
|
||||||
@ -85,6 +86,7 @@ pub enum Event {
|
|||||||
|
|
||||||
/// A room event or state event.
|
/// A room event or state event.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum RoomEvent {
|
pub enum RoomEvent {
|
||||||
/// m.call.answer
|
/// m.call.answer
|
||||||
CallAnswer(AnswerEvent),
|
CallAnswer(AnswerEvent),
|
||||||
@ -132,6 +134,7 @@ pub enum RoomEvent {
|
|||||||
|
|
||||||
/// A state event.
|
/// A state event.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum StateEvent {
|
pub enum StateEvent {
|
||||||
/// m.room.aliases
|
/// m.room.aliases
|
||||||
RoomAliases(AliasesEvent),
|
RoomAliases(AliasesEvent),
|
||||||
@ -663,9 +666,7 @@ impl<'de> Deserialize<'de> for RoomEvent {
|
|||||||
| EventType::Presence
|
| EventType::Presence
|
||||||
| EventType::Receipt
|
| EventType::Receipt
|
||||||
| EventType::Tag
|
| EventType::Tag
|
||||||
| EventType::Typing => {
|
| EventType::Typing => Err(D::Error::custom("not a room event".to_string())),
|
||||||
return Err(D::Error::custom("not a room event".to_string()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -834,9 +835,7 @@ impl<'de> Deserialize<'de> for StateEvent {
|
|||||||
| EventType::RoomMessage
|
| EventType::RoomMessage
|
||||||
| EventType::RoomRedaction
|
| EventType::RoomRedaction
|
||||||
| EventType::Tag
|
| EventType::Tag
|
||||||
| EventType::Typing => {
|
| EventType::Typing => Err(D::Error::custom("not a state event".to_string())),
|
||||||
return Err(D::Error::custom("not a state event".to_string()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ pub enum Event {
|
|||||||
|
|
||||||
/// A room event.
|
/// A room event.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum RoomEvent {
|
pub enum RoomEvent {
|
||||||
/// m.call.answer
|
/// m.call.answer
|
||||||
CallAnswer(AnswerEvent),
|
CallAnswer(AnswerEvent),
|
||||||
@ -154,11 +155,9 @@ impl<'de> Deserialize<'de> for Event {
|
|||||||
| EventType::RoomPowerLevels
|
| EventType::RoomPowerLevels
|
||||||
| EventType::RoomRedaction
|
| EventType::RoomRedaction
|
||||||
| EventType::RoomThirdPartyInvite
|
| EventType::RoomThirdPartyInvite
|
||||||
| EventType::RoomTopic => {
|
| EventType::RoomTopic => Err(D::Error::custom(
|
||||||
return Err(D::Error::custom(
|
|
||||||
"not exclusively a basic event".to_string(),
|
"not exclusively a basic event".to_string(),
|
||||||
));
|
)),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,7 +271,7 @@ impl<'de> Deserialize<'de> for RoomEvent {
|
|||||||
| EventType::RoomTopic
|
| EventType::RoomTopic
|
||||||
| EventType::Tag
|
| EventType::Tag
|
||||||
| EventType::Typing => {
|
| EventType::Typing => {
|
||||||
return Err(D::Error::custom("not exclusively a room event".to_string()));
|
Err(D::Error::custom("not exclusively a room event".to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ mod tests {
|
|||||||
content.insert(alice.clone(), room.clone());
|
content.insert(alice.clone(), room.clone());
|
||||||
|
|
||||||
let event = DirectEvent {
|
let event = DirectEvent {
|
||||||
content: content,
|
content,
|
||||||
event_type: EventType::Direct,
|
event_type: EventType::Direct,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ use crate::{
|
|||||||
|
|
||||||
/// A stripped-down version of a state event that is included along with some other events.
|
/// A stripped-down version of a state event that is included along with some other events.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum StrippedState {
|
pub enum StrippedState {
|
||||||
/// A stripped-down version of the *m.room.aliases* event.
|
/// A stripped-down version of the *m.room.aliases* event.
|
||||||
RoomAliases(StrippedRoomAliases),
|
RoomAliases(StrippedRoomAliases),
|
||||||
@ -211,9 +212,7 @@ impl<'de> Deserialize<'de> for StrippedState {
|
|||||||
|
|
||||||
Ok(StrippedState::RoomTopic(event))
|
Ok(StrippedState::RoomTopic(event))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => Err(D::Error::custom("not a state event".to_string())),
|
||||||
return Err(D::Error::custom("not a state event".to_string()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user