diff --git a/.travis.yml b/.travis.yml index 818141c..66bee5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,8 @@ matrix: - cargo build --verbose --all - cargo clippy --all-targets --all-features -- -D warnings -A clippy::cognitive_complexity - cargo test --verbose --all + - cd wasm && cargo clippy -- -D warnings -A clippy::suspicious_else_formatting + - cd ../nodejs/native && cargo clippy -- -D warnings after_success: | cargo tarpaulin --exclude-files nodejs wasm parser/mod.rs --out Xml bash <(curl -s https://codecov.io/bash) diff --git a/build.sh b/build.sh index 1d03efb..b9fbf00 100755 --- a/build.sh +++ b/build.sh @@ -2,9 +2,6 @@ set -e -cargo clippy -- -D warnings && \ -cargo clippy --all-targets --all-features -- -D warnings -A clippy::cognitive_complexity - # project_root DIR="$(pwd)" WASM="${DIR}"/wasm @@ -31,6 +28,16 @@ __cargo_clean () { cd "${DIR}" && cargo clean } +if [ "$1" = "clippy" ] +then + echo + __msg "clippy" + cargo clippy -- -D warnings && \ + cargo clippy --all-targets --all-features -- -D warnings -A clippy::cognitive_complexity && \ + cd "${WASM}" && cargo clippy -- -A clippy::suspicious_else_formatting && \ + cd "${NODEJS}" && cargo clippy +fi + echo __msg "clean" rm -rf \ diff --git a/nodejs/native/src/lib.rs b/nodejs/native/src/lib.rs index 7e36356..0fa84f3 100644 --- a/nodejs/native/src/lib.rs +++ b/nodejs/native/src/lib.rs @@ -206,7 +206,7 @@ declare_types! { { let guard = ctx.lock(); let mut this = this.borrow_mut(&guard); - let _ = this.path(&path); + this.path(&path); } Ok(JsUndefined::new().upcast()) @@ -219,7 +219,7 @@ declare_types! { { let guard = ctx.lock(); let mut this = this.borrow_mut(&guard); - let _ = this.value(&json_str); + this.value(&json_str); } Ok(JsUndefined::new().upcast()) diff --git a/src/lib.rs b/src/lib.rs index 65cd66c..80e9cbb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -132,6 +132,7 @@ extern crate serde_json; use serde_json::Value; +pub use parser::Parser; pub use select::JsonPathError; pub use select::{Selector, SelectorMut}; diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs index ec1b8bf..cf0fb7d 100644 --- a/wasm/src/lib.rs +++ b/wasm/src/lib.rs @@ -102,7 +102,7 @@ pub fn compile(path: &str) -> JsValue { }, Err(e) => JsValue::from_str(&format!("{:?}", e)), } - }) as Box JsValue>); + }) as Box JsValue>); let ret = cb.as_ref().clone(); cb.forget(); @@ -131,8 +131,8 @@ pub fn selector(js_value: JsValue) -> JsValue { Err(e) => JsValue::from_str(&format!("{:?}", e)), } } - Err(e) => return JsValue::from_str(&format!("{:?}", JsonPathError::Path(e))), - }) as Box JsValue>, + Err(e) => JsValue::from_str(&format!("{:?}", JsonPathError::Path(e))), + }) as Box JsValue>, ); let ret = cb.as_ref().clone(); @@ -193,6 +193,7 @@ pub fn replace_with(js_value: JsValue, path: &str, fun: js_sys::Function) -> JsV /// lifetime 제약으로 Selector를 사용 할 수 없다. /// #[wasm_bindgen] +#[derive(Default)] pub struct Selector { path: Option, value: Option, @@ -202,10 +203,7 @@ pub struct Selector { impl Selector { #[wasm_bindgen(constructor)] pub fn new() -> Self { - Selector { - path: None, - value: None, - } + Selector::default() } #[wasm_bindgen(catch)] @@ -263,6 +261,7 @@ impl Selector { /// `wasm_bindgen` 제약으로 builder-pattern을 구사 할 수 없다. /// #[wasm_bindgen] +#[derive(Default)] pub struct SelectorMut { path: Option, value: Option, @@ -272,10 +271,7 @@ pub struct SelectorMut { impl SelectorMut { #[wasm_bindgen(constructor)] pub fn new() -> Self { - SelectorMut { - path: None, - value: None, - } + SelectorMut::default() } #[wasm_bindgen(catch)]