Skip to content

Commit 16150a3

Browse files
authored
refactor(scripts): fix clippy errors (#49719)
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation or adding/fixing Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### Why? ### How? Closes NEXT- Fixes # --> ### What? Another fix, with adding scripts under next-swc check.
1 parent 4bc1bc3 commit 16150a3

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

scripts/run-for-change.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const CHANGE_ITEM_GROUPS = {
4141
'packages/next-swc',
4242
'scripts/normalize-version-bump.js',
4343
'test/integration/create-next-app',
44+
'scripts/send-trace-to-jaeger',
4445
],
4546
}
4647

scripts/send-trace-to-jaeger/src/main.rs

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ where
2121
fn log_web_url(jaeger_web_ui_url: &str, trace_id: &str) {
2222
println!(
2323
"Jaeger trace will be available on {}/trace/{}",
24-
jaeger_web_ui_url.to_string(),
25-
trace_id.to_string()
24+
jaeger_web_ui_url, trace_id
2625
)
2726
}
2827

@@ -69,39 +68,37 @@ fn main() {
6968
let first_arg = args().nth(1).expect("Please provide a file name");
7069

7170
if let Ok(lines) = read_lines(first_arg) {
72-
for line in lines {
73-
if let Ok(json_to_parse) = line {
74-
let v = match serde_json::from_str::<Vec<Value>>(&json_to_parse) {
75-
Ok(v) => v
76-
.into_iter()
77-
.map(|mut data| {
78-
if !logged_url {
79-
log_web_url(&jaeger_web_ui_url, &data["traceId"].as_str().unwrap());
80-
logged_url = true;
81-
}
82-
data["localEndpoint"] = Value::Object(local_endpoint.clone());
83-
84-
data["id"] = Value::String(pad_zeros(data["id"].as_u64().unwrap()));
85-
if data["parentId"] != Value::Null {
86-
data["parentId"] =
87-
Value::String(pad_zeros(data["parentId"].as_u64().unwrap()));
88-
}
89-
90-
data
91-
})
92-
.collect::<Value>(),
93-
Err(e) => {
94-
println!("{}", e);
95-
continue;
96-
}
97-
};
98-
99-
let json_map = serde_json::to_string(&v).expect("Failed to serialize");
100-
101-
// println!("{:}", json_map);
102-
103-
send_json_to_zipkin(&zipkin_api, json_map);
104-
}
71+
for json_to_parse in lines.flatten() {
72+
let v = match serde_json::from_str::<Vec<Value>>(&json_to_parse) {
73+
Ok(v) => v
74+
.into_iter()
75+
.map(|mut data| {
76+
if !logged_url {
77+
log_web_url(&jaeger_web_ui_url, data["traceId"].as_str().unwrap());
78+
logged_url = true;
79+
}
80+
data["localEndpoint"] = Value::Object(local_endpoint.clone());
81+
82+
data["id"] = Value::String(pad_zeros(data["id"].as_u64().unwrap()));
83+
if data["parentId"] != Value::Null {
84+
data["parentId"] =
85+
Value::String(pad_zeros(data["parentId"].as_u64().unwrap()));
86+
}
87+
88+
data
89+
})
90+
.collect::<Value>(),
91+
Err(e) => {
92+
println!("{}", e);
93+
continue;
94+
}
95+
};
96+
97+
let json_map = serde_json::to_string(&v).expect("Failed to serialize");
98+
99+
// println!("{:}", json_map);
100+
101+
send_json_to_zipkin(&zipkin_api, json_map);
105102
}
106103
}
107104
}

0 commit comments

Comments
 (0)