Skip to content

Commit feeed9a

Browse files
0xrinegadeclaude
andcommitted
chore: Fix all clippy warnings and format code
Comprehensive cleanup of clippy warnings and code formatting across the entire codebase. All production code (lib + bins) now compiles with zero warnings. ## Main Codebase Improvements - Replace manual range checks with idiomatic .contains() - Use .ok_or() instead of unnecessary closures - Remove needless reference operators in comparisons - Modernize map_or patterns to .is_some_and() - Replace .get(0) with more idiomatic .first() - Improve loop patterns with direct iteration - Use .strip_prefix() instead of manual string slicing - Add type aliases for complex nested types - Use struct update syntax for field initialization - Change &PathBuf to &Path in function parameters - Fix logic bug with #[allow] attribute for disabled code - Add missing imports (serde_json::json, std::path::Path) - Remove empty lines after outer attributes ## Test Code Improvements - Update deprecated assert_cmd::Command::cargo_bin usage - Replace useless .as_ref() calls with direct dereference - Clean up unused imports in test files - Add #[allow(deprecated)] where needed for compatibility - Format all test code to rustfmt standards ## Files Modified - 8 stdlib files in crates/ovsm/src/tools/stdlib/ - 1 core OVSM evaluator (lisp_evaluator.rs) - 10 main service files - 3 command handlers - 14 test files - 1 example file ## Results ✅ Library + Binary: 0 warnings ✅ Release Build: 0 warnings ✅ All Tests: 457 passed ✅ Formatting: 100% compliant 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 43a308e commit feeed9a

36 files changed

+251
-206
lines changed

crates/ovsm/src/runtime/lisp_evaluator.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ impl LispEvaluator {
211211
"sqrt" => self.eval_sqrt(args),
212212
"pow" => self.eval_pow(args),
213213
"expt" => self.eval_pow(args), // Common Lisp alias for pow
214-
"exp" => self.eval_exp(args), // e^x
215-
"ln" => self.eval_ln(args), // Natural logarithm
214+
"exp" => self.eval_exp(args), // e^x
215+
"ln" => self.eval_ln(args), // Natural logarithm
216216
"abs" => self.eval_abs(args),
217217
// Common Lisp arithmetic shortcuts
218218
"1+" => self.eval_1_plus(args),
@@ -2316,7 +2316,7 @@ impl LispEvaluator {
23162316
}
23172317
};
23182318

