chore: Fix extra spaces in api mod #351
Annotations
25 warnings
format
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|
iterating on a map's values:
src/bluez/peripheral.rs#L369
warning: iterating on a map's values
--> src/bluez/peripheral.rs:369:30
|
369 | characteristics: service
| ______________________________^
370 | | .characteristics
371 | | .iter()
372 | | .map(|(_, characteristic)| make_characteristic(characteristic, service.info.uuid))
| |__________________________________________________________________________________________________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map
= note: `#[warn(clippy::iter_kv_map)]` on by default
help: try
|
369 ~ characteristics: service
370 + .characteristics.values().map(|characteristic| make_characteristic(characteristic, service.info.uuid))
|
|
method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str`:
src/api/mod.rs#L64
warning: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str`
--> src/api/mod.rs:64:5
|
64 | / pub fn from_str(v: &str) -> Option<AddressType> {
65 | | match v {
66 | | "public" => Some(AddressType::Public),
67 | | "random" => Some(AddressType::Random),
68 | | _ => None,
69 | | }
70 | | }
| |_____^
|
= help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
= note: `#[warn(clippy::should_implement_trait)]` on by default
|
this `impl` can be derived:
src/api/mod.rs#L57
warning: this `impl` can be derived
--> src/api/mod.rs:57:1
|
57 | / impl Default for AddressType {
58 | | fn default() -> Self {
59 | | AddressType::Public
60 | | }
61 | | }
| |_^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
= note: `#[warn(clippy::derivable_impls)]` on by default
= help: remove the manual implementation...
help: ...and instead derive it...
|
52 + #[derive(Default)]
53 | pub enum AddressType {
|
help: ...and mark the default variant
|
54 ~ #[default]
55 ~ Public,
|
|
this expression borrows a value the compiler would automatically borrow:
src/api/bdaddr.rs#L109
warning: this expression borrows a value the compiler would automatically borrow
--> src/api/bdaddr.rs:109:9
|
109 | (&mut slice[2..]).copy_from_slice(&addr.into_inner());
| ^^^^^^^^^^^^^^^^^ help: change this to: `slice[2..]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
|
build (ubuntu-latest)
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2, actions-rs/clippy-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|
module `CentralDelegate` should have a snake case name:
src/corebluetooth/central_delegate.rs#L291
warning: module `CentralDelegate` should have a snake case name
--> src/corebluetooth/central_delegate.rs:291:9
|
291 | pub mod CentralDelegate {
| ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `central_delegate`
|
= note: `#[warn(non_snake_case)]` on by default
|
usage of `contains_key` followed by `insert` on a `HashMap`:
src/corebluetooth/internal.rs#L518
warning: usage of `contains_key` followed by `insert` on a `HashMap`
--> src/corebluetooth/internal.rs:518:9
|
518 | / if self.peripherals.contains_key(&uuid) {
519 | | if let Some(name) = name {
520 | | self.dispatch_event(CoreBluetoothEvent::DeviceUpdated { uuid, name })
521 | | .await;
... |
533 | | .await;
534 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_entry
= note: `#[warn(clippy::map_entry)]` on by default
help: try this
|
518 ~ if let std::collections::hash_map::Entry::Vacant(e) = self.peripherals.entry(uuid) {
519 + // Create our channels
520 + let (event_sender, event_receiver) = mpsc::channel(256);
521 + e.insert(CBPeripheral::new(peripheral, event_sender));
522 + self.dispatch_event(CoreBluetoothEvent::DeviceDiscovered {
523 + uuid,
524 + name,
525 + event_receiver,
526 + })
527 + .await;
528 + } else {
529 + if let Some(name) = name {
530 + self.dispatch_event(CoreBluetoothEvent::DeviceUpdated { uuid, name })
531 + .await;
532 + }
533 + }
|
|
this expression borrows a value the compiler would automatically borrow:
src/corebluetooth/central_delegate.rs#L394
warning: this expression borrows a value the compiler would automatically borrow
--> src/corebluetooth/central_delegate.rs:394:17
|
394 | (*(*(&*delegate).get_ivar::<*mut c_void>(DELEGATE_SENDER_IVAR)
| ^^^^^^^^^^^^ help: change this to: `(*delegate)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
|
use of `.unwrap_or_else(..)` to construct default value:
src/corebluetooth/central_delegate.rs#L382
warning: use of `.unwrap_or_else(..)` to construct default value
--> src/corebluetooth/central_delegate.rs:382:13
|
382 | nsstring_to_string(nsstring).unwrap_or_else(|| "".to_string())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `nsstring_to_string(nsstring).unwrap_or_default()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_else_default
= note: `#[warn(clippy::unwrap_or_else_default)]` on by default
|
this expression borrows a value the compiler would automatically borrow:
src/corebluetooth/central_delegate.rs#L314
warning: this expression borrows a value the compiler would automatically borrow
--> src/corebluetooth/central_delegate.rs:314:36
|
314 | let _ = Box::from_raw(*(&*delegate).get_ivar::<*mut c_void>(DELEGATE_SENDER_IVAR)
| ^^^^^^^^^^^^ help: change this to: `(*delegate)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
|
called `unwrap` on `x` after checking its variant with `is_ok`:
src/common/util.rs#L19
warning: called `unwrap` on `x` after checking its variant with `is_ok`
--> src/common/util.rs:19:18
|
18 | if x.is_ok() {
| ------------ help: try: `if let Ok(..) = x`
19 | Some(x.unwrap())
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
|
called `unwrap` on `x` after checking its variant with `is_ok`:
src/common/adapter_manager.rs#L63
warning: called `unwrap` on `x` after checking its variant with `is_ok`
--> src/common/adapter_manager.rs:63:22
|
62 | if x.is_ok() {
| ------------ help: try: `if let Ok(..) = x`
63 | Some(x.unwrap())
| ^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap
= note: `#[warn(clippy::unnecessary_unwrap)]` on by default
|
you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`:
src/common/adapter_manager.rs#L47
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
--> src/common/adapter_manager.rs:47:9
|
47 | / match event {
48 | | CentralEvent::DeviceDisconnected(ref id) => {
49 | | self.peripherals.remove(id);
50 | | }
51 | | _ => {}
52 | | }
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
= note: `#[warn(clippy::single_match)]` on by default
help: try this
|
47 ~ if let CentralEvent::DeviceDisconnected(ref id) = event {
48 + self.peripherals.remove(id);
49 + }
|
|
method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str`:
src/api/mod.rs#L64
warning: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str`
--> src/api/mod.rs:64:5
|
64 | / pub fn from_str(v: &str) -> Option<AddressType> {
65 | | match v {
66 | | "public" => Some(AddressType::Public),
67 | | "random" => Some(AddressType::Random),
68 | | _ => None,
69 | | }
70 | | }
| |_____^
|
= help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait
= note: `#[warn(clippy::should_implement_trait)]` on by default
|
this `impl` can be derived:
src/api/mod.rs#L57
warning: this `impl` can be derived
--> src/api/mod.rs:57:1
|
57 | / impl Default for AddressType {
58 | | fn default() -> Self {
59 | | AddressType::Public
60 | | }
61 | | }
| |_^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
= note: `#[warn(clippy::derivable_impls)]` on by default
= help: remove the manual implementation...
help: ...and instead derive it...
|
52 + #[derive(Default)]
53 | pub enum AddressType {
|
help: ...and mark the default variant
|
54 ~ #[default]
55 ~ Public,
|
|
this expression borrows a value the compiler would automatically borrow:
src/api/bdaddr.rs#L109
warning: this expression borrows a value the compiler would automatically borrow
--> src/api/bdaddr.rs:109:9
|
109 | (&mut slice[2..]).copy_from_slice(&addr.into_inner());
| ^^^^^^^^^^^^^^^^^ help: change this to: `slice[2..]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
|
constant `PERIPHERALSTATE_CONNECTED` is never used:
src/corebluetooth/framework.rs#L296
warning: constant `PERIPHERALSTATE_CONNECTED` is never used
--> src/corebluetooth/framework.rs:296:15
|
296 | pub const PERIPHERALSTATE_CONNECTED: c_int = 2; // CBPeripheralStateConnected
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
variants `Disonnected`, `Connecting`, `Connected`, and `Disconnecting` are never constructed:
src/corebluetooth/framework.rs#L204
warning: variants `Disonnected`, `Connecting`, `Connected`, and `Disconnecting` are never constructed
--> src/corebluetooth/framework.rs:204:9
|
203 | pub enum CBPeripheralState {
| ----------------- variants in this enum
204 | Disonnected = 0,
| ^^^^^^^^^^^
205 | Connecting = 1,
| ^^^^^^^^^^
206 | Connected = 2,
| ^^^^^^^^^
207 | Disconnecting = 3,
| ^^^^^^^^^^^^^
|
= note: `CBPeripheralState` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
|
variants `Restricted` and `Denied` are never constructed:
src/corebluetooth/framework.rs#L184
warning: variants `Restricted` and `Denied` are never constructed
--> src/corebluetooth/framework.rs:184:9
|
182 | pub enum CBManagerAuthorization {
| ---------------------- variants in this enum
183 | NotDetermined = 0,
184 | Restricted = 1,
| ^^^^^^^^^^
185 | Denied = 2,
| ^^^^^^
|
= note: `CBManagerAuthorization` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
|
unused variable: `descriptor`:
src/corebluetooth/internal.rs#L960
warning: unused variable: `descriptor`
--> src/corebluetooth/internal.rs:960:33
|
960 | if let Some(descriptor) = characteristic.descriptors.get_mut(&descriptor_uuid) {
| ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_descriptor`
|
= note: `#[warn(unused_variables)]` on by default
|
redundant field names in struct initialization:
src/corebluetooth/peripheral.rs#L169
warning: redundant field names in struct initialization
--> src/corebluetooth/peripheral.rs:169:16
|
169 | Self { shared: shared }
| ^^^^^^^^^^^^^^ help: replace it with: `shared`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
= note: `#[warn(clippy::redundant_field_names)]` on by default
|
unused import: `bleuuid::uuid_from_u16`:
src/corebluetooth/internal.rs#L25
warning: unused import: `bleuuid::uuid_from_u16`
--> src/corebluetooth/internal.rs:25:5
|
25 | bleuuid::uuid_from_u16, CharPropFlags, Characteristic, Descriptor, ScanFilter, Service,
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
|
build (macOS-latest)
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2, actions-rs/clippy-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|
build (windows-latest)
The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2, actions-rs/clippy-check@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|