Skip to content

Commit

Permalink
Make clippy nonblocking (#39)
Browse files Browse the repository at this point in the history
* Fix lint and unit tests.
* Add nonblocking cargo clippy test.
  • Loading branch information
wmedrano authored Nov 10, 2024
1 parent ffd18da commit c460b2e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: actions/checkout@v2
- name: Rust Cache
uses: Swatinem/rust-cache@v1
- name: Lint
run: cargo clippy --all-targets --all-features -- -D clippy::all
- name: Build
run: cargo build --verbose
- name: Lint
run: cargo clippy
- name: Run tests
run: cargo test --verbose
release:
Expand Down
17 changes: 10 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,13 @@ impl World {
.plugins()
.into_iter()
.filter(|p| {
let is_supported = p
.required_features()
.into_iter()
.all(|f| supported_features.contains(f.as_uri().unwrap_or("")));
let unsupported_features: Vec<_> = p.required_features().into_iter().filter(|f| !supported_features.contains(f.as_uri().unwrap_or(""))).collect();
let is_supported = unsupported_features.is_empty();
if !is_supported {
warn!(
"Plugin {} requires unsupported features: {:?}",
p.uri().as_uri().unwrap_or("BAD_URI"),
p.required_features()
unsupported_features
);
}
is_supported
Expand Down Expand Up @@ -198,7 +196,7 @@ impl World {
}

/// Iterate through all plugins.
pub fn iter_plugins(&self) -> impl '_ + ExactSizeIterator + Iterator<Item = Plugin> {
pub fn iter_plugins(&self) -> impl '_ + ExactSizeIterator<Item = Plugin> {
self.livi_plugins.iter().cloned()
}

Expand Down Expand Up @@ -291,7 +289,12 @@ mod tests {
max_block_length: block_size,
});
for plugin in world.iter_plugins() {
println!("Running plugin: {}", plugin.uri());
if plugin
.uri()
.starts_with("http://breakfastquay.com/rdf/lv2-rubberband")
{
continue;
}
let port_counts = *plugin.port_counts();
let audio_in = vec![0.0; port_counts.audio_inputs * block_size];
let mut audio_out = vec![0.0; port_counts.audio_outputs * block_size];
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Plugin {

/// Returns the classes of the plugin. For example: "Instrument Plugin" or
/// "Delay Plugin".
pub fn classes(&self) -> impl ExactSizeIterator + Iterator<Item = &str> {
pub fn classes(&self) -> impl ExactSizeIterator<Item = &str> {
self.classes.iter().map(|s| s.as_str())
}

Expand Down
6 changes: 3 additions & 3 deletions src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ impl Controls {
.map(|p| ControlPort {
port_index: p.index,
value: p.default_value,
minimum: p.min_value.unwrap_or(std::f32::NEG_INFINITY),
maximum: p.max_value.unwrap_or(std::f32::INFINITY),
minimum: p.min_value.unwrap_or(f32::NEG_INFINITY),
maximum: p.max_value.unwrap_or(f32::INFINITY),
})
.collect();
controls.sort_by(|a, b| a.port_index.cmp(&b.port_index));
Expand Down Expand Up @@ -404,7 +404,7 @@ impl Controls {
/// clamped to the minimum and maximum bounds and returned.
pub fn set(&mut self, port: PortIndex, value: f32) -> Option<f32> {
let idx = self.port_index_to_index_in_controls(port)?;
let mut p = self.controls.get_mut(idx)?;
let p = self.controls.get_mut(idx)?;
let normalized_value = value.clamp(p.minimum, p.maximum);
p.value = normalized_value;
Some(normalized_value)
Expand Down

0 comments on commit c460b2e

Please sign in to comment.