diff --git a/.github/workflows/check.sh b/.github/workflows/check.sh index 8c45e10..3b17eb8 100755 --- a/.github/workflows/check.sh +++ b/.github/workflows/check.sh @@ -2,19 +2,7 @@ set -eux -o pipefail -cargo fmt --check || ( - printf " -Please run 'cargo fmt' to format the code. -" - exit 1 -) - -cargo clippy -- -D clippy::nursery || ( - printf " -run 'cargo clippy -- -D clippy::nursery' to check the code. -" - exit 1 -) +cargo fmt --check cargo install cargo-llvm-cov --locked SKIP_TRAINING=1 cargo llvm-cov --release diff --git a/src/algo.rs b/src/algo.rs index beb7a4e..ff30443 100644 --- a/src/algo.rs +++ b/src/algo.rs @@ -1,8 +1,8 @@ +use crate::ImplScheduler; use crate::models::{Card, Rating, RecordLog, SchedulingInfo}; use crate::parameters::Parameters; use crate::scheduler_basic::BasicScheduler; use crate::scheduler_longterm::LongtermScheduler; -use crate::ImplScheduler; use chrono::{DateTime, Utc}; diff --git a/src/lib.rs b/src/lib.rs index 74a3845..84800f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,9 @@ -#![deny(warnings)] +#![deny(clippy::all)] mod algo; pub use algo::FSRS; mod alea; -pub use alea::{alea, Alea, AleaState, Prng}; +pub use alea::{Alea, AleaState, Prng, alea}; mod scheduler; pub use scheduler::{ImplScheduler, Scheduler}; diff --git a/src/parameters.rs b/src/parameters.rs index 536f2b6..5b78545 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -1,7 +1,7 @@ use chrono::Utc; -use crate::alea; use crate::Rating; +use crate::alea; type Weights = [f64; 19]; const DEFAULT_WEIGHTS: Weights = [ @@ -36,7 +36,7 @@ impl Parameters { (self.w[4] - f64::exp(self.w[5] * (rating_int as f64 - 1.0)) + 1.0).clamp(1.0, 10.0) } - pub fn init_stability(&self, rating: Rating) -> f64 { + pub const fn init_stability(&self, rating: Rating) -> f64 { let rating_int: i32 = rating as i32; self.w[(rating_int - 1) as usize].max(0.1) } diff --git a/src/scheduler.rs b/src/scheduler.rs index e5ebdde..5a4db31 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -1,10 +1,10 @@ use chrono::{DateTime, Utc}; -use crate::models::State::*; use crate::Seed; +use crate::models::State::*; use crate::{ - models::{RecordLog, SchedulingInfo}, Card, Parameters, Rating, ReviewLog, + models::{RecordLog, SchedulingInfo}, }; #[derive(Debug, Clone)] diff --git a/src/scheduler_basic.rs b/src/scheduler_basic.rs index f8acade..46b1f90 100644 --- a/src/scheduler_basic.rs +++ b/src/scheduler_basic.rs @@ -1,6 +1,6 @@ use chrono::{DateTime, Duration, Utc}; -use crate::{scheduler::Scheduler, Card, ImplScheduler, Parameters, Rating, SchedulingInfo}; +use crate::{Card, ImplScheduler, Parameters, Rating, SchedulingInfo, scheduler::Scheduler}; use crate::{Rating::*, State::*}; pub struct BasicScheduler { pub scheduler: Scheduler, diff --git a/src/tests.rs b/src/tests.rs index a403319..fc5ea29 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,7 +1,7 @@ #[cfg(test)] use { crate::{ - alea::{alea, AleaState}, + alea::{AleaState, alea}, algo::FSRS, models::{Card, Rating, State}, parameters::{Parameters, Seed}, @@ -204,7 +204,7 @@ fn test_alea_int32() { #[test] fn test_alea_import_state() { let mut rng = rand::thread_rng(); - let mut prng_1 = alea(Seed::new(rng.gen::())); + let mut prng_1 = alea(Seed::new(rng.r#gen::())); prng_1.gen_next(); prng_1.gen_next(); prng_1.gen_next();