Skip to content

Commit 8c7dc5e

Browse files
committed
Merge #353: Tighten Linter (Check and Clippy)
eb838dd dev: tighten lint for build and clippy (Cameron Garnham) Pull request description: ACKs for top commit: josecelano: ACK eb838dd Tree-SHA512: c2872448c2cfa392e7fc60e429fe500d73f3b0546e913ced576a584ba8f3b9832714c4de0c469bc41b3212a4f735f180a0afdf234fde913c9bfb9dd7cc67434c
2 parents 87e117e + eb838dd commit 8c7dc5e

File tree

17 files changed

+86
-57
lines changed

17 files changed

+86
-57
lines changed

.cargo/config.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,23 @@ cov = "llvm-cov"
33
cov-lcov = "llvm-cov --lcov --output-path=./.coverage/lcov.info"
44
cov-html = "llvm-cov --html"
55
time = "build --timings --all-targets"
6+
7+
[build]
8+
rustflags = [
9+
"-D",
10+
"warnings",
11+
"-D",
12+
"future-incompatible",
13+
"-D",
14+
"let-underscore",
15+
"-D",
16+
"nonstandard-style",
17+
"-D",
18+
"rust-2018-compatibility",
19+
"-D",
20+
"rust-2018-idioms",
21+
"-D",
22+
"rust-2021-compatibility",
23+
"-D",
24+
"unused",
25+
]

.vscode/settings.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22
"[rust]": {
33
"editor.formatOnSave": true
44
},
5-
"rust-analyzer.checkOnSave.command": "clippy",
6-
"rust-analyzer.checkOnSave.allTargets": true,
7-
"rust-analyzer.checkOnSave.extraArgs": ["--","-W","clippy::pedantic"],
5+
"rust-analyzer.checkOnSave": true,
6+
"rust-analyzer.check.command": "clippy",
7+
"rust-analyzer.check.allTargets": true,
8+
"rust-analyzer.check.extraArgs": [
9+
"--",
10+
"-D",
11+
"clippy::correctness",
12+
"-D",
13+
"clippy::suspicious",
14+
"-W",
15+
"clippy::complexity",
16+
"-W",
17+
"clippy::perf",
18+
"-W",
19+
"clippy::style",
20+
"-W",
21+
"clippy::pedantic",
22+
],
823
}

