mirror of
https://github.com/bspeice/dtparse
synced 2024-12-22 12:28:08 -05:00
Merge #28
28: Disable clippy component for 1.28 r=bspeice a=bspeice And fix some other issues from a `.travis.yml` file I definitely didn't just copy-paste from a separate project... Co-authored-by: Bradlee Speice <bradlee@speice.io>
This commit is contained in:
commit
af6c3238c4
15
.travis.yml
15
.travis.yml
@ -6,6 +6,7 @@ jobs:
|
|||||||
os: linux
|
os: linux
|
||||||
- rust: 1.28.0
|
- rust: 1.28.0
|
||||||
os: linux
|
os: linux
|
||||||
|
env: DISABLE_TOOLS=true
|
||||||
- rust: stable
|
- rust: stable
|
||||||
os: osx
|
os: osx
|
||||||
- rust: stable-msvc
|
- rust: stable-msvc
|
||||||
@ -20,12 +21,10 @@ before_script:
|
|||||||
- rustup show
|
- rustup show
|
||||||
# CMake doesn't like the `sh.exe` provided by Git being in PATH
|
# 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 [[ "$TRAVIS_OS_NAME" == "windows" ]]; then rm "C:/Program Files/Git/usr/bin/sh.exe"; fi
|
||||||
- rustup component add clippy
|
- if [[ "$DISABLE_TOOLS" == "" ]]; then rustup component add clippy; rustup component add rustfmt; fi
|
||||||
- rustup component add rustfmt
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cargo clippy --all
|
- if [[ "$DISABLE_TOOLS" == "" ]]; then cargo clippy --all && cargo fmt --all -- --check; fi
|
||||||
- cargo fmt --all -- --check
|
|
||||||
|
|
||||||
# For default build, split up compilation and tests so we can track build times
|
# For default build, split up compilation and tests so we can track build times
|
||||||
- cargo test --no-run
|
- cargo test --no-run
|
||||||
@ -33,14 +32,6 @@ script:
|
|||||||
- cargo test --release --no-run
|
- cargo test --release --no-run
|
||||||
- cargo test --release
|
- 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:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
22
src/lib.rs
22
src/lib.rs
@ -1,4 +1,5 @@
|
|||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
#![cfg_attr(test, allow(unknown_lints))]
|
||||||
#![cfg_attr(test, deny(warnings))]
|
#![cfg_attr(test, deny(warnings))]
|
||||||
|
|
||||||
//! # dtparse
|
//! # dtparse
|
||||||
@ -165,16 +166,15 @@ pub(crate) fn tokenize(parse_string: &str) -> Vec<String> {
|
|||||||
|
|
||||||
/// Utility function for `ParserInfo` that helps in constructing
|
/// Utility function for `ParserInfo` that helps in constructing
|
||||||
/// the attributes that make up the `ParserInfo` container
|
/// 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<Vec<&str>>) -> HashMap<String, usize> {
|
pub fn parse_info(vec: Vec<Vec<&str>>) -> HashMap<String, usize> {
|
||||||
let mut m = HashMap::new();
|
let mut m = HashMap::new();
|
||||||
|
|
||||||
if vec.len() == 1 {
|
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);
|
m.insert(val.to_lowercase(), i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i, val_vec) in vec.into_iter().enumerate() {
|
for (i, val_vec) in vec.iter().enumerate() {
|
||||||
for val in val_vec {
|
for val in val_vec {
|
||||||
m.insert(val.to_lowercase(), i);
|
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(
|
fn resolve_ymd(
|
||||||
&mut self,
|
&mut self,
|
||||||
yearfirst: bool,
|
yearfirst: bool,
|
||||||
@ -670,7 +670,7 @@ impl Parser {
|
|||||||
/// timezone name support (i.e. "EST", "BRST") is not available by default
|
/// 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
|
/// at the moment, they must be added through `tzinfos` at the moment in
|
||||||
/// order to be resolved.
|
/// 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(
|
pub fn parse(
|
||||||
&self,
|
&self,
|
||||||
timestr: &str,
|
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(
|
fn parse_with_tokens(
|
||||||
&self,
|
&self,
|
||||||
timestr: &str,
|
timestr: &str,
|
||||||
@ -888,6 +888,7 @@ impl Parser {
|
|||||||
&& all_ascii_upper
|
&& all_ascii_upper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unnecessary_unwrap)]
|
||||||
fn ampm_valid(&self, hour: Option<i32>, ampm: Option<bool>, fuzzy: bool) -> ParseResult<bool> {
|
fn ampm_valid(&self, hour: Option<i32>, ampm: Option<bool>, fuzzy: bool) -> ParseResult<bool> {
|
||||||
let mut val_is_ampm = !(fuzzy && ampm.is_some());
|
let mut val_is_ampm = !(fuzzy && ampm.is_some());
|
||||||
|
|
||||||
@ -991,6 +992,7 @@ impl Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unnecessary_unwrap)]
|
||||||
fn parse_numeric_token(
|
fn parse_numeric_token(
|
||||||
&self,
|
&self,
|
||||||
tokens: &[String],
|
tokens: &[String],
|
||||||
@ -1042,11 +1044,7 @@ impl Parser {
|
|||||||
} else if vec![8, 12, 14].contains(&len_li) {
|
} else if vec![8, 12, 14].contains(&len_li) {
|
||||||
// YYMMDD
|
// YYMMDD
|
||||||
let s = &tokens[idx];
|
let s = &tokens[idx];
|
||||||
ymd.append(
|
ymd.append(s[..4].parse::<i32>()?, &s[..4], Some(YMDLabel::Year))?;
|
||||||
s[..4].parse::<i32>()?,
|
|
||||||
&s[..4],
|
|
||||||
Some(YMDLabel::Year),
|
|
||||||
)?;
|
|
||||||
ymd.append(s[4..6].parse::<i32>()?, &s[4..6], None)?;
|
ymd.append(s[4..6].parse::<i32>()?, &s[4..6], None)?;
|
||||||
ymd.append(s[6..8].parse::<i32>()?, &s[6..8], None)?;
|
ymd.append(s[6..8].parse::<i32>()?, &s[6..8], None)?;
|
||||||
|
|
||||||
@ -1212,6 +1210,7 @@ impl Parser {
|
|||||||
hms_idx
|
hms_idx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unnecessary_unwrap)]
|
||||||
fn parse_hms(
|
fn parse_hms(
|
||||||
&self,
|
&self,
|
||||||
idx: usize,
|
idx: usize,
|
||||||
@ -1271,7 +1270,6 @@ impl Parser {
|
|||||||
(minute, second)
|
(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<usize>, tokens: Vec<String>) -> Vec<String> {
|
fn recombine_skipped(&self, skipped_idxs: Vec<usize>, tokens: Vec<String>) -> Vec<String> {
|
||||||
let mut skipped_tokens: Vec<String> = vec![];
|
let mut skipped_tokens: Vec<String> = vec![];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user