Skip to content

Commit 7687af8

Browse files
chore: make clippy lints blocking (#1820)
1 parent 45467e6 commit 7687af8

File tree

8 files changed

+33
-16
lines changed

8 files changed

+33
-16
lines changed

packages/core-bridge/bridge-macros/src/derive_js_function.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn js_function_impl(
1818
let args = &input.sig.inputs;
1919
let return_type = &input.sig.output; // Can we avoid in some cases?
2020
let fn_block = &input.block;
21+
let attrs = &input.attrs;
2122

2223
let fn_impl_name = format_ident!("{}_impl", fn_name);
2324

@@ -75,6 +76,7 @@ pub fn js_function_impl(
7576
}
7677

7778
// Implementation function
79+
#(#attrs)*
7880
#[allow(clippy::unnecessary_wraps)]
7981
#vis fn #fn_impl_name #generics() -> #result_return_type {
8082
#fn_block
@@ -95,6 +97,7 @@ pub fn js_function_impl(
9597
}
9698

9799
// Implementation function
100+
#(#attrs)*
98101
#[allow(clippy::unnecessary_wraps)]
99102
#vis fn #fn_impl_name #generics(#(#impl_args),*) -> #result_return_type {
100103
#fn_block

packages/core-bridge/src/client.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ macro_rules! rpc_call {
250250
}
251251

252252
// FIXME: "this function may allocate 1400106 bytes on the stack"
253+
#[allow(clippy::cognitive_complexity)]
254+
#[allow(clippy::large_stack_frames)]
253255
#[allow(clippy::too_many_lines)]
254256
async fn client_invoke_workflow_service(
255257
mut retry_client: CoreClient,
@@ -515,6 +517,7 @@ async fn client_invoke_workflow_service(
515517
}
516518
}
517519

520+
#[allow(clippy::cognitive_complexity)]
518521
async fn client_invoke_operator_service(
519522
mut retry_client: CoreClient,
520523
call: RpcCall,
@@ -638,7 +641,7 @@ where
638641
{
639642
match res {
640643
Ok(resp) => Ok(resp.get_ref().encode_to_vec()),
641-
Err(err) => Err(BridgeError::ServiceError(err)),
644+
Err(err) => Err(BridgeError::from(err)),
642645
}
643646
}
644647

@@ -752,6 +755,7 @@ mod config {
752755
}
753756
}
754757

758+
#[allow(clippy::type_complexity)]
755759
pub(super) fn partition_headers(
756760
headers: Option<HashMap<String, MetadataValue>>,
757761
) -> (

packages/core-bridge/src/helpers/callbacks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ where
223223

224224
impl<Args: TryIntoJsArgs + Send + Sync, Ret: TryFromJs + Send + Sync> CallbackInner<Args, Ret> {
225225
fn call<'a, C: Context<'a>>(&self, cx: &mut C, args: Args) -> BridgeResult<Ret> {
226-
let this: Handle<'a, JsValue> = self
227-
.this
228-
.as_ref()
229-
.map_or(cx.undefined().upcast(), |t| t.to_inner(cx).upcast());
226+
let this: Handle<'a, JsValue> = match self.this.as_ref() {
227+
Some(t) => t.to_inner(cx).upcast(),
228+
None => cx.undefined().upcast(),
229+
};
230230

231231
// Convert the arguments to a JS array using the new trait
232232
let js_args = args.try_into_js_args(cx)?;

packages/core-bridge/src/helpers/errors.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub enum BridgeError {
7575
///
7676
/// Becomes a JS `ServiceError` (adhering to the same interface as `grpc.ServiceError`).
7777
#[error(transparent)]
78-
ServiceError(#[from] tonic::Status),
78+
ServiceError(Box<tonic::Status>),
7979

8080
/// Generic wrapper for other errors.
8181
///
@@ -99,6 +99,12 @@ pub enum BridgeError {
9999
JsThrow { thrown: RefCell<Option<ThrowBox>> },
100100
}
101101

102+
impl From<tonic::Status> for BridgeError {
103+
fn from(value: tonic::Status) -> Self {
104+
Self::ServiceError(Box::new(value))
105+
}
106+
}
107+
102108
// Append Field Context ////////////////////////////////////////////////////////////////////////////
103109

104110
pub trait AppendFieldContext {

packages/core-bridge/src/helpers/handles.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use parking_lot::Mutex;
99

1010
use super::{BridgeError, BridgeResult, IntoThrow, TryFromJs, TryIntoJs};
1111

12+
#[allow(clippy::doc_overindented_list_items)]
1213
/// Opaque Handles are native structures that are sent into the JS side but without exposing
1314
/// their internal structure; i.e. they are only meant to be passed back to the Rust side
1415
/// on appropriate API calls.

packages/core-bridge/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(
1+
#![deny(
22
clippy::pedantic,
33
clippy::nursery,
44
clippy::cargo,
@@ -10,7 +10,8 @@
1010
clippy::too_long_first_doc_paragraph,
1111
clippy::option_if_let_else,
1212
clippy::multiple_crate_versions,
13-
clippy::significant_drop_tightening
13+
clippy::significant_drop_tightening,
14+
clippy::upper_case_acronyms
1415
)]
1516

1617
pub mod helpers;

packages/core-bridge/src/metrics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@ pub fn new_metric_gauge_f64(
235235
Ok(OpaqueOutboundHandle::new(GaugeF64 { meter, gauge }))
236236
}
237237

238+
// We do not need to worry about losing the sign of `value` as JS verifies this is positive
239+
// It is understood that if passing in a float to a counter the value will be truncated
238240
#[js_function]
241+
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
239242
pub fn add_metric_counter_value(
240243
counter_handle: OpaqueInboundHandle<Counter>,
241244
value: f64,

packages/core-bridge/src/worker.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ pub fn worker_complete_nexus_task(
296296
.complete_nexus_task(nexus_completion)
297297
.await
298298
.map_err(|err| match err {
299-
CompleteNexusError::NexusNotEnabled {} => {
299+
CompleteNexusError::NexusNotEnabled => {
300300
BridgeError::UnexpectedError(format!("{err}"))
301301
}
302302
CompleteNexusError::MalformedNexusCompletion { reason } => BridgeError::TypeError {
@@ -309,7 +309,7 @@ pub fn worker_complete_nexus_task(
309309

310310
/// Request shutdown of the worker.
311311
/// Once complete Core will stop polling on new tasks and activations on worker's task queue.
312-
/// Caller should drain any pending tasks and activations and call worker_finalize_shutdown before breaking from
312+
/// Caller should drain any pending tasks and activations and call `worker_finalize_shutdown` before breaking from
313313
/// the loop to ensure graceful shutdown.
314314
#[js_function]
315315
pub fn worker_initiate_shutdown(worker: OpaqueInboundHandle<Worker>) -> BridgeResult<()> {
@@ -817,7 +817,6 @@ mod custom_slot_supplier {
817817
Err(err) => {
818818
warn!("Error reserving slot: {err:?}");
819819
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
820-
continue;
821820
}
822821
}
823822
}
@@ -941,18 +940,18 @@ mod custom_slot_supplier {
941940
fn from(info: &'a CoreSlotInfo<'a>) -> Self {
942941
match info {
943942
CoreSlotInfo::Workflow(info) => Self::Workflow {
944-
workflow_type: info.workflow_type.to_string(),
943+
workflow_type: info.workflow_type.clone(),
945944
is_sticky: info.is_sticky,
946945
},
947946
CoreSlotInfo::Activity(info) => Self::Activity {
948-
activity_type: info.activity_type.to_string(),
947+
activity_type: info.activity_type.clone(),
949948
},
950949
CoreSlotInfo::LocalActivity(info) => Self::LocalActivity {
951-
activity_type: info.activity_type.to_string(),
950+
activity_type: info.activity_type.clone(),
952951
},
953952
CoreSlotInfo::Nexus(info) => Self::Nexus {
954-
service: info.service.to_string(),
955-
operation: info.operation.to_string(),
953+
service: info.service.clone(),
954+
operation: info.operation.clone(),
956955
},
957956
}
958957
}

0 commit comments

Comments
 (0)