Enable non-default clippy lints
This commit is contained in:
parent
c6aa2e0428
commit
5090c11843
@ -1,5 +1,27 @@
|
|||||||
[alias]
|
[alias]
|
||||||
xtask = "run --package xtask --"
|
xtask = "run --package xtask --"
|
||||||
|
ruma-clippy = """\
|
||||||
|
clippy --workspace --all-targets --all-features --quiet -- \
|
||||||
|
-W rust_2018_idioms \
|
||||||
|
-W semicolon_in_expressions_from_macros \
|
||||||
|
-W unused_import_braces \
|
||||||
|
-W unused_qualifications \
|
||||||
|
-W clippy::branches_sharing_code \
|
||||||
|
-W clippy::cloned_instead_of_copied \
|
||||||
|
-W clippy::dbg_macro \
|
||||||
|
-W clippy::empty_line_after_outer_attr \
|
||||||
|
-W clippy::inefficient_to_string \
|
||||||
|
-W clippy::macro_use_imports \
|
||||||
|
-W clippy::map_flatten \
|
||||||
|
-W clippy::mut_mut \
|
||||||
|
-W clippy::needless_borrow \
|
||||||
|
-A clippy::new_without_default \
|
||||||
|
-W clippy::todo \
|
||||||
|
-W clippy::unreadable_literal \
|
||||||
|
-W clippy::unseparated_literal_suffix \
|
||||||
|
-W clippy::useless_let_if_seq \
|
||||||
|
-W clippy::wildcard_imports \
|
||||||
|
"""
|
||||||
|
|
||||||
[doc.extern-map.registries]
|
[doc.extern-map.registries]
|
||||||
crates-io = "https://docs.rs/"
|
crates-io = "https://docs.rs/"
|
||||||
|
1
.clippy.toml
Normal file
1
.clippy.toml
Normal file
@ -0,0 +1 @@
|
|||||||
|
msrv = "1.45"
|
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"rust-analyzer.cargo.allFeatures": true
|
"rust-analyzer.cargo.allFeatures": true,
|
||||||
|
"rust-analyzer.checkOnSave.command": "ruma-clippy"
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use ruma_api::{
|
use ruma_api::{
|
||||||
ruma_api, IncomingRequest as _, OutgoingRequest as _, OutgoingRequestAppserviceExt as _,
|
ruma_api, IncomingRequest as _, OutgoingRequest as _, OutgoingRequestAppserviceExt,
|
||||||
SendAccessToken,
|
SendAccessToken,
|
||||||
};
|
};
|
||||||
use ruma_identifiers::{user_id, UserId};
|
use ruma_identifiers::{user_id, UserId};
|
||||||
@ -91,7 +91,7 @@ fn request_with_user_id_serde() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod without_query {
|
mod without_query {
|
||||||
use super::*;
|
use super::{ruma_api, user_id, OutgoingRequestAppserviceExt, SendAccessToken, UserId};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
|
@ -170,7 +170,7 @@ mod tests {
|
|||||||
SendAccessToken::IfRequired("auth_tok"),
|
SendAccessToken::IfRequired("auth_tok"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let json_body: serde_json::Value = serde_json::from_slice(&req.body()).unwrap();
|
let json_body: serde_json::Value = serde_json::from_slice(req.body()).unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
1,
|
1,
|
||||||
|
@ -18,7 +18,7 @@ fn registration_deserialization() {
|
|||||||
regex: "#_irc_bridge_.*"
|
regex: "#_irc_bridge_.*"
|
||||||
rooms: []
|
rooms: []
|
||||||
"##;
|
"##;
|
||||||
let observed = serde_yaml::from_str(®istration_config).unwrap();
|
let observed = serde_yaml::from_str(registration_config).unwrap();
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
observed,
|
observed,
|
||||||
Registration {
|
Registration {
|
||||||
@ -59,7 +59,7 @@ fn config_with_optional_url() {
|
|||||||
rooms: []
|
rooms: []
|
||||||
"#;
|
"#;
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
serde_yaml::from_str(®istration_config).unwrap(),
|
serde_yaml::from_str(registration_config).unwrap(),
|
||||||
Registration { url, .. } if url == "null"
|
Registration { url, .. } if url == "null"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -112,8 +112,8 @@ mod tests {
|
|||||||
let third_party_id_serialized = json!({
|
let third_party_id_serialized = json!({
|
||||||
"medium": "email",
|
"medium": "email",
|
||||||
"address": "monkey@banana.island",
|
"address": "monkey@banana.island",
|
||||||
"validated_at": 1_535_176_800_000u64,
|
"validated_at": 1_535_176_800_000_u64,
|
||||||
"added_at": 1_535_336_848_756u64
|
"added_at": 1_535_336_848_756_u64
|
||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(to_json_value(third_party_id.clone()).unwrap(), third_party_id_serialized);
|
assert_eq!(to_json_value(third_party_id.clone()).unwrap(), third_party_id_serialized);
|
||||||
|
@ -926,7 +926,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_one_to_one = &PushConditionRoomCtx {
|
let context_one_to_one = &PushConditionRoomCtx {
|
||||||
room_id: room_id!("!dm:server.name"),
|
room_id: room_id!("!dm:server.name"),
|
||||||
member_count: 2u32.into(),
|
member_count: 2_u32.into(),
|
||||||
user_display_name: "Jolly Jumper".into(),
|
user_display_name: "Jolly Jumper".into(),
|
||||||
users_power_levels: BTreeMap::new(),
|
users_power_levels: BTreeMap::new(),
|
||||||
default_power_level: 50.into(),
|
default_power_level: 50.into(),
|
||||||
@ -935,7 +935,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_public_room = &PushConditionRoomCtx {
|
let context_public_room = &PushConditionRoomCtx {
|
||||||
room_id: room_id!("!far_west:server.name"),
|
room_id: room_id!("!far_west:server.name"),
|
||||||
member_count: 100u32.into(),
|
member_count: 100_u32.into(),
|
||||||
user_display_name: "Jolly Jumper".into(),
|
user_display_name: "Jolly Jumper".into(),
|
||||||
users_power_levels: BTreeMap::new(),
|
users_power_levels: BTreeMap::new(),
|
||||||
default_power_level: 50.into(),
|
default_power_level: 50.into(),
|
||||||
@ -1025,7 +1025,7 @@ mod tests {
|
|||||||
fn custom_ruleset_applies() {
|
fn custom_ruleset_applies() {
|
||||||
let context_one_to_one = &PushConditionRoomCtx {
|
let context_one_to_one = &PushConditionRoomCtx {
|
||||||
room_id: room_id!("!dm:server.name"),
|
room_id: room_id!("!dm:server.name"),
|
||||||
member_count: 2u32.into(),
|
member_count: 2_u32.into(),
|
||||||
user_display_name: "Jolly Jumper".into(),
|
user_display_name: "Jolly Jumper".into(),
|
||||||
users_power_levels: BTreeMap::new(),
|
users_power_levels: BTreeMap::new(),
|
||||||
default_power_level: 50.into(),
|
default_power_level: 50.into(),
|
||||||
|
@ -484,7 +484,7 @@ mod tests {
|
|||||||
|
|
||||||
let context = PushConditionRoomCtx {
|
let context = PushConditionRoomCtx {
|
||||||
room_id: room_id!("!room:server.name"),
|
room_id: room_id!("!room:server.name"),
|
||||||
member_count: 3u8.into(),
|
member_count: 3_u8.into(),
|
||||||
user_display_name: "Groovy Gorilla".into(),
|
user_display_name: "Groovy Gorilla".into(),
|
||||||
users_power_levels,
|
users_power_levels,
|
||||||
default_power_level: 50.into(),
|
default_power_level: 50.into(),
|
||||||
|
@ -190,7 +190,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn eq_range_contains_its_own_count() {
|
fn eq_range_contains_its_own_count() {
|
||||||
let count = 2u32.into();
|
let count = 2_u32.into();
|
||||||
let range = RoomMemberCountIs::from(count);
|
let range = RoomMemberCountIs::from(count);
|
||||||
|
|
||||||
assert!(range.contains(&count));
|
assert!(range.contains(&count));
|
||||||
@ -199,7 +199,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn ge_range_contains_large_number() {
|
fn ge_range_contains_large_number() {
|
||||||
let range = RoomMemberCountIs::from(uint!(2)..);
|
let range = RoomMemberCountIs::from(uint!(2)..);
|
||||||
let large_number = 9001u32.into();
|
let large_number = 9001_u32.into();
|
||||||
|
|
||||||
assert!(range.contains(&large_number));
|
assert!(range.contains(&large_number));
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ mod tests {
|
|||||||
"recommendation": "m.ban"
|
"recommendation": "m.ban"
|
||||||
},
|
},
|
||||||
"event_id": "$143273582443PhrSn:example.org",
|
"event_id": "$143273582443PhrSn:example.org",
|
||||||
"origin_server_ts": 1432735824653u64,
|
"origin_server_ts": 1_432_735_824_653_u64,
|
||||||
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
|
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
|
||||||
"sender": "@example:example.org",
|
"sender": "@example:example.org",
|
||||||
"state_key": "rule:#*:example.org",
|
"state_key": "rule:#*:example.org",
|
||||||
@ -78,7 +78,7 @@ mod tests {
|
|||||||
"recommendation": "m.ban"
|
"recommendation": "m.ban"
|
||||||
},
|
},
|
||||||
"event_id": "$143273582443PhrSn:example.org",
|
"event_id": "$143273582443PhrSn:example.org",
|
||||||
"origin_server_ts": 1432735824653u64,
|
"origin_server_ts": 1_432_735_824_653_u64,
|
||||||
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
|
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
|
||||||
"sender": "@example:example.org",
|
"sender": "@example:example.org",
|
||||||
"state_key": "rule:#*:example.org",
|
"state_key": "rule:#*:example.org",
|
||||||
|
@ -191,7 +191,9 @@ mod tests {
|
|||||||
.deserialize()
|
.deserialize()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_matches!(content.scheme, EncryptedEventScheme::MegolmV1AesSha2(MegolmV1AesSha2Content {
|
assert_matches!(
|
||||||
|
content.scheme,
|
||||||
|
EncryptedEventScheme::MegolmV1AesSha2(MegolmV1AesSha2Content {
|
||||||
ciphertext,
|
ciphertext,
|
||||||
sender_key,
|
sender_key,
|
||||||
device_id,
|
device_id,
|
||||||
@ -204,7 +206,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
content.relates_to,
|
content.relates_to,
|
||||||
Option::<Relation>::Some(Relation::Reply { in_reply_to })
|
Some(Relation::Reply { in_reply_to })
|
||||||
if in_reply_to.event_id == event_id!("$h29iv0s8:example.com")
|
if in_reply_to.event_id == event_id!("$h29iv0s8:example.com")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -231,7 +233,7 @@ mod tests {
|
|||||||
assert_eq!(c.sender_key, "test_key");
|
assert_eq!(c.sender_key, "test_key");
|
||||||
assert_eq!(c.ciphertext.len(), 1);
|
assert_eq!(c.ciphertext.len(), 1);
|
||||||
assert_eq!(c.ciphertext["test_curve_key"].body, "encrypted_body");
|
assert_eq!(c.ciphertext["test_curve_key"].body, "encrypted_body");
|
||||||
assert_eq!(c.ciphertext["test_curve_key"].message_type, 1u16.into());
|
assert_eq!(c.ciphertext["test_curve_key"].message_type, 1_u16.into());
|
||||||
}
|
}
|
||||||
_ => panic!("Wrong content type, expected a OlmV1 content"),
|
_ => panic!("Wrong content type, expected a OlmV1 content"),
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ mod tests {
|
|||||||
let event = StateEvent {
|
let event = StateEvent {
|
||||||
content: content.clone(),
|
content: content.clone(),
|
||||||
event_id: EventId::new(server_name),
|
event_id: EventId::new(server_name),
|
||||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1_432_804_485_886u64),
|
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1_432_804_485_886_u64),
|
||||||
prev_content: None,
|
prev_content: None,
|
||||||
room_id: RoomId::new(server_name),
|
room_id: RoomId::new(server_name),
|
||||||
sender: UserId::new(server_name),
|
sender: UserId::new(server_name),
|
||||||
|
@ -341,7 +341,7 @@ mod test {
|
|||||||
"m.read": {
|
"m.read": {
|
||||||
"@john:matrix.org": {
|
"@john:matrix.org": {
|
||||||
"data": {
|
"data": {
|
||||||
"ts": 1533358
|
"ts": 1_533_358
|
||||||
},
|
},
|
||||||
"event_ids": [
|
"event_ids": [
|
||||||
"$read_this_event:matrix.org"
|
"$read_this_event:matrix.org"
|
||||||
|
@ -67,12 +67,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn issue_446() {
|
fn issue_446() {
|
||||||
let json = json!({ "timestamp": 15159743990000u64 });
|
let json = json!({ "timestamp": 15_159_743_990_000_u64 });
|
||||||
|
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
serde_json::from_value::<SystemTimeTest>(json),
|
serde_json::from_value::<SystemTimeTest>(json),
|
||||||
Ok(SystemTimeTest { timestamp })
|
Ok(SystemTimeTest { timestamp })
|
||||||
if timestamp == UNIX_EPOCH + Duration::from_millis(15159743990000)
|
if timestamp == UNIX_EPOCH + Duration::from_millis(15_159_743_990_000)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ fn serialize_multiple_lists() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serialize_nested_list() {
|
fn serialize_nested_list() {
|
||||||
let params = &[("list", vec![vec![0u8]])];
|
let params = &[("list", vec![vec![0_u8]])];
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
urlencoded::to_string(params),
|
urlencoded::to_string(params),
|
||||||
Err(Error::Custom(s)) if s.contains("unsupported")
|
Err(Error::Custom(s)) if s.contains("unsupported")
|
||||||
|
@ -170,7 +170,7 @@ fn split_id(id: &str) -> Result<(Algorithm, String), SplitError<'_>> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use base64::{decode_config, STANDARD_NO_PAD};
|
use base64::{decode_config, encode_config, STANDARD_NO_PAD};
|
||||||
use ring::signature::{Ed25519KeyPair as RingEd25519KeyPair, KeyPair as _};
|
use ring::signature::{Ed25519KeyPair as RingEd25519KeyPair, KeyPair as _};
|
||||||
use ruma_identifiers::RoomVersionId;
|
use ruma_identifiers::RoomVersionId;
|
||||||
use serde_json::{from_str as from_json_str, to_string as to_json_string};
|
use serde_json::{from_str as from_json_str, to_string as to_json_string};
|
||||||
@ -186,12 +186,10 @@ mod tests {
|
|||||||
|
|
||||||
/// Convenience method for getting the public key as a string
|
/// Convenience method for getting the public key as a string
|
||||||
fn public_key_string() -> String {
|
fn public_key_string() -> String {
|
||||||
base64::encode_config(
|
encode_config(
|
||||||
&RingEd25519KeyPair::from_pkcs8(
|
&RingEd25519KeyPair::from_pkcs8(&decode_config(PKCS8, STANDARD_NO_PAD).unwrap())
|
||||||
&base64::decode_config(PKCS8, STANDARD_NO_PAD).unwrap(),
|
.unwrap()
|
||||||
)
|
.public_key(),
|
||||||
.unwrap()
|
|
||||||
.public_key(),
|
|
||||||
STANDARD_NO_PAD,
|
STANDARD_NO_PAD,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -60,11 +60,7 @@ impl CiTask {
|
|||||||
fn build_nightly(&self) -> xshell::Result<()> {
|
fn build_nightly(&self) -> xshell::Result<()> {
|
||||||
vec![
|
vec![
|
||||||
cmd!("rustup run nightly cargo fmt -- --check").run(),
|
cmd!("rustup run nightly cargo fmt -- --check").run(),
|
||||||
cmd!(
|
cmd!("rustup run nightly cargo ruma-clippy -D warnings").run(),
|
||||||
"rustup run nightly cargo clippy -p ruma
|
|
||||||
--all-targets --all-features --quiet -- -D warnings"
|
|
||||||
)
|
|
||||||
.run(),
|
|
||||||
cmd!(
|
cmd!(
|
||||||
"rustup run nightly cargo clippy -p ruma-client
|
"rustup run nightly cargo clippy -p ruma-client
|
||||||
--all-targets --quiet -- -D warnings"
|
--all-targets --quiet -- -D warnings"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user