Skip to content

Commit

Permalink
Fix up Clippy and move lint config out of CI and into Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
rparrett committed Feb 22, 2024
1 parent fadcc83 commit a4b80df
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings -A clippy::type_complexity -A clippy::too_many_arguments -W clippy::doc_markdown
args: --all-targets --all-features -- -D warnings

# Run cargo fmt --all -- --check
format:
Expand Down
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ rstar = "0.11"
[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys = { version = "0.3", features = ["console", "Window", "Storage"] }

[lints.clippy]
type_complexity = "allow"
too_many_arguments = "allow"
doc_markdown = "warn"
manual_let_else = "warn"
redundant_else = "warn"
match_same_arms = "warn"
semicolon_if_nothing_returned = "warn"
map_flatten = "warn"

# Enable only a small amount of optimization in debug mode
[profile.dev]
Expand Down
38 changes: 16 additions & 22 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,19 +603,15 @@ fn show_score_dialog_system(
return;
}

let level = match handles
let Some(level) = handles
.levels
.get(selected_level.0 as usize - 1)
.and_then(|h| levels.get(h))
{
Some(level) => level,
None => return,
else {
return;
};

let score = match score.0 {
Some(score) => score,
None => return,
};
let Some(score) = score.0 else { return };

let num_stars = level
.star_thresholds
Expand Down Expand Up @@ -812,7 +808,7 @@ fn dismiss_score_dialog_button_system(
}

if let Ok(mut color) = q_node.get_single_mut() {
*color = Color::NONE.into()
*color = Color::NONE.into();
}
}
}
Expand Down Expand Up @@ -1746,9 +1742,9 @@ fn drawing_mouse_movement_system(
{
connections
.0
.push(SegmentConnection::TryExtend(parent.get()))
.push(SegmentConnection::TryExtend(parent.get()));
} else {
connections.0.push(SegmentConnection::Add(parent.get()))
connections.0.push(SegmentConnection::Add(parent.get()));
}
}
if (line_state.start == *b && start_touching)
Expand All @@ -1759,9 +1755,9 @@ fn drawing_mouse_movement_system(
{
connections
.1
.push(SegmentConnection::TryExtend(parent.get()))
.push(SegmentConnection::TryExtend(parent.get()));
} else {
connections.1.push(SegmentConnection::Add(parent.get()))
connections.1.push(SegmentConnection::Add(parent.get()));
}
}
}
Expand Down Expand Up @@ -1805,7 +1801,7 @@ fn drawing_mouse_movement_system(
adds.push(AddSegment {
points: (*a, *b),
connections,
})
});
}

if ok {
Expand Down Expand Up @@ -2072,14 +2068,12 @@ fn update_cost_system(
let mut cost = 0.0;

for (segment, children) in q_segments.iter() {
let child = match children.first() {
Some(child) => child,
None => continue,
let Some(child) = children.first() else {
continue;
};

let layer = match q_colliders.get(*child) {
Ok(layer) => layer,
Err(_) => continue,
let Ok(layer) = q_colliders.get(*child) else {
continue;
};

let multiplier = if layer.0 == 1 {
Expand Down Expand Up @@ -2122,7 +2116,7 @@ fn update_cost_system(
} else {
text.sections[1].value = "".to_string();
}
text.sections[1].style.color = color::FINISHED_ROAD[line_draw.layer as usize - 1]
text.sections[1].style.color = color::FINISHED_ROAD[line_draw.layer as usize - 1];
}
}

Expand Down Expand Up @@ -2171,7 +2165,7 @@ fn update_score_text_system(
if let Some(best) = best_scores.0.get(&selected_level.0) {
text.sections[0].value = format!("Æ{best}");
} else {
text.sections[0].value = "Æ?".to_string()
text.sections[0].value = "Æ?".to_string();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pixie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ pub fn move_pixies_system(
if speed_diff > f32::EPSILON {
pixie.current_speed += acceleration * delta;
pixie.current_speed = pixie.current_speed.min(speed_limit);
pixie.driving_state = DrivingState::Accelerating
pixie.driving_state = DrivingState::Accelerating;
}

// move the pixie
Expand All @@ -454,7 +454,7 @@ pub fn move_pixies_system(
} else if prev_layer < current_layer && last_dist < PIXIE_RADIUS {
transform.translation.z = layer::PIXIE - prev_layer as f32;
} else {
transform.translation.z = layer::PIXIE - current_layer as f32
transform.translation.z = layer::PIXIE - current_layer as f32;
}
} else {
pixie.path_index += segments_traveled;
Expand Down
5 changes: 2 additions & 3 deletions src/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ impl Plugin for SavePlugin {
pub fn load_system(mut commands: Commands) {
#[cfg(not(target_arch = "wasm32"))]
{
let file = match std::fs::File::open(SAVE_FILE) {
Ok(f) => f,
Err(_) => return,
let Ok(file) = std::fs::File::open(SAVE_FILE) else {
return;
};

let save_file: SaveFile = match ron::de::from_reader(file) {
Expand Down

0 comments on commit a4b80df

Please sign in to comment.