From 3e03b188b45112d39fbeaf3d2ef500e5faaf8f41 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 11 Jun 2020 13:05:21 -0400 Subject: [PATCH 1/4] Disable clippy component for 1.28 --- .travis.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e7a618..a586154 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ jobs: os: linux - rust: 1.28.0 os: linux + env: DISABLE_TOOLS=true - rust: stable os: osx - rust: stable-msvc @@ -20,12 +21,10 @@ before_script: - rustup show # CMake doesn't like the `sh.exe` provided by Git being in PATH - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then rm "C:/Program Files/Git/usr/bin/sh.exe"; fi - - rustup component add clippy - - rustup component add rustfmt + - if [[ "$DISABLE_CLIPPY" == "" ]]; then rustup component add clippy; rustup component add rustfmt; fi script: - - cargo clippy --all - - cargo fmt --all -- --check + - if [[ "$DISABLE_CLIPPY" == "" ]]; then cargo clippy --all && cargo fmt --all -- --check; fi # For default build, split up compilation and tests so we can track build times - cargo test --no-run @@ -33,14 +32,6 @@ script: - cargo test --release --no-run - cargo test --release - # Run tests using static linking - - cd "$TRAVIS_BUILD_DIR/libaeron-sys" - - cargo test --features "static" - - - cd "$TRAVIS_BUILD_DIR/libaeron_driver-sys" - - cargo test --features "static" - - branches: only: - master From 4079b3ce2f658efe84f67a5cb6d663110f9b450f Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 11 Jun 2020 13:06:26 -0400 Subject: [PATCH 2/4] Fix ENV naming --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a586154..4a92d65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,10 +21,10 @@ before_script: - rustup show # CMake doesn't like the `sh.exe` provided by Git being in PATH - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then rm "C:/Program Files/Git/usr/bin/sh.exe"; fi - - if [[ "$DISABLE_CLIPPY" == "" ]]; then rustup component add clippy; rustup component add rustfmt; fi + - if [[ "$DISABLE_TOOLS" == "" ]]; then rustup component add clippy; rustup component add rustfmt; fi script: - - if [[ "$DISABLE_CLIPPY" == "" ]]; then cargo clippy --all && cargo fmt --all -- --check; fi + - if [[ "$DISABLE_TOOLS" == "" ]]; then cargo clippy --all && cargo fmt --all -- --check; fi # For default build, split up compilation and tests so we can track build times - cargo test --no-run From 61022c323eb918890f1a8b640db21fa4d4e47a78 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 11 Jun 2020 13:11:52 -0400 Subject: [PATCH 3/4] Cargo fmt --- src/lib.rs | 6 +----- src/tests/fuzzing.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b894482..a3446cf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1042,11 +1042,7 @@ impl Parser { } else if vec![8, 12, 14].contains(&len_li) { // YYMMDD let s = &tokens[idx]; - ymd.append( - s[..4].parse::()?, - &s[..4], - Some(YMDLabel::Year), - )?; + ymd.append(s[..4].parse::()?, &s[..4], Some(YMDLabel::Year))?; ymd.append(s[4..6].parse::()?, &s[4..6], None)?; ymd.append(s[6..8].parse::()?, &s[6..8], None)?; diff --git a/src/tests/fuzzing.rs b/src/tests/fuzzing.rs index e0695c5..48373f3 100644 --- a/src/tests/fuzzing.rs +++ b/src/tests/fuzzing.rs @@ -46,4 +46,4 @@ fn large_int() { let parse_result = parse("1412409095009.jpg"); assert!(parse_result.is_err()); println!("{:?}", parse_result); -} \ No newline at end of file +} From b098f54f8b64458786d5fa56bb9f01cd51adf386 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 11 Jun 2020 13:33:09 -0400 Subject: [PATCH 4/4] Convert clippy lints --- src/lib.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a3446cf..1289b78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![deny(missing_docs)] +#![cfg_attr(test, allow(unknown_lints))] #![cfg_attr(test, deny(warnings))] //! # dtparse @@ -165,16 +166,15 @@ pub(crate) fn tokenize(parse_string: &str) -> Vec { /// Utility function for `ParserInfo` that helps in constructing /// the attributes that make up the `ParserInfo` container -#[cfg_attr(feature = "cargo-clippy", allow(get_unwrap))] // Recommended suggestion of &vec[0] doesn't compile pub fn parse_info(vec: Vec>) -> HashMap { let mut m = HashMap::new(); if vec.len() == 1 { - for (i, val) in vec.get(0).unwrap().into_iter().enumerate() { + for (i, val) in vec.get(0).unwrap().iter().enumerate() { m.insert(val.to_lowercase(), i); } } else { - for (i, val_vec) in vec.into_iter().enumerate() { + for (i, val_vec) in vec.iter().enumerate() { for val in val_vec { m.insert(val.to_lowercase(), i); } @@ -516,7 +516,7 @@ impl YMD { )) } - #[cfg_attr(feature = "cargo-clippy", allow(needless_return))] + #[allow(clippy::needless_return)] fn resolve_ymd( &mut self, yearfirst: bool, @@ -670,7 +670,7 @@ impl Parser { /// timezone name support (i.e. "EST", "BRST") is not available by default /// at the moment, they must be added through `tzinfos` at the moment in /// order to be resolved. - #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] // Need to release a 2.0 for changing public API + #[allow(clippy::too_many_arguments)] pub fn parse( &self, timestr: &str, @@ -699,7 +699,7 @@ impl Parser { } } - #[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] // Imitating Python API is priority + #[allow(clippy::cognitive_complexity)] // Imitating Python API is priority fn parse_with_tokens( &self, timestr: &str, @@ -888,6 +888,7 @@ impl Parser { && all_ascii_upper } + #[allow(clippy::unnecessary_unwrap)] fn ampm_valid(&self, hour: Option, ampm: Option, fuzzy: bool) -> ParseResult { let mut val_is_ampm = !(fuzzy && ampm.is_some()); @@ -991,6 +992,7 @@ impl Parser { } } + #[allow(clippy::unnecessary_unwrap)] fn parse_numeric_token( &self, tokens: &[String], @@ -1208,6 +1210,7 @@ impl Parser { hms_idx } + #[allow(clippy::unnecessary_unwrap)] fn parse_hms( &self, idx: usize, @@ -1267,7 +1270,6 @@ impl Parser { (minute, second) } - #[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] // Need Vec type because of mutability in the function that calls us fn recombine_skipped(&self, skipped_idxs: Vec, tokens: Vec) -> Vec { let mut skipped_tokens: Vec = vec![];