Skip to content
This repository was archived by the owner on Dec 10, 2022. It is now read-only.

Commit 8cb4bb9

Browse files
authored
Merge pull request #40 from tox-rs/clippy
Fix clippy warnings
2 parents a63d604 + 36b13b5 commit 8cb4bb9

File tree

7 files changed

+32
-60
lines changed

7 files changed

+32
-60
lines changed

.travis.yml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
11
language: rust
2+
os:
3+
- linux
4+
- osx
25
rust:
36
- 1.31.0
47
- stable
58
- beta
69
- nightly
7-
cache:
8-
- apt
9-
- cargo
10-
11-
os:
12-
- linux
13-
- osx
14-
15-
matrix:
16-
allow_failures:
17-
- rust: beta
18-
- rust: nightly
19-
20-
sudo: required
2110

11+
sudo: false
2212
env:
2313
global:
2414
- RUST_BACKTRACE=1
@@ -31,27 +21,23 @@ before_install:
3121
- |
3222
if [[ "$TRAVIS_OS_NAME" == "linux" ]]
3323
then
34-
./scripts/verify-commit-messages.sh "$TRAVIS_COMMIT_RANGE" \
35-
&& ./scripts/bootstrap-ubuntu-14-04.sh
36-
fi
37-
- |
38-
if [[ "$TRAVIS_OS_NAME" == "osx" ]]
39-
then
40-
./scripts/bootstrap-osx.sh
41-
fi
42-
43-
install:
44-
- |
45-
if [[ "$TRAVIS_RUST_VERSION" == nightly ]]
46-
then
47-
rustup component add clippy-preview
24+
./scripts/verify-commit-messages.sh "$TRAVIS_COMMIT_RANGE" || exit 1;
4825
fi
4926
5027
script:
5128
- cargo build --verbose
5229
- cargo test --verbose
53-
- |
54-
if [[ "$TRAVIS_RUST_VERSION" == nightly ]]
55-
then
56-
cargo clippy --verbose --all --tests
57-
fi
30+
31+
matrix:
32+
allow_failures:
33+
- rust: beta
34+
- rust: nightly
35+
include:
36+
- os: linux
37+
rust: stable
38+
env:
39+
NAME: clippy
40+
install:
41+
- rustup component add clippy
42+
script:
43+
- cargo clippy --verbose --all --tests

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/bootstrap-osx.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

scripts/bootstrap-ubuntu-14-04.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn version() -> u32 {
6767
assert!(major < 1000, "Invalid major version");
6868
assert!(minor < 1000, "Invalid minor version");
6969
assert!(patch < 1000, "Invalid patch version");
70-
3000000000 + major * 1000000 + minor * 1000 + patch
70+
3_000_000_000 + major * 1_000_000 + minor * 1000 + patch
7171
}
7272

7373
/// Bind a UDP listener to the socket address.
@@ -276,7 +276,7 @@ fn run_udp(config: &NodeConfig, dht_pk: PublicKey, dht_sk: &SecretKey, udp_onion
276276
}
277277

278278
fn main() {
279-
if !crypto_init() {
279+
if crypto_init().is_err() {
280280
panic!("Crypto initialization failed.");
281281
}
282282

@@ -304,7 +304,7 @@ fn main() {
304304
LogType::None => { },
305305
}
306306

307-
for (key, _) in &config.unused {
307+
for key in config.unused.keys() {
308308
warn!("Unused configuration key: {:?}", key);
309309
}
310310

src/motd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ impl Motd {
8585
fn summary(source: u64) -> String {
8686
match source {
8787
0..=999 => format!("{}",source),
88-
1000..=999999 => format!("{0:.1}K", source as f32 / 1000.0),
89-
1000000..=999999999 => format!("{0:.1}M", source as f32 / 1000000.0),
90-
1000000000..=999999999999 => format!("{0:.1}G", source as f32 / 1000000000.0),
91-
1000000000000..=u64::MAX => format!("{0:.1}T", source as f32 / 1000000000000.0),
88+
1_000..=999_999 => format!("{0:.1}K", source as f32 / 1_000.0),
89+
1_000_000..=999_999_999 => format!("{0:.1}M", source as f32 / 1_000_000.0),
90+
1_000_000_000..=999_999_999_999 => format!("{0:.1}G", source as f32 / 1_000_000_000.0),
91+
1_000_000_000_000..=u64::MAX => format!("{0:.1}T", source as f32 / 1_000_000_000_000.0),
9292
_ => unreachable!("Packets counter has an impossible value")
9393
}
9494
}

src/node_config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn de_from_hex<'de, D>(deserializer: D) -> Result<PublicKey, D::Error> where D:
7676
let bootstrap_pk_bytes: [u8; 32] = FromHex::from_hex(s)
7777
.map_err(|e| de::Error::custom(format!("Can't make bytes from hex string {:?}", e)))?;
7878
PublicKey::from_slice(&bootstrap_pk_bytes)
79-
.ok_or(de::Error::custom("Can't make PublicKey"))
79+
.ok_or_else(|| de::Error::custom("Can't make PublicKey"))
8080
}
8181

8282
// TODO: Remove this function. Use default String type after bug fix released.
@@ -259,18 +259,18 @@ pub fn cli_parse() -> NodeConfig {
259259
}
260260

261261
/// Parse settings from a saved file.
262-
fn parse_config(config_path: String) -> NodeConfig {
262+
fn parse_config(config_path: &str) -> NodeConfig {
263263
let mut settings = Config::default();
264264

265265
settings.set_default("log-type", "Stderr").expect("Can't set default value for `log-type`");
266266
settings.set_default("motd", "This is tox-rs").expect("Can't set default value for `motd`");
267267
settings.set_default("lan-discovery", "False").expect("Can't set default value for `lan-discovery`");
268268
settings.set_default("threads", "1").expect("Can't set default value for `threads`");
269269

270-
let config_file = if !Path::new(&config_path).exists() {
270+
let config_file = if !Path::new(config_path).exists() {
271271
panic!("Can't find config file {}", config_path);
272272
} else {
273-
CfgFile::with_name(&config_path)
273+
CfgFile::with_name(config_path)
274274
};
275275

276276
settings.merge(config_file).expect("Merging config file with default values failed");
@@ -287,7 +287,7 @@ fn parse_config(config_path: String) -> NodeConfig {
287287
fn run_config(matches: &ArgMatches) -> NodeConfig {
288288
let config_path = value_t!(matches.value_of("cfg-file"), String).unwrap_or_else(|e| e.exit());
289289

290-
parse_config(config_path)
290+
parse_config(&config_path)
291291
}
292292

293293
fn run_args(matches: &ArgMatches) -> NodeConfig {

0 commit comments

Comments
 (0)