[fix](workspace): resolve clippy warnings

Clean up the workspace so cargo clippy passes across all targets and features.

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-01 13:22:44 +01:00
parent 523f3992f5
commit 46bc96ddf2
10 changed files with 89 additions and 102 deletions
+2
View File
@@ -265,6 +265,7 @@ pub fn spawn_audio_capture(
})
}
#[allow(clippy::too_many_arguments)]
fn run_capture(
sample_rate: u32,
channels: u16,
@@ -1306,6 +1307,7 @@ pub async fn run_audio_listener(
Ok(())
}
#[allow(clippy::too_many_arguments)]
async fn handle_audio_client(
socket: TcpStream,
peer: SocketAddr,
+15 -34
View File
@@ -27,7 +27,7 @@ use trx_core::rig::state::RigMode;
/// `[behavior]` / `[decode_logs]` fields are still supported via
/// `ServerConfig::resolved_rigs()` which synthesises a single-element list
/// with `id = "default"` when `rigs` is empty.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct RigInstanceConfig {
/// Stable rig identifier used in protocol routing.
@@ -51,22 +51,6 @@ pub struct RigInstanceConfig {
pub decode_logs: DecodeLogsConfig,
}
impl Default for RigInstanceConfig {
fn default() -> Self {
Self {
id: String::new(), // Empty by default so auto-generation triggers in resolved_rigs()
name: None,
rig: RigConfig::default(),
behavior: BehaviorConfig::default(),
audio: AudioConfig::default(),
sdr: SdrConfig::default(),
pskreporter: PskReporterConfig::default(),
aprsfi: AprsFiConfig::default(),
decode_logs: DecodeLogsConfig::default(),
}
}
}
impl RigInstanceConfig {
/// Get the display name for this rig.
/// Returns the configured name if set, otherwise the id.
@@ -520,18 +504,14 @@ impl ServerConfig {
let mut seen_ports: std::collections::HashSet<u16> = std::collections::HashSet::new();
for rig in &self.rigs {
// Check for explicit duplicate IDs (empty IDs are auto-generated later).
if !rig.id.trim().is_empty() {
if !seen_ids.insert(rig.id.clone()) {
return Err(format!("[[rigs]] duplicate rig id: \"{}\"", rig.id));
}
if !rig.id.trim().is_empty() && !seen_ids.insert(rig.id.clone()) {
return Err(format!("[[rigs]] duplicate rig id: \"{}\"", rig.id));
}
if rig.audio.enabled {
if !seen_ports.insert(rig.audio.port) {
return Err(format!(
"[[rigs]] duplicate audio port {} (rig id: \"{}\")",
rig.audio.port, rig.id
));
}
if rig.audio.enabled && !seen_ports.insert(rig.audio.port) {
return Err(format!(
"[[rigs]] duplicate audio port {} (rig id: \"{}\")",
rig.audio.port, rig.id
));
}
if let Some(max_gain) = rig.sdr.gain.max_value {
if !max_gain.is_finite() {
@@ -979,12 +959,13 @@ tokens = ["secret123"]
stream_opus: bool,
decoders: Vec<String>,
) {
let mut ch = SdrChannelConfig::default();
ch.id = id.to_string();
ch.offset_hz = offset_hz;
ch.stream_opus = stream_opus;
ch.decoders = decoders;
cfg.sdr.channels.push(ch);
cfg.sdr.channels.push(SdrChannelConfig {
id: id.to_string(),
offset_hz,
stream_opus,
decoders,
..SdrChannelConfig::default()
});
}
#[test]
+14 -13
View File
@@ -269,14 +269,18 @@ fn parse_rig_mode(
}
}
/// Build a `SoapySdrRig` with full channel config from a `RigInstanceConfig`.
#[cfg(feature = "soapysdr")]
fn build_sdr_rig_from_instance(
rig_cfg: &RigInstanceConfig,
) -> DynResult<(
type SdrRigBuildResult = DynResult<(
Box<dyn trx_core::rig::RigCat>,
tokio::sync::broadcast::Receiver<Vec<f32>>,
)> {
)>;
type OptionalSdrRig = Option<Box<dyn trx_core::rig::RigCat>>;
type OptionalSdrPcmRx = Option<broadcast::Receiver<Vec<f32>>>;
/// Build a `SoapySdrRig` with full channel config from a `RigInstanceConfig`.
#[cfg(feature = "soapysdr")]
fn build_sdr_rig_from_instance(rig_cfg: &RigInstanceConfig) -> SdrRigBuildResult {
use trx_core::radio::freq::Freq;
use trx_core::rig::AudioSource;
@@ -332,6 +336,7 @@ fn build_sdr_rig_from_instance(
}
/// Build a `RigTaskConfig` for a single rig instance.
#[allow(clippy::too_many_arguments)]
fn build_rig_task_config(
rig_cfg: &RigInstanceConfig,
rig_model: String,
@@ -391,6 +396,7 @@ fn build_rig_task_config(
///
/// `sdr_pcm_rx` carries a live SDR PCM receiver when the rig uses the
/// SoapySDR backend; `None` selects the cpal capture path.
#[allow(clippy::too_many_arguments)]
fn spawn_rig_audio_stack(
rig_cfg: &RigInstanceConfig,
state_rx: watch::Receiver<RigState>,
@@ -812,10 +818,8 @@ async fn main() -> DynResult<()> {
// Build SDR rig when applicable.
#[cfg(feature = "soapysdr")]
let (sdr_prebuilt_rig, sdr_pcm_rx): (
Option<Box<dyn trx_core::rig::RigCat>>,
Option<broadcast::Receiver<Vec<f32>>>,
) = if rig_cfg.rig.access.access_type.as_deref() == Some("sdr") {
let (sdr_prebuilt_rig, sdr_pcm_rx): (OptionalSdrRig, OptionalSdrPcmRx) =
if rig_cfg.rig.access.access_type.as_deref() == Some("sdr") {
let (rig, pcm_rx) = build_sdr_rig_from_instance(rig_cfg)?;
(Some(rig), Some(pcm_rx))
} else {
@@ -823,10 +827,7 @@ async fn main() -> DynResult<()> {
};
#[cfg(not(feature = "soapysdr"))]
let (sdr_prebuilt_rig, sdr_pcm_rx): (
Option<Box<dyn trx_core::rig::RigCat>>,
Option<broadcast::Receiver<Vec<f32>>>,
) = (None, None);
let (sdr_prebuilt_rig, sdr_pcm_rx): (OptionalSdrRig, OptionalSdrPcmRx) = (None, None);
let histories = DecoderHistories::new();
+1
View File
@@ -147,6 +147,7 @@ impl DummyRig {
}
#[cfg(test)]
#[allow(clippy::items_after_test_module)]
mod tests {
use super::*;
use trx_core::rig::Rig;
@@ -154,7 +154,7 @@ fn fast_atan2(y: f32, x: f32) -> f32 {
}
}
let angle = if x > 0.0 {
if x > 0.0 {
fast_atan(y / x)
} else if x < 0.0 {
if y >= 0.0 {
@@ -164,8 +164,7 @@ fn fast_atan2(y: f32, x: f32) -> f32 {
}
} else {
0.0
};
angle
}
}
/// 7th-order minimax atan approximation for |z| ≤ 1.
@@ -1511,14 +1510,14 @@ mod tests {
let pilot_freq = 19_000.0_f32;
let carrier_freq = 38_000.0_f32;
let mut composite = vec![0.0_f32; num_samples];
for n in 0..num_samples {
for (n, sample) in composite.iter_mut().enumerate() {
let t = n as f32 / fs;
let audio = (TAU * audio_freq * t).sin(); // L = audio, R = 0
let sum = audio; // L + R
let diff = audio; // L - R
let pilot = 0.1 * (TAU * pilot_freq * t).cos();
let carrier = (TAU * carrier_freq * t).cos();
composite[n] = sum + pilot + diff * carrier;
*sample = sum + pilot + diff * carrier;
}
// --- FM-modulate composite → IQ samples ---
@@ -1613,7 +1612,7 @@ mod tests {
// Test both L-only (diff = +audio) and R-only (diff = -audio).
for (label, diff_sign) in [("L-only", 1.0_f32), ("R-only", -1.0_f32)] {
let mut composite = vec![0.0_f32; num_samples];
for n in 0..num_samples {
for (n, sample) in composite.iter_mut().enumerate() {
let t = n as f32 / fs;
let audio: f32 = freqs.iter().map(|&f| (TAU * f * t).sin()).sum::<f32>()
/ freqs.len() as f32;
@@ -1621,7 +1620,7 @@ mod tests {
let diff = audio * diff_sign; // L - R
let pilot = 0.1 * (TAU * pilot_freq * t).cos();
let carrier = (TAU * carrier_freq * t).cos();
composite[n] = sum + pilot + diff * carrier;
*sample = sum + pilot + diff * carrier;
}
let peak_composite = 2.1_f32;
@@ -1928,14 +1927,14 @@ mod tests {
let pilot_freq = 19_000.0_f32;
let carrier_freq = 38_000.0_f32;
let mut composite = vec![0.0_f32; num_samples];
for n in 0..num_samples {
for (n, sample) in composite.iter_mut().enumerate() {
let t = n as f32 / fs;
let audio = (TAU * audio_freq * t).sin();
let sum = audio;
let diff = audio;
let pilot = 0.1 * (TAU * pilot_freq * t).cos();
let carrier = (TAU * carrier_freq * t).cos();
composite[n] = sum + pilot + diff * carrier;
*sample = sum + pilot + diff * carrier;
}
let peak_composite = 2.1_f32;
@@ -178,16 +178,18 @@ pub struct BlockFirFilterPair {
scratch_freq: Vec<FftComplex<f32>>,
}
fn build_fir_kernel(
cutoff_norm: f32,
taps: usize,
block_size: usize,
) -> (
type FirKernel = (
Vec<FftComplex<f32>>,
usize,
Arc<dyn Fft<f32>>,
Arc<dyn Fft<f32>>,
) {
);
fn build_fir_kernel(
cutoff_norm: f32,
taps: usize,
block_size: usize,
) -> FirKernel {
let coeffs = windowed_sinc_coeffs(cutoff_norm, taps);
let fft_size = (block_size + taps - 1).next_power_of_two();
@@ -943,6 +945,7 @@ pub struct SdrPipeline {
}
impl SdrPipeline {
#[allow(clippy::too_many_arguments)]
pub fn start(
source: Box<dyn IqSource>,
sdr_sample_rate: u32,