morganlinton/BeautifulRust / skills/rust-review
rust-review
UnverifiedReview existing Rust code for idiom, API design, error handling, safety, and maintainability, and produce a prioritized report where every finding cites the rule it breaks and gives a concrete fix. Use this whenever the user asks to review, audit, critique, grade, or "check" Rust code, a crate, a module, a .rs file, a diff, or a pull request, or asks what is wrong with their Rust or how to make it more idiomatic, even if they don't say "review". Pairs with the rust-best-practices skill, which covers writing new code.
evals/review-bevy-arena/files/tests/arena.rs
View on GitHubuse std::time::Duration;
use arena::*;
use bevy::prelude::*;
#[derive(Resource, Default)]
struct Received(Vec<Hit>);
fn record_hits(mut hits: MessageReader<Hit>, mut received: ResMut<Received>) {
received.0.extend(hits.read().copied());
}
#[test]
fn units_move_by_velocity_unless_stunned() {
let mut app = App::new();
app.init_resource::<Time>().add_systems(Update, move_units);
let walker = app.world_mut().spawn((Position(Vec2::ZERO), Velocity(Vec2::new(10.0, 0.0)))).id();
let stunned = app
.world_mut()
.spawn((Position(Vec2::ZERO), Velocity(Vec2::new(10.0, 0.0)), Stunned))
.id();
app.world_mut().resource_mut::<Time>().advance_by(Duration::from_secs(2));
app.update();
assert_eq!(app.world().get::<Position>(walker), Some(&Position(Vec2::new(20.0, 0.0))));
assert_eq!(app.world().get::<Position>(stunned), Some(&Position(Vec2::ZERO)));
}
#[test]
fn enemies_in_range_hit_the_player() {
let mut app = App::new();
app.init_resource::<ArenaConfig>()
.init_resource::<Received>()
.add_message::<Hit>()
.add_systems(Update, (contact_damage, record_hits).chain());
let player = app.world_mut().spawn((Player, Position(Vec2::ZERO))).id();
app.world_mut().spawn((Enemy, Position(Vec2::new(10.0, 0.0))));
app.world_mut().spawn((Enemy, Position(Vec2::new(10.0, 0.0)), Stunned));
app.world_mut().spawn((Enemy, Position(Vec2::new(100.0, 0.0))));
app.update();
let received = &app.world().resource::<Received>().0;
assert_eq!(received.len(), 1);
assert_eq!(received[0].target, player);
assert_eq!(received[0].amount, 5);
}
#[test]
fn armor_reduces_damage_and_crits_add_half() {
assert_eq!(damage_after_armor(10, 2, false), 8);
assert_eq!(damage_after_armor(10, 2, true), 12);
assert_eq!(damage_after_armor(1, 5, false), 0);
}
#[test]
fn a_cleared_wave_spawns_the_next_one() {
let mut app = App::new();
app.init_resource::<ArenaConfig>()
.insert_resource(Wave { number: 1, cleared: true })
.add_systems(Update, spawn_wave);
app.update();
let enemies = app.world_mut().query_filtered::<(), With<Enemy>>().iter(app.world()).count();
assert_eq!(enemies, 6);
assert!(!app.world().resource::<Wave>().cleared);
}
#[test]
fn the_wave_counter_advances_when_no_enemies_are_left() {
let mut app = App::new();
app.init_resource::<Wave>().add_systems(Update, check_wave_cleared);
app.update();
let wave = app.world().resource::<Wave>();
assert_eq!(wave.number, 1);
assert!(wave.cleared);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |