fix clippy and check it on ci (#18)
This commit is contained in:
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
branches: ["master"]
|
||||
|
||||
jobs:
|
||||
debug:
|
||||
ci:
|
||||
runs-on: [self-hosted, linux]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -23,16 +23,18 @@ jobs:
|
||||
packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
|
||||
version: 1.0
|
||||
|
||||
- name: Formatting
|
||||
run: |
|
||||
cargo fmt --check
|
||||
|
||||
- name: Lints
|
||||
run: |
|
||||
cargo clippy
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --locked --target=x86_64-unknown-linux-gnu
|
||||
cargo build
|
||||
|
||||
- name: Archive
|
||||
- name: Lints
|
||||
run: |
|
||||
cp target/x86_64-unknown-linux-gnu/debug/hedz_reloaded hedz_reloaded
|
||||
tar -czf steamos-debug.tar.gz hedz_reloaded
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: steamos-debug.tar.gz
|
||||
path: ./steamos-debug.tar.gz
|
||||
cargo test
|
||||
|
||||
40
.github/workflows/ci_debug.yml
vendored
Normal file
40
.github/workflows/ci_debug.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: ci_debug
|
||||
|
||||
on:
|
||||
workflow_dispatch: # Enables manual triggers
|
||||
|
||||
jobs:
|
||||
debug:
|
||||
runs-on: [self-hosted, linux]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cargo-bins/cargo-binstall@main
|
||||
- uses: extractions/setup-just@v1
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
components: clippy, rustfmt
|
||||
|
||||
- name: "Install and cache dependencies (Linux)"
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
|
||||
version: 1.0
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --locked --target=x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Lints
|
||||
run: |
|
||||
cargo clippy
|
||||
|
||||
- name: Archive
|
||||
run: |
|
||||
cp target/x86_64-unknown-linux-gnu/debug/hedz_reloaded hedz_reloaded
|
||||
tar -czf steamos-debug.tar.gz hedz_reloaded
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: steamos-debug.tar.gz
|
||||
path: ./steamos-debug.tar.gz
|
||||
@@ -16,7 +16,7 @@ avian3d = { version = "0.2.1", default-features = false, features = [
|
||||
"parry-f32",
|
||||
"collider-from-mesh",
|
||||
"bevy_scene",
|
||||
"bevy_picking", # todo: Consider if this one is necessary
|
||||
"bevy_picking", # todo: Consider if this one is necessary
|
||||
"parallel",
|
||||
] }
|
||||
bevy = "0.15.3"
|
||||
@@ -27,3 +27,7 @@ bevy_sprite3d = "4.0.0"
|
||||
rand = "0.8.5"
|
||||
bevy-inspector-egui = { version = "0.30", optional = true }
|
||||
bevy_polyline = "0.11.0"
|
||||
|
||||
[lints.clippy]
|
||||
too_many_arguments = "allow"
|
||||
type_complexity = "allow"
|
||||
|
||||
6
justfile
6
justfile
@@ -7,3 +7,9 @@ tb_setup_mac:
|
||||
|
||||
dbg:
|
||||
RUST_BACKTRACE=1 cargo r --features dbg
|
||||
|
||||
check:
|
||||
cargo fmt --check
|
||||
cargo b
|
||||
cargo test
|
||||
cargo clippy
|
||||
|
||||
@@ -280,17 +280,13 @@ fn swap_head_inputs(
|
||||
}
|
||||
|
||||
let mut changed = false;
|
||||
if action == BackpackAction::Left {
|
||||
if state.current_slot > 0 {
|
||||
state.current_slot -= 1;
|
||||
changed = true;
|
||||
}
|
||||
if action == BackpackAction::Left && state.current_slot > 0 {
|
||||
state.current_slot -= 1;
|
||||
changed = true;
|
||||
}
|
||||
if action == BackpackAction::Right {
|
||||
if state.current_slot < state.count.saturating_sub(1) {
|
||||
state.current_slot += 1;
|
||||
changed = true;
|
||||
}
|
||||
if action == BackpackAction::Right && state.current_slot < state.count.saturating_sub(1) {
|
||||
state.current_slot += 1;
|
||||
changed = true;
|
||||
}
|
||||
if action == BackpackAction::Swap {
|
||||
commands.trigger(BackbackSwapEvent(state.current_slot));
|
||||
|
||||
@@ -34,7 +34,6 @@ pub fn plugin(app: &mut App) {
|
||||
fn setup(mut commands: Commands) {
|
||||
commands.insert_resource(Backpack {
|
||||
heads: (0usize..HEAD_COUNT)
|
||||
.into_iter()
|
||||
.map(|i| BackpackHead {
|
||||
head: i,
|
||||
health: 1.,
|
||||
|
||||
@@ -66,7 +66,7 @@ fn startup(mut commands: Commands) {
|
||||
|
||||
fn update_look_around(controls: Res<Controls>, mut cam_state: ResMut<CameraState>) {
|
||||
let look_around =
|
||||
controls.keyboard_state.view_mode || controls.gamepad_state.map_or(false, |g| g.view_mode);
|
||||
controls.keyboard_state.view_mode || controls.gamepad_state.is_some_and(|g| g.view_mode);
|
||||
|
||||
if look_around != cam_state.look_around {
|
||||
cam_state.look_around = look_around;
|
||||
|
||||
@@ -239,10 +239,8 @@ fn set_movement_flag(mut player_movement: ResMut<PlayerMovement>, controls: Res<
|
||||
if direction.length_squared() < deadzone {
|
||||
player_movement.any_direction = false;
|
||||
}
|
||||
} else {
|
||||
if direction.length_squared() > deadzone {
|
||||
player_movement.any_direction = true;
|
||||
}
|
||||
} else if direction.length_squared() > deadzone {
|
||||
player_movement.any_direction = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ fn gamepad_controls(
|
||||
if rotate < 0.5 - EPSILON {
|
||||
40. * (rotate - 0.5)
|
||||
} else if rotate > 0.5 + EPSILON {
|
||||
40. * (rotate - 0.5)
|
||||
-40. * (rotate - 0.5)
|
||||
} else {
|
||||
0.
|
||||
},
|
||||
@@ -189,8 +189,8 @@ fn mouse_click(mut events: EventReader<MouseButtonInput>, mut commands: Commands
|
||||
|
||||
fn gamepad_connections(mut evr_gamepad: EventReader<GamepadEvent>) {
|
||||
for ev in evr_gamepad.read() {
|
||||
match ev {
|
||||
GamepadEvent::Connection(connection) => match &connection.connection {
|
||||
if let GamepadEvent::Connection(connection) = ev {
|
||||
match &connection.connection {
|
||||
GamepadConnection::Connected {
|
||||
name,
|
||||
vendor_id,
|
||||
@@ -204,8 +204,7 @@ fn gamepad_connections(mut evr_gamepad: EventReader<GamepadEvent>) {
|
||||
GamepadConnection::Disconnected => {
|
||||
info!("Lost connection with gamepad: {:?}", connection.gamepad);
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ fn on_start_cutscene(
|
||||
let move_end = cutscene_movement
|
||||
.iter()
|
||||
.find(|(_, _, target)| cutscene == target.target.clone().unwrap_or_default())
|
||||
.map(|(t, _, _)| t.clone())
|
||||
.unwrap_or_else(|| t.clone());
|
||||
.map(|(t, _, _)| *t)
|
||||
.unwrap_or_else(|| *t);
|
||||
|
||||
let Some((target, _)) = cam_target.iter().find(|(_, camera_target)| {
|
||||
camera_target.targetname == target.target.clone().unwrap_or_default()
|
||||
|
||||
@@ -14,7 +14,7 @@ fn on_key(trigger: Trigger<KeyCollected>, mut commands: Commands) {
|
||||
|
||||
let entities: HashSet<_> = vec!["fence_01", "fence_02"]
|
||||
.into_iter()
|
||||
.map(|s| String::from(s))
|
||||
.map(String::from)
|
||||
.collect();
|
||||
|
||||
commands.trigger(PlaySound::Gate);
|
||||
@@ -23,10 +23,7 @@ fn on_key(trigger: Trigger<KeyCollected>, mut commands: Commands) {
|
||||
"fence_shaft" => {
|
||||
commands.trigger(StartCutscene("cutscene_02".to_string()));
|
||||
|
||||
let entities: HashSet<_> = vec!["fence_shaft"]
|
||||
.into_iter()
|
||||
.map(|s| String::from(s))
|
||||
.collect();
|
||||
let entities: HashSet<_> = vec!["fence_shaft"].into_iter().map(String::from).collect();
|
||||
|
||||
commands.trigger(PlaySound::Gate);
|
||||
commands.trigger(TriggerMovableEvent(entities));
|
||||
|
||||
@@ -75,7 +75,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
});
|
||||
|
||||
let heads = (0usize..HEAD_COUNT)
|
||||
.into_iter()
|
||||
.map(|i| asset_server.load(format!("ui/heads/{}.png", head_id_to_str(i))))
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{collections::HashMap, usize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
heads_ui::HEAD_COUNT, keys::KeySpawn, player::head_id_to_str, sounds::PlaySound,
|
||||
|
||||
@@ -151,11 +151,7 @@ fn enemy_hit(
|
||||
continue;
|
||||
}
|
||||
|
||||
let enemy_entity = query_npc
|
||||
.contains(*e1)
|
||||
.then(|| *e1)
|
||||
.or_else(|| Some(*e2))
|
||||
.unwrap();
|
||||
let enemy_entity = if query_npc.contains(*e1) { *e1 } else { *e2 };
|
||||
|
||||
commands.entity(enemy_entity).trigger(Hit { damage: 20 });
|
||||
}
|
||||
@@ -199,11 +195,7 @@ fn shot_collision(
|
||||
continue;
|
||||
}
|
||||
|
||||
let shot_entity = query_shot
|
||||
.contains(*e1)
|
||||
.then(|| *e1)
|
||||
.or_else(|| Some(*e2))
|
||||
.unwrap();
|
||||
let shot_entity = if query_shot.contains(*e1) { *e1 } else { *e2 };
|
||||
|
||||
let shot_pos = query_shot.get(shot_entity).unwrap().1.translation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user