Add rustfmt and clippy to CI and address clippy warnings.

This commit is contained in:
Jimmy Cuadra 2019-06-02 18:42:36 -07:00
parent dc7d71c79c
commit 16347d7209
6 changed files with 21 additions and 17 deletions

View File

@ -1 +0,0 @@
merge_imports = true

View File

@ -1,4 +1,12 @@
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:
email: false
irc:

View File

@ -26,6 +26,7 @@ use serde_json::{from_value, Value};
/// A basic event, room event, or state event.
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum Event {
/// m.call.answer
CallAnswer(AnswerEvent),
@ -85,6 +86,7 @@ pub enum Event {
/// A room event or state event.
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum RoomEvent {
/// m.call.answer
CallAnswer(AnswerEvent),
@ -132,6 +134,7 @@ pub enum RoomEvent {
/// A state event.
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum StateEvent {
/// m.room.aliases
RoomAliases(AliasesEvent),
@ -663,9 +666,7 @@ impl<'de> Deserialize<'de> for RoomEvent {
| EventType::Presence
| EventType::Receipt
| EventType::Tag
| EventType::Typing => {
return Err(D::Error::custom("not a room event".to_string()));
}
| EventType::Typing => Err(D::Error::custom("not a room event".to_string())),
}
}
}
@ -834,9 +835,7 @@ impl<'de> Deserialize<'de> for StateEvent {
| EventType::RoomMessage
| EventType::RoomRedaction
| EventType::Tag
| EventType::Typing => {
return Err(D::Error::custom("not a state event".to_string()));
}
| EventType::Typing => Err(D::Error::custom("not a state event".to_string())),
}
}
}

View File

@ -37,6 +37,7 @@ pub enum Event {
/// A room event.
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum RoomEvent {
/// m.call.answer
CallAnswer(AnswerEvent),
@ -154,11 +155,9 @@ impl<'de> Deserialize<'de> for Event {
| EventType::RoomPowerLevels
| EventType::RoomRedaction
| EventType::RoomThirdPartyInvite
| EventType::RoomTopic => {
return Err(D::Error::custom(
"not exclusively a basic event".to_string(),
));
}
| EventType::RoomTopic => Err(D::Error::custom(
"not exclusively a basic event".to_string(),
)),
}
}
}
@ -272,7 +271,7 @@ impl<'de> Deserialize<'de> for RoomEvent {
| EventType::RoomTopic
| EventType::Tag
| 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()))
}
}
}

View File

@ -38,7 +38,7 @@ mod tests {
content.insert(alice.clone(), room.clone());
let event = DirectEvent {
content: content,
content,
event_type: EventType::Direct,
};

View File

@ -23,6 +23,7 @@ use crate::{
/// A stripped-down version of a state event that is included along with some other events.
#[derive(Clone, Debug)]
#[allow(clippy::large_enum_variant)]
pub enum StrippedState {
/// A stripped-down version of the *m.room.aliases* event.
RoomAliases(StrippedRoomAliases),
@ -211,9 +212,7 @@ impl<'de> Deserialize<'de> for StrippedState {
Ok(StrippedState::RoomTopic(event))
}
_ => {
return Err(D::Error::custom("not a state event".to_string()));
}
_ => Err(D::Error::custom("not a state event".to_string())),
}
}
}