diff --git a/.drone.yml b/.drone.yml index 416a666..1d41f9d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,4 +11,8 @@ steps: - name: build-release-linux image: deukhoofd/linux64builder commands: - - cargo build --release \ No newline at end of file + - cargo build --release + - name: clippy-check + image: deukhoofd/linux64builder + commands: + - cargo clippy --all-targets -- -D warnings \ No newline at end of file diff --git a/gen_7_scripts/src/moves/acupressure.rs b/gen_7_scripts/src/moves/acupressure.rs index 7f005bf..98649bb 100755 --- a/gen_7_scripts/src/moves/acupressure.rs +++ b/gen_7_scripts/src/moves/acupressure.rs @@ -78,7 +78,7 @@ mod tests { random.expect_get_between().returning_st(|low, high| { assert_eq!(1, low); assert_eq!(6, high); - return 1; + 1 }); Rc::new(random) }); @@ -89,7 +89,7 @@ mod tests { .returning(|stat, amount, self_inflicted| { assert_eq!(Statistic::Attack, stat); assert_eq!(2, amount); - assert_eq!(false, self_inflicted); + assert!(!self_inflicted); true }); diff --git a/gen_7_scripts/src/moves/after_you.rs b/gen_7_scripts/src/moves/after_you.rs index 7846183..0f09443 100755 --- a/gen_7_scripts/src/moves/after_you.rs +++ b/gen_7_scripts/src/moves/after_you.rs @@ -64,7 +64,7 @@ mod tests { target .expect_battle() .once() - .return_once_st(move || Some(battle.clone())); + .return_once_st(move || Some(battle)); let target = Rc::new(target); let script = AfterYou::new(); diff --git a/gen_7_scripts/src/moves/assist.rs b/gen_7_scripts/src/moves/assist.rs index 5c8ea4c..2a3e09a 100755 --- a/gen_7_scripts/src/moves/assist.rs +++ b/gen_7_scripts/src/moves/assist.rs @@ -52,7 +52,7 @@ impl Script for Assist { let party = battle.find_party_for_pokemon(&user).unwrap().party(); let possible_moves = Self::get_party_moves(&party, &user); - if possible_moves.len() == 0 { + if possible_moves.is_empty() { choice.fail(); return; } diff --git a/pkmn_lib_interface/src/lib.rs b/pkmn_lib_interface/src/lib.rs index 05f12d7..1891190 100755 --- a/pkmn_lib_interface/src/lib.rs +++ b/pkmn_lib_interface/src/lib.rs @@ -14,6 +14,9 @@ #![feature(adt_const_params)] #![cfg_attr(not(feature = "mock_data"), no_std)] #![allow(incomplete_features)] +// These give false positives too often +#![allow(clippy::borrowed_box)] +#![allow(clippy::needless_lifetimes)] extern crate alloc; extern crate core; @@ -24,6 +27,7 @@ static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc {}; pub(crate) use crate::app_interface::StringKey; pub(crate) use crate::handling::extern_ref::*; +use alloc::boxed::Box; #[macro_use] #[allow(dead_code)] @@ -31,8 +35,12 @@ pub mod app_interface; pub mod handling; pub mod utils; +pub type LoadScriptFnType = Box Option>>; + #[cfg(not(feature = "mock_data"))] mod implementation { + use super::LoadScriptFnType; + use crate::app_interface::list::{EffectParameterImmutableList, ImmutableListWasm}; use crate::app_interface::{ BattleImpl, DamageSource, DynamicLibraryImpl, EffectParameter, ExecutingMoveImpl, ItemImpl, @@ -48,8 +56,6 @@ mod implementation { use cstr_core::{c_char, CString}; use hashbrown::HashMap; - pub type LoadScriptFnType = Box Option>>; - static mut LOAD_SCRIPT_FN: Option = None; pub fn set_load_script_fn(f: LoadScriptFnType) { @@ -663,5 +669,9 @@ mod implementation { } } +use crate::handling::{Script, ScriptCategory}; #[cfg(not(feature = "mock_data"))] pub use implementation::*; + +#[cfg(feature = "mock_data")] +pub fn set_load_script_fn(_f: LoadScriptFnType) {}