2319-
if num < -1.0 || num > 1.0 {
2319+
if !(-1.0..=1.0).contains(&num) {
23202320
return Err(Error::InvalidArguments {
23212321
tool: "asin".to_string(),
23222322
reason: format!("Input must be in range [-1, 1], got {}", num),
@@ -2347,7 +2347,7 @@ impl LispEvaluator {
23472347
}
23482348
};
23492349

2350-
if num < -1.0 || num > 1.0 {
2350+
if !(-1.0..=1.0).contains(&num) {
23512351
return Err(Error::InvalidArguments {
23522352
tool: "acos".to_string(),
23532353
reason: format!("Input must be in range [-1, 1], got {}", num),
@@ -3199,7 +3199,10 @@ impl LispEvaluator {
31993199
if params.len() != 1 {
32003200
return Err(Error::InvalidArguments {
32013201
tool: "mapcar".to_string(),
3202-
reason: format!("Lambda must take exactly 1 parameter, got {}", params.len()),
3202+
reason: format!(
3203+
"Lambda must take exactly 1 parameter, got {}",
3204+
params.len()
3205+
),
32033206
});
32043207
}
32053208

@@ -3238,7 +3241,10 @@ impl LispEvaluator {
32383241
if params.len() != 1 {
32393242
return Err(Error::InvalidArguments {
32403243
tool: "mapc".to_string(),
3241-
reason: format!("Lambda must take exactly 1 parameter, got {}", params.len()),
3244+
reason: format!(
3245+
"Lambda must take exactly 1 parameter, got {}",
3246+
params.len()
3247+
),
32423248
});
32433249
}
32443250

@@ -3279,7 +3285,10 @@ impl LispEvaluator {
32793285
if params.len() != 1 {
32803286
return Err(Error::InvalidArguments {
32813287
tool: "remove-if".to_string(),
3282-
reason: format!("Lambda must take exactly 1 parameter, got {}", params.len()),
3288+
reason: format!(
3289+
"Lambda must take exactly 1 parameter, got {}",
3290+
params.len()
3291+
),
32833292
});
32843293
}
32853294

@@ -3321,7 +3330,10 @@ impl LispEvaluator {
33213330
if params.len() != 1 {
33223331
return Err(Error::InvalidArguments {
33233332
tool: "remove-if-not".to_string(),
3324-
reason: format!("Lambda must take exactly 1 parameter, got {}", params.len()),
3333+
reason: format!(
3334+
"Lambda must take exactly 1 parameter, got {}",
3335+
params.len()
3336+
),
33253337
});
33263338
}
33273339

crates/ovsm/src/tools/stdlib/arrays.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,10 @@ impl Tool for ArefTool {
155155
let array = args[0].as_array()?;
156156
let index = args[1].as_int()? as usize;
157157

158-
array
159-
.get(index)
160-
.cloned()
161-
.ok_or_else(|| Error::IndexOutOfBounds {
162-
index,
163-
length: array.len(),
164-
})
158+
array.get(index).cloned().ok_or(Error::IndexOutOfBounds {
159+
index,
160+
length: array.len(),
161+
})
165162
}
166163
}
167164

crates/ovsm/src/tools/stdlib/lists_advanced.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl Tool for TailpTool {
216216
}
217217

218218
let offset = list.len() - sublist.len();
219-
Ok(Value::Bool(&list[offset..] == &sublist[..]))
219+
Ok(Value::Bool(list[offset..] == sublist[..]))
220220
}
221221
}
222222

@@ -313,7 +313,7 @@ impl Tool for TreeEqualTool {
313313
obj1.len() == obj2.len()
314314
&& obj1
315315
.iter()
316-
.all(|(k, v1)| obj2.get(k).map_or(false, |v2| deep_equal(v1, v2)))
316+
.all(|(k, v1)| obj2.get(k).is_some_and(|v2| deep_equal(v1, v2)))
317317
}
318318
(a, b) => a == b,
319319
}

crates/ovsm/src/tools/stdlib/multiple_values.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl Tool for ValuesCountTool {
189189
"Get number of values returned"
190190
}
191191
fn execute(&self, args: &[Value]) -> Result<Value> {
192-
let count = match args.get(0) {
192+
let count = match args.first() {
193193
Some(Value::Array(arr)) => arr.len(),
194194
Some(_) => 1,
195195
None => 0,
@@ -208,7 +208,7 @@ impl Tool for ExtractPrimaryValueTool {
208208
"Extract only primary value, discard rest"
209209
}
210210
fn execute(&self, args: &[Value]) -> Result<Value> {
211-
match args.get(0) {
211+
match args.first() {
212212
Some(Value::Array(arr)) => Ok(arr.first().cloned().unwrap_or(Value::Null)),
213213
Some(v) => Ok(v.clone()),
214214
None => Ok(Value::Null),
@@ -311,7 +311,7 @@ impl Tool for GetPropertiesTool {
311311
Ok(Value::Array(Arc::new(vec![
312312
Value::Null,
313313
Value::Null,
314-
args.get(0).cloned().unwrap_or(Value::Null),
314+
args.first().cloned().unwrap_or(Value::Null),
315315
])))
316316
}
317317
}
@@ -332,11 +332,11 @@ impl Tool for GetSetfExpansionTool {
332332
fn execute(&self, args: &[Value]) -> Result<Value> {
333333
// Return 5 values: vars, vals, stores, writer, reader
334334
Ok(Value::Array(Arc::new(vec![
335-
Value::Array(Arc::new(vec![])), // vars
336-
Value::Array(Arc::new(vec![])), // vals
337-
Value::Array(Arc::new(vec![])), // stores
338-
args.get(0).cloned().unwrap_or(Value::Null), // writer
339-
args.get(0).cloned().unwrap_or(Value::Null), // reader
335+
Value::Array(Arc::new(vec![])), // vars
336+
Value::Array(Arc::new(vec![])), // vals
337+
Value::Array(Arc::new(vec![])), // stores
338+
args.first().cloned().unwrap_or(Value::Null), // writer
339+
args.first().cloned().unwrap_or(Value::Null), // reader
340340
])))
341341
}
342342
}

crates/ovsm/src/tools/stdlib/packages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl Tool for DescribePackageTool {
531531
"Describe package structure and contents"
532532
}
533533
fn execute(&self, args: &[Value]) -> Result<Value> {
534-
match args.get(0) {
534+
match args.first() {
535535
Some(Value::String(name)) => Ok(Value::String(format!(
536536
"Package: {}\nNicknames: none\nUse list: (COMMON-LISP)\nUsed by: none\nSymbols: 0",
537537
name

crates/ovsm/src/tools/stdlib/sequences.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl Tool for EltTool {
129129
chars
130130
.get(index)
131131
.map(|c| Value::String(c.to_string()))
132-
.ok_or_else(|| Error::IndexOutOfBounds {
132+
.ok_or(Error::IndexOutOfBounds {
133133
index,
134134
length: chars.len(),
135135
})
@@ -827,7 +827,7 @@ impl Tool for UnionTool {
827827
let list1 = args[0].as_array()?;
828828
let list2 = args[1].as_array()?;
829829

830-
let mut result: Vec<Value> = list1.iter().cloned().collect();
830+
let mut result: Vec<Value> = list1.to_vec();
831831

832832
for elem in list2.iter() {
833833
if !result.contains(elem) {

crates/ovsm/src/tools/stdlib/symbols_extended.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl Tool for GensymTool {
9393
"Generate unique uninterned symbol"
9494
}
9595
fn execute(&self, args: &[Value]) -> Result<Value> {
96-
let prefix = match args.get(0) {
96+
let prefix = match args.first() {
9797
Some(Value::String(s)) => s.clone(),
9898
_ => "G".to_string(),
9999
};
@@ -115,7 +115,7 @@ impl Tool for GentempTool {
115115
"Generate unique interned symbol"
116116
}
117117
fn execute(&self, args: &[Value]) -> Result<Value> {
118-
let prefix = match args.get(0) {
118+
let prefix = match args.first() {
119119
Some(Value::String(s)) => s.clone(),
120120
_ => "T".to_string(),
121121
};
@@ -140,7 +140,7 @@ impl Tool for SymbolNameTool {
140140
"Get symbol name as string"
141141
}
142142
fn execute(&self, args: &[Value]) -> Result<Value> {
143-
match args.get(0) {
143+
match args.first() {
144144
Some(Value::String(s)) => Ok(Value::String(s.clone())),
145145
_ => Ok(Value::String("UNKNOWN".to_string())),
146146
}
@@ -194,7 +194,7 @@ impl Tool for SymbolpTool {
194194
"Check if object is a symbol"
195195
}
196196
fn execute(&self, args: &[Value]) -> Result<Value> {
197-
match args.get(0) {
197+
match args.first() {
198198
Some(Value::String(_)) => Ok(Value::Bool(true)),
199199
_ => Ok(Value::Bool(false)),
200200
}
@@ -211,7 +211,7 @@ impl Tool for KeywordpTool {
211211
"Check if symbol is a keyword"
212212
}
213213
fn execute(&self, args: &[Value]) -> Result<Value> {
214-
match args.get(0) {
214+
match args.first() {
215215
Some(Value::String(s)) => Ok(Value::Bool(s.starts_with(':'))),
216216
_ => Ok(Value::Bool(false)),
217217
}
@@ -242,7 +242,7 @@ impl Tool for ConstantSymbolPTool {
242242
"Check if symbol is a constant"
243243
}
244244
fn execute(&self, args: &[Value]) -> Result<Value> {
245-
match args.get(0) {
245+
match args.first() {
246246
Some(Value::String(s)) => {
247247
// Keywords and T, NIL are constants
248248
Ok(Value::Bool(s.starts_with(':') || s == "T" || s == "NIL"))
@@ -306,7 +306,7 @@ impl Tool for MakeKeywordTool {
306306
"Convert symbol to keyword"
307307
}
308308
fn execute(&self, args: &[Value]) -> Result<Value> {
309-
match args.get(0) {
309+
match args.first() {
310310
Some(Value::String(s)) => {
311311
if s.starts_with(':') {
312312
Ok(Value::String(s.clone()))
@@ -329,7 +329,7 @@ impl Tool for KeywordicateTool {
329329
"Ensure value is a keyword"
330330
}
331331
fn execute(&self, args: &[Value]) -> Result<Value> {
332-
match args.get(0) {
332+
match args.first() {
333333
Some(Value::String(s)) => {
334334
if s.starts_with(':') {
335335
Ok(Value::String(s.clone()))
@@ -357,7 +357,7 @@ impl Tool for InternTool {
357357
"Intern symbol in package"
358358
}
359359
fn execute(&self, args: &[Value]) -> Result<Value> {
360-
match args.get(0) {
360+
match args.first() {
361361
Some(Value::String(s)) => Ok(Value::String(s.clone())),
362362
_ => Ok(Value::Null),
363363
}
@@ -390,7 +390,7 @@ impl Tool for FindSymbolTool {
390390
}
391391
fn execute(&self, args: &[Value]) -> Result<Value> {
392392
// Returns (symbol, status)
393-
match args.get(0) {
393+
match args.first() {
394394
Some(s @ Value::String(_)) => Ok(Value::Array(Arc::new(vec![
395395
s.clone(),
396396
Value::String(":INTERNAL".to_string()),

crates/ovsm/src/tools/stdlib/types_extended.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ impl Tool for CoerceTool {
170170
got: "invalid".to_string(),
171171
}),
172172
},
173-
"STRING" => Ok(Value::String(format!(
174-
"{}",
175-
match value {
173+
"STRING" => Ok(Value::String(
174+
(match value {
176175
Value::String(s) => s.clone(),
177176
Value::Int(n) => n.to_string(),
178177
Value::Float(f) => f.to_string(),
179178
Value::Bool(b) => b.to_string(),
180179
Value::Null => "null".to_string(),
181180
_ => "?".to_string(),
182-
}
183-
))),
181+
})
182+
.to_string(),
183+
)),
184184
_ => Ok(value.clone()),
185185
}
186186
}

0 commit comments

Comments
 (0)