diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..7abadbc --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,38 @@ +name: Rust + +on: + push: + branches: + - main + pull_request: +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + name: stable / fmt + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - name: Run cargo fmt + run: cargo fmt -- --check + - name: Cache Cargo dependencies + uses: Swatinem/rust-cache@v2 + clippy_check: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - name: Install Rust stable with Clippy + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - name: Run Clippy + run: cargo clippy --all-features -- -D warnings diff --git a/src/main.rs b/src/main.rs index b16a61f..40f0e75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -162,7 +162,7 @@ fn main() { let path = file.path().clone(); let path = path.to_str().unwrap(); if path.ends_with(".wav") { - options.push(format!("{}", path)); + options.push(path.into()); } } if options.is_empty() { diff --git a/src/playback.rs b/src/playback.rs index 6154d31..21dfdf6 100644 --- a/src/playback.rs +++ b/src/playback.rs @@ -104,7 +104,7 @@ pub fn play_audio(file_path: &str, device: &str, jack: bool) -> Result<()> { }; let sample = sample / (1 << 23) as f32; let channel = sample_count % num_channels; - file_data[channel].push(sample as f32); + file_data[channel].push(sample); sample_count += 1; } } @@ -344,7 +344,7 @@ pub fn play_audio(file_path: &str, device: &str, jack: bool) -> Result<()> { ); f.render_widget(chart, chunks[1]); let label = Span::styled( - format!("press ENTER to exit tui and stop playback."), + "press ENTER to exit tui and stop playback.", Style::default() .fg(Color::Yellow) .add_modifier(Modifier::ITALIC | Modifier::BOLD), diff --git a/src/record.rs b/src/record.rs index 7b4841d..bff9ffd 100644 --- a/src/record.rs +++ b/src/record.rs @@ -61,11 +61,8 @@ fn record_tui( let duration = now.duration_since(start_time); let recording_time = format!("Recording Time: {:.2}s", duration.as_secs_f32()); - match *recording_state.lock() { - RecordingState::Recording => { - draw_rec_waveform(&mut terminal, shared_waveform_data.clone(), recording_time)?; - } - _ => {} + if let RecordingState::Recording = *recording_state.lock() { + draw_rec_waveform(&mut terminal, shared_waveform_data.clone(), recording_time)?; } if event::poll(refresh_interval)? { @@ -135,7 +132,7 @@ fn draw_rec_waveform( f.render_widget(time_paragraph, chunks[0]); let label = Span::styled( - format!("press ENTER to exit tui and finish recording..."), + "press ENTER to exit tui and finish recording...", Style::default() .fg(Color::Yellow) .add_modifier(Modifier::ITALIC | Modifier::BOLD),