Run clippy on travis

This commit is contained in:
Mike Welsh 2017-06-24 16:01:14 -07:00
parent 1aa08aaee7
commit ffa8f41a1a
6 changed files with 44 additions and 35 deletions

View File

@ -9,8 +9,10 @@ matrix:
- rust: nightly
before_script:
- export PATH="$PATH:$HOME/.cargo/bin"
- which rustfmt || cargo install rustfmt-nightly
- (test $TRAVIS_RUST_VERSION != "nightly" || which rustfmt || cargo install rustfmt-nightly)
script:
- (test $TRAVIS_RUST_VERSION != "nightly" || cargo fmt)
- cargo build
- cargo test
- cargo test
- (test $TRAVIS_RUST_VERSION != "nightly" || cargo build --features "clippy")
- (test $TRAVIS_RUST_VERSION != "nightly" || cargo test --features "clippy")

View File

@ -9,8 +9,12 @@ readme = "README.md"
description = "Read and write the Adobe Flash SWF file format."
[dependencies]
clippy = {version = "0.0.140", optional = true}
byteorder = "1.0"
enum_primitive = "0.1.1"
flate2 = "0.2.17"
num = "0.1"
xz2 = { git = "https://github.com/alexcrichton/xz2-rs", rev = "09ce8db2" }
xz2 = { git = "https://github.com/alexcrichton/xz2-rs", rev = "09ce8db2" }
[features]
default = []

View File

@ -7,6 +7,9 @@
//! This library consits of a `read` module for decoding SWF data, and a `write` library for
//! writing SWF data.
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
extern crate byteorder;
#[macro_use]
extern crate enum_primitive;

View File

@ -1,3 +1,5 @@
#![allow(float_cmp)]
use avm1;
use byteorder::{LittleEndian, ReadBytesExt};
use flate2::read::ZlibDecoder;
@ -2589,7 +2591,6 @@ pub mod tests {
use std::vec::Vec;
use super::*;
use test_data;
use types::*;
use tag_codes::TagCode;
fn reader(data: &[u8]) -> Reader<&[u8]> {
@ -2632,26 +2633,24 @@ pub mod tests {
cursor.read_exact(&mut data[..]).unwrap();
if swf_tag_code == 0 {
panic!("Tag not found");
} else {
if swf_tag_code == tag_code as u16 {
if index == 0 {
// Flash tends to export tags with the extended header even if the size
// would fit with the standard header.
// This screws up our tests, because swf-rs writes tags with the
// minimum header necessary.
// We want to easily write new tests by exporting SWFs from the Flash
// software, so rewrite with a standard header to match swf-rs output.
if length < 0b111111 && (data[0] & 0b111111) == 0b111111 {
let mut tag_data = Vec::with_capacity(length + 2);
tag_data.extend_from_slice(&data[0..2]);
tag_data.extend_from_slice(&data[6..]);
tag_data[0] = (data[0] & !0b111111) | (length as u8);
data = tag_data;
}
return data;
} else {
index -= 1;
} else if swf_tag_code == tag_code as u16 {
if index == 0 {
// Flash tends to export tags with the extended header even if the size
// would fit with the standard header.
// This screws up our tests, because swf-rs writes tags with the
// minimum header necessary.
// We want to easily write new tests by exporting SWFs from the Flash
// software, so rewrite with a standard header to match swf-rs output.
if length < 0b111111 && (data[0] & 0b111111) == 0b111111 {
let mut tag_data = Vec::with_capacity(length + 2);
tag_data.extend_from_slice(&data[0..2]);
tag_data.extend_from_slice(&data[6..]);
tag_data[0] = (data[0] & !0b111111) | (length as u8);
data = tag_data;
}
return data;
} else {
index -= 1;
}
}
}
@ -2912,7 +2911,7 @@ pub mod tests {
#[test]
fn read_c_string() {
{
let buf = "Testing\0".as_bytes();
let buf = b"Testing\0";
let mut reader = Reader::new(&buf[..], 1);
assert_eq!(reader.read_c_string().unwrap(), "Testing");
}

View File

@ -3513,7 +3513,7 @@ pub fn tag_tests() -> Vec<TagTestData> {
(
1,
Tag::Metadata("aa!".to_string()),
vec![0b01_000100, 0b000_10011, 'a' as u8, 'a' as u8, '!' as u8, 0],
vec![0b01_000100, 0b000_10011, b'a', b'a', b'!', 0],
),
(

View File

@ -2678,7 +2678,6 @@ mod tests {
use super::Writer;
use std::io::Result;
use test_data;
use types::*;
fn new_swf() -> Swf {
Swf {
@ -3009,7 +3008,7 @@ mod tests {
let mut buf = Vec::new();
{
let mut writer = Writer::new(&mut buf, 1);
writer.write_tag_list(&vec![]).unwrap();
writer.write_tag_list(&[]).unwrap();
}
assert_eq!(buf, [0, 0]);
}
@ -3017,7 +3016,7 @@ mod tests {
let mut buf = Vec::new();
{
let mut writer = Writer::new(&mut buf, 1);
writer.write_tag_list(&vec![Tag::ShowFrame]).unwrap();
writer.write_tag_list(&[Tag::ShowFrame]).unwrap();
}
assert_eq!(buf, [0b01_000000, 0b00000000, 0, 0]);
}
@ -3026,13 +3025,15 @@ mod tests {
{
let mut writer = Writer::new(&mut buf, 1);
writer
.write_tag_list(&vec![
Tag::Unknown {
tag_code: 512,
data: vec![0; 100],
},
Tag::ShowFrame,
])
.write_tag_list(
&[
Tag::Unknown {
tag_code: 512,
data: vec![0; 100],
},
Tag::ShowFrame,
],
)
.unwrap();
}
let mut expected = vec![0b00_111111, 0b10000000, 100, 0, 0, 0];