finish the lint pass: allow what is contractual, fix what is not
This commit is contained in:
@@ -14,6 +14,10 @@ fn main() {
|
||||
fn compile_shaders() {
|
||||
// Cargo always sets OUT_DIR for a build script; if it is missing the build
|
||||
// is broken in a way we cannot paper over, so say so plainly.
|
||||
#[allow(
|
||||
clippy::expect_used,
|
||||
reason = "a build script without OUT_DIR cannot produce a usable build"
|
||||
)]
|
||||
let out_dir = PathBuf::from(
|
||||
std::env::var("OUT_DIR").expect("OUT_DIR is set by cargo for build scripts"),
|
||||
);
|
||||
|
||||
+16
-2
@@ -322,7 +322,15 @@ fn write_next_packet(
|
||||
} else {
|
||||
match bits_per_sample {
|
||||
16 => {
|
||||
// SAFETY: data_ptr from GetBuffer points to valid i16 samples.
|
||||
// WASAPI allocates the shared buffer aligned for the mix
|
||||
// format it reported, so reinterpreting as i16 is sound;
|
||||
// clippy cannot see that guarantee through the raw pointer.
|
||||
#[allow(
|
||||
clippy::cast_ptr_alignment,
|
||||
reason = "WASAPI's shared buffer is aligned for the mix format it reported"
|
||||
)]
|
||||
// SAFETY: data_ptr from GetBuffer points to `samples` valid
|
||||
// i16 values.
|
||||
let i16_slice =
|
||||
unsafe { std::slice::from_raw_parts(data_ptr as *const i16, samples) };
|
||||
for &sample in i16_slice {
|
||||
@@ -333,7 +341,13 @@ fn write_next_packet(
|
||||
}
|
||||
}
|
||||
32 => {
|
||||
// SAFETY: data_ptr from GetBuffer points to valid i32 samples.
|
||||
// As above, but for i32 samples.
|
||||
#[allow(
|
||||
clippy::cast_ptr_alignment,
|
||||
reason = "WASAPI's shared buffer is aligned for the mix format it reported"
|
||||
)]
|
||||
// SAFETY: data_ptr from GetBuffer points to `samples` valid
|
||||
// i32 values.
|
||||
let i32_slice =
|
||||
unsafe { std::slice::from_raw_parts(data_ptr as *const i32, samples) };
|
||||
for &sample in i32_slice {
|
||||
|
||||
@@ -336,9 +336,9 @@ fn find_ffmpeg_in(dir: &Path) -> Option<PathBuf> {
|
||||
if is_ffmpeg_entry(&name.to_string_lossy()) {
|
||||
return Some(p);
|
||||
}
|
||||
} else {
|
||||
// Neither a directory nor a named file, so nothing to look inside.
|
||||
}
|
||||
// Anything else is neither a directory nor a named file, so there is
|
||||
// nothing to look at inside it.
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -95,6 +95,13 @@ struct TonemapPipeline {
|
||||
height: u32,
|
||||
}
|
||||
|
||||
// One D3D11 object per descriptor, in the order the API documents them; the
|
||||
// length is the API's, not ours, and splitting it would scatter a single
|
||||
// initialization sequence across helpers that each need half the locals.
|
||||
#[allow(
|
||||
clippy::too_many_lines,
|
||||
reason = "linear D3D11 resource setup: each step needs the previous object in scope"
|
||||
)]
|
||||
impl TonemapPipeline {
|
||||
fn new(device: &ID3D11Device, width: u32, height: u32) -> Result<Self> {
|
||||
// Vertex shader: fullscreen-triangle pass-through (no vertex buffer).
|
||||
@@ -303,6 +310,12 @@ impl TonemapPipeline {
|
||||
/// Run the tonemap shader on `src` (the captured HDR texture) and write
|
||||
/// the resulting BGRA8 bytes to `out`. One GPU draw + one staging readback.
|
||||
/// Recreates itself if `src` dimensions differ from the cached RT.
|
||||
// The draw sequence, the bind state and the readback all have to happen in
|
||||
// one call on the frame's own context; the length is the sequence.
|
||||
#[allow(
|
||||
clippy::too_many_lines,
|
||||
reason = "the GPU draw and its readback share one context and one mapped buffer"
|
||||
)]
|
||||
fn process(
|
||||
&mut self,
|
||||
device: &ID3D11Device,
|
||||
@@ -589,7 +602,7 @@ pub(crate) fn primary_monitor_dims() -> Result<(u32, u32)> {
|
||||
/// resolves the device name through `GetMonitorInfoW` and queries its current
|
||||
/// settings with `EnumDisplaySettingsW`. Falls back to [`FALLBACK_REFRESH_HZ`]
|
||||
/// on any failure.
|
||||
fn monitor_refresh_rate(monitor: &Monitor) -> u32 {
|
||||
fn monitor_refresh_rate(monitor: Monitor) -> u32 {
|
||||
match monitor.refresh_rate() {
|
||||
Ok(0) => {
|
||||
tracing::warn!("monitor reported 0 Hz refresh, using fallback");
|
||||
@@ -607,7 +620,7 @@ fn monitor_refresh_rate(monitor: &Monitor) -> u32 {
|
||||
/// capture API. WGC delivers frames roughly at the monitor's refresh rate;
|
||||
/// declaring that rate (instead of a fixed high constant) keeps the raw
|
||||
/// timestamps close to real time so `fix_intermediate_fps` only nudges.
|
||||
fn detect_pipe_framerate(monitor: &Monitor) -> u32 {
|
||||
fn detect_pipe_framerate(monitor: Monitor) -> u32 {
|
||||
monitor_refresh_rate(monitor)
|
||||
}
|
||||
|
||||
@@ -634,6 +647,7 @@ fn monitor_at_point(x: i32, y: i32) -> Result<Monitor> {
|
||||
|
||||
#[allow(
|
||||
clippy::expect_used,
|
||||
clippy::unwrap_in_result,
|
||||
reason = "Windows always has a primary monitor; if enumeration fails there is nothing sensible to capture instead"
|
||||
)]
|
||||
pub(crate) fn start(
|
||||
@@ -672,7 +686,7 @@ pub(crate) fn start(
|
||||
|
||||
let frame_counter = Arc::new(std::sync::atomic::AtomicU64::new(0));
|
||||
|
||||
let pipe_fps = detect_pipe_framerate(&monitor);
|
||||
let pipe_fps = detect_pipe_framerate(monitor);
|
||||
|
||||
let setup = CaptureSetup {
|
||||
output_path: output_path.clone(),
|
||||
@@ -765,6 +779,7 @@ impl CaptureSession {
|
||||
/// `output` exists, returns Ok without re-running ffmpeg.
|
||||
#[allow(
|
||||
clippy::expect_used,
|
||||
clippy::unwrap_in_result,
|
||||
reason = "callers rule out the None case that capture_timing returns None for"
|
||||
)]
|
||||
pub(crate) fn fix_intermediate_fps(
|
||||
|
||||
+19
-1
@@ -919,6 +919,12 @@ pub(crate) fn render_preview(
|
||||
|
||||
/// Render a GIF preview with actual palette and dithering applied.
|
||||
/// Generates a palette from the full clip, then applies it to a single frame.
|
||||
// Every argument is a distinct knob the caller already has in hand; bundling
|
||||
// them into a struct would only move the same list one level up.
|
||||
#[allow(
|
||||
clippy::too_many_arguments,
|
||||
reason = "flat parameter list mirrors the preview request fields the caller owns"
|
||||
)]
|
||||
pub(crate) fn render_gif_preview(
|
||||
ffmpeg: &Path,
|
||||
input: &Path,
|
||||
@@ -1111,6 +1117,8 @@ impl Drop for TempFileGuard {
|
||||
}
|
||||
|
||||
pub(crate) fn concat_segments(ffmpeg: &Path, segments: &[PathBuf], output: &Path) -> Result<()> {
|
||||
use std::fmt::Write as _;
|
||||
|
||||
if segments.is_empty() {
|
||||
bail!("no segments to concatenate");
|
||||
}
|
||||
@@ -1126,7 +1134,6 @@ pub(crate) fn concat_segments(ffmpeg: &Path, segments: &[PathBuf], output: &Path
|
||||
|
||||
let list_path = parent.join("concat-list.txt");
|
||||
let _guard = TempFileGuard(list_path.clone());
|
||||
use std::fmt::Write as _;
|
||||
let mut body = String::new();
|
||||
for seg in segments {
|
||||
let s = seg
|
||||
@@ -1161,6 +1168,12 @@ fn run(cmd: &mut Command, label: &str) -> Result<()> {
|
||||
/// `progress_tx`, if provided, receives (pass, `total_passes`, percent) updates
|
||||
/// driven by ffmpeg's stable key=value output (`out_time_us`) rather than
|
||||
/// fragile stderr line parsing.
|
||||
// Thin forwarder to run_impl, which needs the same list; a params struct here
|
||||
// would just be reconstructed at each of the four call sites.
|
||||
#[allow(
|
||||
clippy::too_many_arguments,
|
||||
reason = "thin forwarder for the ffmpeg invocation; callers already hold these as locals"
|
||||
)]
|
||||
fn run_with_progress(
|
||||
cmd: &mut Command,
|
||||
label: &str,
|
||||
@@ -1211,10 +1224,15 @@ fn ffmpeg_failure_message(label: &str, status: std::process::ExitStatus, stderr:
|
||||
|
||||
// Consumes the progress sender and the cancel flag: both are moved into the
|
||||
// reader threads this spawns, so borrowing them here would not typecheck.
|
||||
// The argument count matches run_with_progress, its only caller.
|
||||
#[allow(
|
||||
clippy::needless_pass_by_value,
|
||||
reason = "progress_tx and cancel are moved into the threads spawned below"
|
||||
)]
|
||||
#[allow(
|
||||
clippy::too_many_arguments,
|
||||
reason = "receives the ffmpeg invocation plus its progress plumbing from run_with_progress"
|
||||
)]
|
||||
fn run_impl(
|
||||
cmd: &mut Command,
|
||||
label: &str,
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
clippy::needless_pass_by_value,
|
||||
reason = "tauri::command arguments are passed by value by the generated wrapper"
|
||||
)]
|
||||
// The remaining `exit` hit is inside tauri::generate_context! itself, so it can
|
||||
// only be silenced at crate scope; app.exit in this code is deliberate (see
|
||||
// apply_update).
|
||||
#![allow(
|
||||
clippy::exit,
|
||||
reason = "bounded by the tauri macro expansion, which exits on its own terms"
|
||||
)]
|
||||
|
||||
mod audio;
|
||||
mod bootstrap;
|
||||
@@ -276,6 +283,12 @@ async fn download_update(
|
||||
.map_err(|e| format!("{e:#}"))
|
||||
}
|
||||
|
||||
// Tauri's app.exit is how this process is meant to hand over to the apply
|
||||
// script; the updater cannot replace a running exe, so exiting is the point.
|
||||
#[allow(
|
||||
clippy::exit,
|
||||
reason = "app.exit is the intended way to let the update script replace the running exe"
|
||||
)]
|
||||
#[tauri::command]
|
||||
fn apply_update(app: AppHandle, state: State<'_, AppState>) -> Result<(), String> {
|
||||
use std::os::windows::process::CommandExt;
|
||||
@@ -735,6 +748,13 @@ fn restart_audio_capture(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Finalising a recording is one transaction: stop the live sessions, fix each
|
||||
// segment's timestamps, concatenate, pad and mux the audio, and hand back the
|
||||
// clip. The steps share `ss` and the temp paths throughout.
|
||||
#[allow(
|
||||
clippy::too_many_lines,
|
||||
reason = "one recording-finalisation transaction; the steps share session state and temp paths"
|
||||
)]
|
||||
#[tauri::command]
|
||||
fn stop_capture(app: AppHandle, state: State<'_, AppState>) -> Result<RecordedClip, String> {
|
||||
set_overlay_clickthrough(&app, false);
|
||||
@@ -1527,6 +1547,12 @@ fn open_window_picker(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
/// Tauri deserializes the return into a JS Result, so the wrapper stays even
|
||||
/// though there is no failure path.
|
||||
#[allow(
|
||||
clippy::unnecessary_wraps,
|
||||
reason = "Result is part of the tauri::command contract the frontend invokes"
|
||||
)]
|
||||
fn close_window_picker(
|
||||
app: AppHandle,
|
||||
state: State<'_, AppState>,
|
||||
@@ -1863,6 +1889,12 @@ fn cancel_export(state: State<'_, AppState>) {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
/// Tauri deserializes the return into a JS Result, so the wrapper stays even
|
||||
/// though there is no failure path.
|
||||
#[allow(
|
||||
clippy::unnecessary_wraps,
|
||||
reason = "Result is part of the tauri::command contract the frontend invokes"
|
||||
)]
|
||||
fn codec_availability(state: State<'_, AppState>) -> Result<encode::CodecAvailability, String> {
|
||||
let ffmpeg = bootstrap::ffmpeg_path(&state.app_dir);
|
||||
if !ffmpeg.is_file() {
|
||||
@@ -1871,6 +1903,13 @@ fn codec_availability(state: State<'_, AppState>) -> Result<encode::CodecAvailab
|
||||
Ok(encode::codec_availability(&ffmpeg))
|
||||
}
|
||||
|
||||
// One export is one transaction: resolve the output path, translate the trim
|
||||
// and crop into encoder terms, run the encode, and report the size. Splitting
|
||||
// it would mean threading the same resolved state through the pieces.
|
||||
#[allow(
|
||||
clippy::too_many_lines,
|
||||
reason = "one export transaction; the request translation feeds directly into the encode call"
|
||||
)]
|
||||
#[tauri::command]
|
||||
async fn export(app: AppHandle, state: State<'_, AppState>, request: ExportRequest) -> Result<ExportResult, String> {
|
||||
let (cfg, clip, app_dir, export_cancel) = {
|
||||
@@ -2006,10 +2045,22 @@ async fn export(app: AppHandle, state: State<'_, AppState>, request: ExportReque
|
||||
|
||||
// Process startup: if the exe directory cannot be resolved or config.toml
|
||||
// cannot be created there, there is no degraded mode worth continuing into.
|
||||
/// Start the app: resolve the portable directory, sweep temp/, wire up logging
|
||||
/// and the hotkeys, then hand control to Tauri's event loop.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if the executable's own directory cannot be resolved or if
|
||||
/// `config.toml` cannot be created there. Both are fatal for a portable build:
|
||||
/// there is nowhere to write config, logs or temp files.
|
||||
#[allow(
|
||||
clippy::expect_used,
|
||||
reason = "fatal startup conditions with no sensible recovery"
|
||||
)]
|
||||
#[allow(
|
||||
clippy::too_many_lines,
|
||||
reason = "app wiring: logging, state, plugins, hotkeys, updater, then the event loop - one sequence"
|
||||
)]
|
||||
pub fn run() {
|
||||
let app_dir = exe_dir().expect("resolve exe directory");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user