Skip to content

Commit bab463e

Browse files
authored
Merge pull request kstep#17 from tomprince/lints
Clean up warnings and run clippy.
2 parents 442ac99 + 25a823d commit bab463e

File tree

9 files changed

+24
-36
lines changed

9 files changed

+24
-36
lines changed

.travis.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,29 @@ addons:
1010
- binutils-dev
1111
rust:
1212
- stable
13+
- nightly
14+
env:
15+
global:
16+
# override the default `--features unstable` used for the nightly branch
17+
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
1318
before_script:
1419
- sudo apt-get update -qq
1520
- sudo apt-get install -y mpd
1621
- /usr/bin/mpd --version
22+
- export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
1723
- |
1824
pip install 'travis-cargo<0.2' --user &&
19-
export PATH=$HOME/.local/bin:$PATH
25+
travis-cargo --only nightly install -- --force clippy
2026
- |
2127
cargo install --force rustfmt
22-
export PATH=$HOME/.cargo/bin:$PATH
2328
script:
2429
- |
25-
travis-cargo build &&
30+
RUSTFLAGS=-Dwarnings travis-cargo build &&
2631
travis-cargo test
2732
- |
2833
cargo fmt -- --write-mode diff
34+
- |
35+
travis-cargo --only nightly clippy
2936
- |
3037
travis-cargo --only stable doc
3138
after_success:

benches/helpers.rs

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

benches/options.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ extern crate time;
55
extern crate test;
66
extern crate unix_socket;
77

8-
mod helpers;
9-
use helpers::connect;
108
use test::{Bencher, black_box};
11-
use time::Duration;
129
use unix_socket::UnixStream;
1310

1411
#[bench]
1512
fn status(b: &mut Bencher) {
1613
let mut mpd = mpd::Client::<UnixStream>::new(UnixStream::connect("/var/run/mpd/socket").unwrap()).unwrap();
17-
b.iter(|| { black_box(mpd.status()); });
14+
b.iter(|| { black_box(mpd.status()).unwrap(); });
1815
}

src/client.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ impl<S: Read + Write> Client<S> {
162162
}
163163

164164
/// Switch to a next song in queue
165+
#[cfg_attr(feature = "cargo-clippy", allow(should_implement_trait))]
165166
pub fn next(&mut self) -> Result<()> {
166167
self.run_command("next")
167168
.and_then(|_| self.expect_ok())
@@ -692,7 +693,7 @@ impl<S: Read + Write> Client<S> {
692693
.map(|&(ref a, _)| *a == "sticker")
693694
.unwrap_or(true)
694695
})
695-
.map(|r| r.map(|(_, b)| b.splitn(2, "=").nth(1).map(|s| s.to_owned()).unwrap()))
696+
.map(|r| r.map(|(_, b)| b.splitn(2, '=').nth(1).map(|s| s.to_owned()).unwrap()))
696697
.collect()
697698
})
698699
}
@@ -708,7 +709,7 @@ impl<S: Read + Write> Client<S> {
708709
rmap.map(|mut map| {
709710
(map.remove("file").unwrap(),
710711
map.remove("sticker")
711-
.and_then(|s| s.splitn(2, "=").nth(1).map(|s| s.to_owned()))
712+
.and_then(|s| s.splitn(2, '=').nth(1).map(|s| s.to_owned()))
712713
.unwrap())
713714
})
714715
})
@@ -741,7 +742,7 @@ impl<S: Read + Write> Proto for Client<S> {
741742
fn read_line(&mut self) -> Result<String> {
742743
let mut buf = String::new();
743744
try!(self.socket.read_line(&mut buf));
744-
if buf.ends_with("\n") {
745+
if buf.ends_with('\n') {
745746
buf.pop();
746747
}
747748
Ok(buf)

src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'a> ToPlaylistName for &'a Playlist {
4545

4646
impl<'a> ToPlaylistName for &'a String {
4747
fn to_name(&self) -> &str {
48-
&*self
48+
self
4949
}
5050
}
5151

src/proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use error::{Error, ProtoError, Result};
88
use reply::Reply;
99
use std::collections::BTreeMap;
1010
use std::fmt::Arguments;
11-
use std::io::{self, BufRead, Lines, Read, Write};
11+
use std::io::{self, Lines, Read, Write};
1212

1313
pub struct Pairs<I>(pub I);
1414

src/reply.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ impl FromStr for Reply {
2323
fn from_str(s: &str) -> Result<Reply, ParseError> {
2424
if s == "OK" || s == "list_OK" {
2525
Ok(Reply::Ok)
26+
} else if let Ok(ack) = s.parse::<ServerError>() {
27+
Ok(Reply::Ack(ack))
2628
} else {
27-
if let Ok(ack) = s.parse::<ServerError>() {
28-
Ok(Reply::Ack(ack))
29-
} else {
30-
let mut splits = s.splitn(2, ':');
31-
match (splits.next(), splits.next()) {
32-
(Some(a), Some(b)) => Ok(Reply::Pair(a.to_owned(), b.trim().to_owned())),
33-
_ => Err(ParseError::BadPair),
34-
}
29+
let mut splits = s.splitn(2, ':');
30+
match (splits.next(), splits.next()) {
31+
(Some(a), Some(b)) => Ok(Reply::Pair(a.to_owned(), b.trim().to_owned())),
32+
_ => Err(ParseError::BadPair),
3533
}
3634
}
3735
}

src/search.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#![allow(missing_docs)]
22
// TODO: unfinished functionality
33

4-
use client::Client;
5-
use convert::{FromMap, ToPlaylistName};
6-
use error::Result;
7-
use proto::Proto;
8-
use song::Song;
94
use std::borrow::Cow;
105
use std::convert::Into;
116
use std::fmt;
12-
use std::io::{Read, Write};
137

148
pub enum Term<'a> {
159
Any,

tests/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ use std::env;
44
use std::net::TcpStream;
55

66
pub fn connect() -> mpd::Client<TcpStream> {
7-
let addr = env::var("MPD_SOCK").unwrap_or("127.0.0.1:6600".to_owned());
7+
let addr = env::var("MPD_SOCK").unwrap_or_else(|_| "127.0.0.1:6600".to_owned());
88
mpd::Client::connect(&*addr).unwrap()
99
}

0 commit comments

Comments
 (0)