Skip to content

Commit bebe362

Browse files
committed
fix(ci): resolve clippy errors and improve lint configuration
Two main issues were fixed: 1. Toolchain mismatch: When multiple Rust toolchains are installed in the same job, the last one becomes default. Fixed by explicitly using +stable for clippy and doc commands to match the existing +nightly for rustfmt. 2. Clippy lint configuration: RUSTFLAGS="-D warnings" was overriding workspace lint allows. Changed approach to use workspace lints with "deny" level instead of command-line -D warnings, allowing proper prioritization of allows. Changes: - CI workflow: Added +stable prefix to clippy/doc, removed -D warnings - Cargo.toml: Changed clippy lints to "deny" level, added priority allows for overly strict lints (multiple_crate_versions, cargo_common_metadata) - Code fixes: Removed 11 instances of needless borrows (needless_borrows_for_generic_args) All clippy checks now pass with proper workspace lint inheritance.
1 parent 761d44b commit bebe362

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
CARGO_INCREMENTAL: 0
1515
CARGO_NET_RETRY: 10
1616
RUST_BACKTRACE: short
17-
RUSTFLAGS: "-D warnings"
17+
# Don't use RUSTFLAGS=-D warnings, use workspace lints configuration instead
1818
RUSTUP_MAX_RETRIES: 10
1919

2020
# Cancel previous runs on new push
@@ -51,7 +51,7 @@ jobs:
5151
run: cargo +nightly fmt --all -- --check
5252

5353
- name: Clippy (all targets, all features)
54-
run: cargo +stable clippy --all-targets --all-features --workspace -- -D warnings
54+
run: cargo +stable clippy --all-targets --all-features --workspace
5555

5656
- name: Check documentation
5757
run: cargo +stable doc --no-deps --all-features --workspace

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ criterion = "0.7"
103103

104104
[workspace.lints.rust]
105105
missing_debug_implementations = "warn"
106-
unsafe_op_in_unsafe_fn = "warn"
106+
unsafe_op_in_unsafe_fn = "deny"
107107
unused_lifetimes = "warn"
108108

109109
[workspace.lints.clippy]
110-
all = { level = "warn", priority = -1 }
111-
pedantic = { level = "warn", priority = -1 }
112-
cargo = { level = "warn", priority = -1 }
113-
nursery = { level = "warn", priority = -1 }
110+
# Deny all clippy warnings to fail CI
111+
all = { level = "deny", priority = -1 }
112+
pedantic = { level = "deny", priority = -1 }
113+
cargo = { level = "deny", priority = -1 }
114+
nursery = { level = "deny", priority = -1 }
114115

115116
# Allow specific lints that are too strict or have false positives
116-
needless-borrows-for-generic-args = "allow"
117-
multiple-crate-versions = "allow" # Common with transitive dependencies
117+
needless_borrows_for_generic_args = { level = "allow", priority = 1 }
118+
multiple_crate_versions = { level = "allow", priority = 1 } # Common with transitive dependencies
119+
cargo_common_metadata = { level = "allow", priority = 1 } # Not required for internal workspace crates
118120

119121
[profile.release]
120122
opt-level = 3