packages/located-error/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ mod tests {
128128
fn error_should_include_location() {
129129
let e = TestError::Test;
130130

131-
let b: LocatedError<TestError> = Located(e).into();
131+
let b: LocatedError<'_, TestError> = Located(e).into();
132132
let l = get_caller_location();
133133

134134
assert_eq!(b.location.file(), l.file());

src/servers/apis/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl ApiServer<Running> {
128128
.send(0)
129129
.map_err(|_| Error::Error("Task killer channel was closed.".to_string()))?;
130130

131-
let _: Result<(), tokio::task::JoinError> = self.state.task.await;
131+
drop(self.state.task.await);
132132

133133
Ok(ApiServer {
134134
cfg: self.cfg,

src/servers/apis/v1/context/auth_key/resources.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl From<AuthKey> for auth::ExpiringKey {
2727
}
2828
}
2929

30+
#[allow(deprecated)]
3031
impl From<auth::ExpiringKey> for AuthKey {
3132
fn from(auth_key: auth::ExpiringKey) -> Self {
3233
AuthKey {
@@ -63,6 +64,7 @@ mod tests {
6364
}
6465

6566
#[test]
67+
#[allow(deprecated)]
6668
fn it_should_be_convertible_into_an_auth_key() {
6769
let auth_key_resource = AuthKey {
6870
key: "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM".to_string(), // cspell:disable-line
@@ -80,6 +82,7 @@ mod tests {
8082
}
8183

8284
#[test]
85+
#[allow(deprecated)]
8386
fn it_should_be_convertible_from_an_auth_key() {
8487
let auth_key = auth::ExpiringKey {
8588
key: "IaWDneuFNZi8IB4MPA3qW1CD0M30EZSM".parse::<Key>().unwrap(), // cspell:disable-line
@@ -97,6 +100,7 @@ mod tests {
97100
}
98101

99102
#[test]
103+
#[allow(deprecated)]
100104
fn it_should_be_convertible_into_json() {
101105
assert_eq!(
102106
serde_json::to_string(&AuthKey {

src/servers/http/v1/query.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl From<Vec<(&str, &str)>> for Query {
137137
}
138138

139139
impl std::fmt::Display for Query {
140-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
140+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
141141
let query = self
142142
.params
143143
.iter_all()
@@ -185,7 +185,7 @@ impl FromStr for NameValuePair {
185185
}
186186

187187
impl std::fmt::Display for NameValuePair {
188-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
188+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
189189
write!(f, "{}={}", self.name, self.value)
190190
}
191191
}
@@ -208,7 +208,7 @@ impl FieldValuePairSet {
208208
}
209209

210210
impl std::fmt::Display for FieldValuePairSet {
211-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
211+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
212212
let query = self
213213
.pairs
214214
.iter()

src/servers/http/v1/requests/announce.rs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl FromStr for Event {
166166
}
167167

168168
impl fmt::Display for Event {
169-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
169+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
170170
match self {
171171
Event::Started => write!(f, "started"),
172172
Event::Stopped => write!(f, "stopped"),
@@ -194,7 +194,7 @@ pub enum Compact {
194194
}
195195

196196
impl fmt::Display for Compact {
197-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
197+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
198198
match self {
199199
Compact::Accepted => write!(f, "1"),
200200
Compact::NotAccepted => write!(f, "0"),
@@ -264,12 +264,10 @@ fn extract_info_hash(query: &Query) -> Result<InfoHash, ParseAnnounceQueryError>
264264
})?,
265265
)
266266
}
267-
None => {
268-
return Err(ParseAnnounceQueryError::MissingParam {
269-
location: Location::caller(),
270-
param_name: INFO_HASH.to_owned(),
271-
})
272-
}
267+
None => Err(ParseAnnounceQueryError::MissingParam {
268+
location: Location::caller(),
269+
param_name: INFO_HASH.to_owned(),
270+
}),
273271
}
274272
}
275273

@@ -282,12 +280,10 @@ fn extract_peer_id(query: &Query) -> Result<peer::Id, ParseAnnounceQueryError> {
282280
source: Located(err).into(),
283281
})?,
284282
),
285-
None => {
286-
return Err(ParseAnnounceQueryError::MissingParam {
287-
location: Location::caller(),
288-
param_name: PEER_ID.to_owned(),
289-
})
290-
}
283+
None => Err(ParseAnnounceQueryError::MissingParam {
284+
location: Location::caller(),
285+
param_name: PEER_ID.to_owned(),
286+
}),
291287
}
292288
}
293289

@@ -298,12 +294,10 @@ fn extract_port(query: &Query) -> Result<u16, ParseAnnounceQueryError> {
298294
param_value: raw_param.clone(),
299295
location: Location::caller(),
300296
})?),
301-
None => {
302-
return Err(ParseAnnounceQueryError::MissingParam {
303-
location: Location::caller(),
304-
param_name: PORT.to_owned(),
305-
})
306-
}
297+
None => Err(ParseAnnounceQueryError::MissingParam {
298+
location: Location::caller(),
299+
param_name: PORT.to_owned(),
300+
}),
307301
}
308302
}
309303

src/servers/http/v1/requests/scrape.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ fn extract_info_hashes(query: &Query) -> Result<Vec<InfoHash>, ParseScrapeQueryE
7474

7575
Ok(info_hashes)
7676
}
77-
None => {
78-
return Err(ParseScrapeQueryError::MissingParam {
79-
location: Location::caller(),
80-
param_name: INFO_HASH.to_owned(),
81-
})
82-
}
77+
None => Err(ParseScrapeQueryError::MissingParam {
78+
location: Location::caller(),
79+
param_name: INFO_HASH.to_owned(),
80+
}),
8381
}
8482
}
8583

src/servers/http/v1/responses/announce.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub struct Peer {
116116

117117
impl Peer {
118118
#[must_use]
119-
pub fn ben_map(&self) -> BencodeMut {
119+
pub fn ben_map(&self) -> BencodeMut<'_> {
120120
ben_map! {
121121
"peer id" => ben_bytes!(self.peer_id.clone().to_vec()),
122122
"ip" => ben_bytes!(self.ip.to_string()),

src/servers/udp/handlers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ pub async fn handle_connect(remote_addr: SocketAddr, request: &ConnectRequest, t
104104
/// # Errors
105105
///
106106
/// Will return `Error` if unable to `authenticate_request`.
107+
#[allow(deprecated)]
107108
pub async fn authenticate(info_hash: &InfoHash, tracker: &Tracker) -> Result<(), Error> {
108109
tracker
109110
.authenticate_request(info_hash, &None)
@@ -225,6 +226,7 @@ pub async fn handle_scrape(remote_addr: SocketAddr, request: &ScrapeRequest, tra
225226
let info_hash = file.0;
226227
let swarm_metadata = file.1;
227228

229+
#[allow(deprecated)]
228230
let scrape_entry = if tracker.authenticate_request(info_hash, &None).await.is_ok() {
229231
#[allow(clippy::cast_possible_truncation)]
230232
TorrentScrapeStatistics {

0 commit comments

Comments
 (0)