diff --git a/src/mania/convert/mod.rs b/src/mania/convert/mod.rs index 365e779d..ad2bf5bb 100644 --- a/src/mania/convert/mod.rs +++ b/src/mania/convert/mod.rs @@ -200,7 +200,7 @@ fn target_columns(map: &Beatmap) -> f32 { // * In osu!stable, this division appears as if it happens on floats, but due to release-mode // * optimisations, it actually ends up happening on doubles. - let percent_slider_or_spinner = f64::from(count_slider_or_spinner as f64 / len as f64); + let percent_slider_or_spinner = count_slider_or_spinner as f64 / len as f64; if percent_slider_or_spinner < 0.2 { return 7.0; @@ -211,7 +211,11 @@ fn target_columns(map: &Beatmap) -> f32 { } } - ((rounded_od as i32) + 1).min(7).max(4) as f32 + // Keeping it in-sync with lazer + #[allow(clippy::manual_clamp)] + { + ((rounded_od as i32) + 1).min(7).max(4) as f32 + } } #[cfg(test)] diff --git a/src/model/beatmap/attributes.rs b/src/model/beatmap/attributes.rs index 7133a379..a75dada0 100644 --- a/src/model/beatmap/attributes.rs +++ b/src/model/beatmap/attributes.rs @@ -382,6 +382,8 @@ impl From<&Converted<'_, M>> for BeatmapAttributesBuilder { } } +// False positive? Value looks consumed to me... +#[allow(clippy::needless_pass_by_value)] fn difficulty_range(difficulty: f64, windows: GameModeHitWindows) -> f64 { let GameModeHitWindows { min, avg: mid, max } = windows; @@ -425,13 +427,18 @@ impl ModsDependentKind { #[cfg(test)] mod tests { - use rosu_mods::{generated_mods::DifficultyAdjustOsu, GameMod, GameMods}; + #![allow(clippy::float_cmp)] + + use rosu_mods::{ + generated_mods::{DifficultyAdjustOsu, DoubleTimeCatch, DoubleTimeOsu, HiddenOsu}, + GameMod, GameMods, + }; use super::*; #[test] fn default_ar() { - let gamemod = GameMod::HiddenOsu(Default::default()); + let gamemod = GameMod::HiddenOsu(HiddenOsu::default()); let diff = Difficulty::new().mods(GameMods::from(gamemod)); let attrs = BeatmapAttributesBuilder::new().difficulty(&diff).build(); @@ -440,7 +447,7 @@ mod tests { #[test] fn custom_ar_without_mods() { - let gamemod = GameMod::DoubleTimeOsu(Default::default()); + let gamemod = GameMod::DoubleTimeOsu(DoubleTimeOsu::default()); let diff = Difficulty::new().mods(GameMods::from(gamemod)); let attrs = BeatmapAttributesBuilder::new() .ar(8.5, false) @@ -452,7 +459,7 @@ mod tests { #[test] fn custom_ar_with_mods() { - let gamemod = GameMod::DoubleTimeOsu(Default::default()); + let gamemod = GameMod::DoubleTimeOsu(DoubleTimeOsu::default()); let diff = Difficulty::new().mods(GameMods::from(gamemod)); let attrs = BeatmapAttributesBuilder::new() .ar(8.5, true) @@ -465,10 +472,10 @@ mod tests { #[test] fn custom_mods_ar() { let mut mods = GameMods::new(); - mods.insert(GameMod::DoubleTimeCatch(Default::default())); + mods.insert(GameMod::DoubleTimeCatch(DoubleTimeCatch::default())); mods.insert(GameMod::DifficultyAdjustOsu(DifficultyAdjustOsu { approach_rate: Some(7.0), - ..Default::default() + ..DifficultyAdjustOsu::default() })); let diff = Difficulty::new().mods(mods); let attrs = BeatmapAttributesBuilder::new().difficulty(&diff).build(); @@ -479,10 +486,10 @@ mod tests { #[test] fn custom_ar_custom_mods_ar_without_mods() { let mut mods = GameMods::new(); - mods.insert(GameMod::DoubleTimeCatch(Default::default())); + mods.insert(GameMod::DoubleTimeCatch(DoubleTimeCatch::default())); mods.insert(GameMod::DifficultyAdjustOsu(DifficultyAdjustOsu { approach_rate: Some(9.0), - ..Default::default() + ..DifficultyAdjustOsu::default() })); let diff = Difficulty::new().mods(mods).ar(8.5, false); @@ -494,10 +501,10 @@ mod tests { #[test] fn custom_ar_custom_mods_ar_with_mods() { let mut mods = GameMods::new(); - mods.insert(GameMod::DoubleTimeCatch(Default::default())); + mods.insert(GameMod::DoubleTimeCatch(DoubleTimeCatch::default())); mods.insert(GameMod::DifficultyAdjustOsu(DifficultyAdjustOsu { approach_rate: Some(9.0), - ..Default::default() + ..DifficultyAdjustOsu::default() })); let diff = Difficulty::new().mods(mods).ar(8.5, true); diff --git a/src/osu/difficulty/gradual.rs b/src/osu/difficulty/gradual.rs index e12c4f98..fc724ae5 100644 --- a/src/osu/difficulty/gradual.rs +++ b/src/osu/difficulty/gradual.rs @@ -178,9 +178,9 @@ impl Iterator for OsuGradualDifficulty { DifficultyValues::eval( &mut attrs, self.difficulty.get_mods(), - aim_difficulty_value, - aim_no_sliders_difficulty_value, - speed_difficulty_value, + &aim_difficulty_value, + &aim_no_sliders_difficulty_value, + &speed_difficulty_value, speed_relevant_note_count, flashlight_difficulty_value, ); diff --git a/src/osu/difficulty/mod.rs b/src/osu/difficulty/mod.rs index 0b5ca3ee..e358bba8 100644 --- a/src/osu/difficulty/mod.rs +++ b/src/osu/difficulty/mod.rs @@ -53,9 +53,9 @@ pub fn difficulty(difficulty: &Difficulty, converted: &OsuBeatmap<'_>) -> OsuDif DifficultyValues::eval( &mut attrs, mods, - aim_difficulty_value, - aim_no_sliders_difficulty_value, - speed_difficulty_value, + &aim_difficulty_value, + &aim_no_sliders_difficulty_value, + &speed_difficulty_value, speed_relevant_note_count, flashlight_difficulty_value, ); @@ -151,9 +151,9 @@ impl DifficultyValues { pub fn eval( attrs: &mut OsuDifficultyAttributes, mods: &GameMods, - aim: UsedOsuStrainSkills, - aim_no_sliders: UsedOsuStrainSkills, - speed: UsedOsuStrainSkills, + aim: &UsedOsuStrainSkills, + aim_no_sliders: &UsedOsuStrainSkills, + speed: &UsedOsuStrainSkills, speed_relevant_note_count: f64, flashlight_difficulty_value: f64, ) { diff --git a/src/osu/difficulty/skills/speed.rs b/src/osu/difficulty/skills/speed.rs index ab27c7b7..1ff48a82 100644 --- a/src/osu/difficulty/skills/speed.rs +++ b/src/osu/difficulty/skills/speed.rs @@ -203,6 +203,7 @@ impl RhythmEvaluator { const RHYTHM_OVERALL_MULTIPLIER: f64 = 0.95; const RHYTHM_RATIO_MULTIPLIER: f64 = 12.0; + #[allow(clippy::too_many_lines)] fn evaluate_diff_of<'a>( curr: &'a OsuDifficultyObject<'a>, diff_objects: &'a [OsuDifficultyObject<'a>], @@ -409,7 +410,7 @@ const _: [(); 0 - !{ MIN_DELTA_TIME - OsuDifficultyObject::MIN_DELTA_TIME as i32 []; impl RhythmIsland { - fn new(delta_difference_eps: f64) -> Self { + const fn new(delta_difference_eps: f64) -> Self { Self { delta_difference_eps, delta: 0, @@ -433,7 +434,7 @@ impl RhythmIsland { self.delta_count += 1; } - fn is_similar_polarity(&self, other: &Self) -> bool { + const fn is_similar_polarity(&self, other: &Self) -> bool { // * TODO: consider islands to be of similar polarity only if they're having the same average delta (we don't want to consider 3 singletaps similar to a triple) // * naively adding delta check here breaks _a lot_ of maps because of the flawed ratio calculation self.delta_count % 2 == other.delta_count % 2 diff --git a/src/osu/difficulty/skills/strain.rs b/src/osu/difficulty/skills/strain.rs index f563fbd5..111eb7c1 100644 --- a/src/osu/difficulty/skills/strain.rs +++ b/src/osu/difficulty/skills/strain.rs @@ -11,7 +11,7 @@ impl Default for OsuStrainSkill { Self { // mean=406.72 | median=307 object_strains: Vec::with_capacity(256), - inner: Default::default(), + inner: StrainSkill::default(), } } } @@ -90,7 +90,7 @@ pub struct UsedOsuStrainSkills { } impl UsedOsuStrainSkills { - pub fn difficulty_value(&self) -> f64 { + pub const fn difficulty_value(&self) -> f64 { self.value.0 } diff --git a/src/osu/performance/mod.rs b/src/osu/performance/mod.rs index 6b3d20ff..4b4310f7 100644 --- a/src/osu/performance/mod.rs +++ b/src/osu/performance/mod.rs @@ -645,7 +645,7 @@ impl OsuPerformanceInner<'_> { aim_value *= len_bonus; if self.effective_miss_count > 0.0 { - aim_value *= self.calculate_miss_penalty( + aim_value *= Self::calculate_miss_penalty( self.effective_miss_count, self.attrs.aim_difficult_strain_count, ); @@ -714,7 +714,7 @@ impl OsuPerformanceInner<'_> { speed_value *= len_bonus; if self.effective_miss_count > 0.0 { - speed_value *= self.calculate_miss_penalty( + speed_value *= Self::calculate_miss_penalty( self.effective_miss_count, self.attrs.speed_difficult_strain_count, ); @@ -857,7 +857,7 @@ impl OsuPerformanceInner<'_> { // * Miss penalty assumes that a player will miss on the hardest parts of a map, // * so we use the amount of relatively difficult sections to adjust miss penalty // * to make it more punishing on maps with lower amount of hard sections. - fn calculate_miss_penalty(&self, miss_count: f64, diff_strain_count: f64) -> f64 { + fn calculate_miss_penalty(miss_count: f64, diff_strain_count: f64) -> f64 { 0.96 / ((miss_count / (4.0 * diff_strain_count.ln().powf(0.94))) + 1.0) } diff --git a/src/taiko/convert.rs b/src/taiko/convert.rs index 916077f2..83a19ef9 100644 --- a/src/taiko/convert.rs +++ b/src/taiko/convert.rs @@ -174,7 +174,7 @@ struct SliderParams<'c> { } impl<'c> SliderParams<'c> { - fn new(start_time: f64, slider: &'c Slider) -> Self { + const fn new(start_time: f64, slider: &'c Slider) -> Self { Self { slider, start_time, diff --git a/src/taiko/performance/mod.rs b/src/taiko/performance/mod.rs index 7c407778..6a8ac6e1 100644 --- a/src/taiko/performance/mod.rs +++ b/src/taiko/performance/mod.rs @@ -511,6 +511,7 @@ impl TaikoPerformanceInner<'_> { let h100 = self.attrs.ok_hit_window; let n = self.total_hits(); + #[allow(clippy::items_after_statements, clippy::unreadable_literal)] // * 99% critical value for the normal distribution (one-tailed). const Z: f64 = 2.32634787404; diff --git a/src/util/special_functions.rs b/src/util/special_functions.rs index 96c4ee82..1e5754f2 100644 --- a/src/util/special_functions.rs +++ b/src/util/special_functions.rs @@ -1,3 +1,10 @@ +#![allow( + clippy::excessive_precision, + clippy::too_many_lines, + clippy::unreadable_literal, + clippy::many_single_char_names +)] + #[rustfmt::skip] mod consts { pub const ERF_IMP_AN: &[f64] = &[ 0.00337916709551257388990745, -0.00073695653048167948530905, -0.374732337392919607868241, 0.0817442448733587196071743, -0.0421089319936548595203468, 0.0070165709512095756344528, -0.00495091255982435110337458, 0.000871646599037922480317225 ]; @@ -45,6 +52,7 @@ mod consts { pub const ERV_INV_IMP_GD: &[f64] = &[ 1.0, 0.0845746234001899436914, 0.00282092984726264681981, 0.468292921940894236786e-4, 0.399968812193862100054e-6, 0.161809290887904476097e-8, 0.231558608310259605225e-11 ]; } +#[allow(clippy::wildcard_imports)] use consts::*; pub fn erf(x: f64) -> f64 {