crates/mcp-codegen/benches/code_generation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::hint::black_box;
2222
/// Creates a simple tool with minimal schema.
2323
fn create_simple_tool(index: usize) -> ToolInfo {
2424
ToolInfo {
25-
name: ToolName::new(&format!("simple_tool_{}", index)),
25+
name: ToolName::new(format!("simple_tool_{}", index)),
2626
description: format!("Simple tool {}", index),
2727
input_schema: json!({
2828
"type": "object",
@@ -38,7 +38,7 @@ fn create_simple_tool(index: usize) -> ToolInfo {
3838
/// Creates a tool with moderate schema complexity.
3939
fn create_moderate_tool(index: usize) -> ToolInfo {
4040
ToolInfo {
41-
name: ToolName::new(&format!("moderate_tool_{}", index)),
41+
name: ToolName::new(format!("moderate_tool_{}", index)),
4242
description: format!("Moderate complexity tool {}", index),
4343
input_schema: json!({
4444
"type": "object",
@@ -67,7 +67,7 @@ fn create_moderate_tool(index: usize) -> ToolInfo {
6767
/// Creates a tool with complex nested schema.
6868
fn create_complex_tool(index: usize) -> ToolInfo {
6969
ToolInfo {
70-
name: ToolName::new(&format!("complex_tool_{}", index)),
70+
name: ToolName::new(format!("complex_tool_{}", index)),
7171
description: format!("Complex nested tool {}", index),
7272
input_schema: json!({
7373
"type": "object",
@@ -141,7 +141,7 @@ fn create_server_info(tool_count: usize, tool_creator: fn(usize) -> ToolInfo) ->
141141
let tools: Vec<_> = (0..tool_count).map(tool_creator).collect();
142142

143143
ServerInfo {
144-
id: ServerId::new(&format!("bench-server-{}", tool_count)),
144+
id: ServerId::new(format!("bench-server-{}", tool_count)),
145145
name: format!("Benchmark Server (n={})", tool_count),
146146
version: "1.0.0".to_string(),
147147
tools,

crates/mcp-codegen/examples/profile_generation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use serde_json::json;
1111

1212
fn create_moderate_tool(index: usize) -> ToolInfo {
1313
ToolInfo {
14-
name: ToolName::new(&format!("tool_{}", index)),
14+
name: ToolName::new(format!("tool_{}", index)),
1515
description: format!("Tool {}", index),
1616
input_schema: json!({
1717
"type": "object",

crates/mcp-codegen/tests/integration_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn test_complete_generation_workflow_vkteams() {
197197
.read_file("/mcp-tools/servers/vkteams-bot/manifest.json")
198198
.expect("Should read manifest");
199199
let manifest: serde_json::Value =
200-
serde_json::from_str(&manifest_content).expect("Manifest should be valid JSON");
200+
serde_json::from_str(manifest_content).expect("Manifest should be valid JSON");
201201

202202
assert_eq!(manifest["name"], "VK Teams Bot");
203203
assert_eq!(manifest["version"], "2.1.0");
@@ -247,7 +247,7 @@ fn test_empty_server_generation() {
247247
let manifest_content = vfs
248248
.read_file("/mcp-tools/servers/empty/manifest.json")
249249
.unwrap();
250-
let manifest: serde_json::Value = serde_json::from_str(&manifest_content).unwrap();
250+
let manifest: serde_json::Value = serde_json::from_str(manifest_content).unwrap();
251251
assert_eq!(manifest["tools"].as_array().unwrap().len(), 0);
252252
}
253253

@@ -446,7 +446,7 @@ fn test_performance_large_server() {
446446
let mut tools = Vec::new();
447447
for i in 0..50 {
448448
tools.push(ToolInfo {
449-
name: ToolName::new(&format!("tool_{}", i)),
449+
name: ToolName::new(format!("tool_{}", i)),
450450
description: format!("Tool number {}", i),
451451
input_schema: json!({
452452
"type": "object",

crates/mcp-examples/benches/e2e_benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn bench_scaling_with_tools(c: &mut Criterion) {
117117
for num_tools in [1, 5, 10, 20, 50].iter() {
118118
let tools: Vec<ToolInfo> = (0..*num_tools)
119119
.map(|i| ToolInfo {
120-
name: ToolName::new(&format!("tool_{}", i)),
120+
name: ToolName::new(format!("tool_{}", i)),
121121
description: format!("Tool number {}", i),
122122
input_schema: json!({"type": "object"}),
123123
output_schema: None,

crates/mcp-examples/src/token_analysis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ mod tests {
293293
fn create_test_server(num_tools: usize) -> ServerInfo {
294294
let tools: Vec<ToolInfo> = (0..num_tools)
295295
.map(|i| ToolInfo {
296-
name: ToolName::new(&format!("tool_{}", i)),
296+
name: ToolName::new(format!("tool_{}", i)),
297297
description: format!("Tool {}", i),
298298
input_schema: json!({"type": "object"}),
299299
output_schema: None,

crates/mcp-examples/tests/integration_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn test_codegen_to_vfs() {
144144
let vfs = result.unwrap();
145145

146146
// Verify files are accessible
147-
assert!(vfs.exists(&format!("{}/manifest.json", vfs_root)));
147+
assert!(vfs.exists(format!("{}/manifest.json", vfs_root)));
148148
}
149149

150150
#[test]

0 commit comments

Comments
 (0)