Skip to content

Commit 1e546fd

Browse files
committed
ref: applied clippy fix
1 parent f2b5747 commit 1e546fd

6 files changed

Lines changed: 45 additions & 26 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,16 @@ jobs:
8383
needs: build
8484
runs-on: ubuntu-latest
8585
steps:
86+
- name: Cache cargo registry
87+
uses: actions/cache@v4
88+
with:
89+
path: |
90+
~/.cargo/registry
91+
~/.cargo/git
92+
target
93+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
94+
restore-keys: |
95+
${{ runner.os }}-cargo-
96+
8697
- name: Run Tests
87-
run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo test
88-
env:
89-
RUST_BACKTRACE: 'full'
98+
run: cargo test --verbose --all-features

crates/base/src/config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ impl AdapterConfig {
6262
let nats_bucket =
6363
code0_flow::flow_config::env_with_default("NATS_BUCKET", String::from("flow_store"));
6464
let grpc_port = code0_flow::flow_config::env_with_default("GRPC_PORT", 50051);
65-
let grpc_host = code0_flow::flow_config::env_with_default("GRPC_HOST", String::from("localhost"));
65+
let grpc_host =
66+
code0_flow::flow_config::env_with_default("GRPC_HOST", String::from("localhost"));
6667
let aquila_url = code0_flow::flow_config::env_with_default(
6768
"AQUILA_URL",
6869
String::from("grpc://localhost:50051"),
@@ -75,7 +76,8 @@ impl AdapterConfig {
7576
"DEFINITION_PATH",
7677
String::from("./definition.yaml"),
7778
);
78-
let with_health_service = code0_flow::flow_config::env_with_default("WITH_HEALTH_SERVICE", false);
79+
let with_health_service =
80+
code0_flow::flow_config::env_with_default("WITH_HEALTH_SERVICE", false);
7981

8082
Self {
8183
environment,

crates/base/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ pub fn extract_flow_setting_field(
1717

1818
let obj = setting.object.as_ref()?;
1919
obj.fields.iter().find_map(|(k, v)| {
20-
if k == field_name {
21-
if let Some(Kind::StringValue(s)) = &v.kind {
22-
return Some(s.clone());
23-
}
20+
if k == field_name
21+
&& let Some(Kind::StringValue(s)) = &v.kind
22+
{
23+
return Some(s.clone());
2424
}
2525
None
2626
})

crates/base/src/runner.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ impl<C: LoadConfig> ServerRunner<C> {
7373
.await;
7474
});
7575

76-
log::info!("Health server started at {}:{}", config.grpc_host, config.grpc_port);
76+
log::info!(
77+
"Health server started at {}:{}",
78+
config.grpc_host,
79+
config.grpc_port
80+
);
7781
}
7882

7983
self.server.init(&self.context).await?;

crates/base/src/store.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::traits::IdentifiableFlow;
22
use async_nats::jetstream::kv::Config;
3+
use code0_flow::flow_validator::verify_flow;
34
use futures_lite::StreamExt;
45
use prost::Message;
56
use tucana::shared::{ExecutionFlow, ValidationFlow, Value};
6-
use code0_flow::flow_validator::verify_flow;
77

88
pub struct AdapterStore {
99
client: async_nats::Client,
@@ -30,10 +30,11 @@ impl AdapterStore {
3030
bucket: bucket.clone(),
3131
..Default::default()
3232
})
33-
.await {
33+
.await
34+
{
3435
Ok(_) => {
3536
log::info!("Successfully created NATS bucket");
36-
},
37+
}
3738
Err(err) => panic!("Failed to create NATS bucket: {:?}", err),
3839
}
3940

@@ -79,17 +80,16 @@ impl AdapterStore {
7980
};
8081

8182
while let Ok(Some(key)) = keys.try_next().await {
82-
8383
if !Self::is_matching_key(&pattern, &key) {
8484
continue;
8585
}
8686

8787
if let Ok(Some(bytes)) = self.kv.get(key).await {
8888
let decoded_flow = ValidationFlow::decode(bytes);
89-
if let Ok(flow) = decoded_flow {
90-
if id.identify(&flow) {
91-
collector.push(flow);
92-
}
89+
if let Ok(flow) = decoded_flow
90+
&& id.identify(&flow)
91+
{
92+
collector.push(flow.clone());
9393
};
9494
}
9595
}
@@ -132,9 +132,7 @@ impl AdapterStore {
132132

133133
match result {
134134
Ok(message) => match Value::decode(message.payload) {
135-
Ok(value) => {
136-
Some(value)
137-
}
135+
Ok(value) => Some(value),
138136
Err(err) => {
139137
log::error!("Failed to decode response from NATS server: {:?}", err);
140138
None
@@ -151,7 +149,7 @@ impl AdapterStore {
151149
ExecutionFlow {
152150
flow_id: flow.flow_id,
153151
starting_node: flow.starting_node,
154-
input_value: input_value,
152+
input_value,
155153
}
156154
}
157155

crates/http/src/request.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ pub struct HeaderMap {
4646
pub fields: HashMap<String, String>,
4747
}
4848

49+
impl Default for HeaderMap {
50+
fn default() -> Self {
51+
Self::new()
52+
}
53+
}
54+
4955
impl HeaderMap {
5056
pub fn new() -> Self {
5157
HeaderMap {
@@ -228,10 +234,10 @@ fn parse_request(
228234
};
229235

230236
let mut body = vec![0; size];
231-
if let Ok(_) = buf_reader.read_exact(&mut body) {
232-
if let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body) {
233-
body_values.insert("body".to_string(), from_json_value(json_value));
234-
}
237+
if buf_reader.read_exact(&mut body).is_ok()
238+
&& let Ok(json_value) = serde_json::from_slice::<serde_json::Value>(&body)
239+
{
240+
body_values.insert("body".to_string(), from_json_value(json_value));
235241
}
236242
};
237243

0 commit comments

Comments
 (0)