chore: enable clippy::redundant_clone (#3489)

Created this PR by:

- adding `redundant_clone` to `[workspace.lints.clippy]` in
`cargo-rs/Cargol.toml`
- running `cargo clippy --tests --fix`
- running `just fmt`

Though I had to clean up one instance of the following that resulted:

```rust
let codex = codex;
```
This commit is contained in:
Michael Bolin
2025-09-11 11:59:37 -07:00
committed by GitHub
parent 66967500bb
commit bec51f6c05
34 changed files with 71 additions and 98 deletions

View File

@@ -304,7 +304,7 @@ impl App {
}
pub(crate) fn token_usage(&self) -> codex_core::protocol::TokenUsage {
self.chat_widget.token_usage().clone()
self.chat_widget.token_usage()
}
async fn handle_key_event(&mut self, tui: &mut tui::Tui, key_event: KeyEvent) {

View File

@@ -487,7 +487,7 @@ impl ChatComposer {
} => {
// Hide popup without modifying text, remember token to avoid immediate reopen.
if let Some(tok) = Self::current_at_token(&self.textarea) {
self.dismissed_file_popup_token = Some(tok.to_string());
self.dismissed_file_popup_token = Some(tok);
}
self.active_popup = ActivePopup::None;
(InputResult::None, true)
@@ -546,7 +546,7 @@ impl ChatComposer {
Some(ext) if ext == "jpg" || ext == "jpeg" => "JPEG",
_ => "IMG",
};
self.attach_image(path_buf.clone(), w, h, format_label);
self.attach_image(path_buf, w, h, format_label);
// Add a trailing space to keep typing fluid.
self.textarea.insert_str(" ");
} else {
@@ -2123,7 +2123,7 @@ mod tests {
// Re-add and test backspace in middle: should break the placeholder string
// and drop the image mapping (same as text placeholder behavior).
composer.attach_image(path.clone(), 20, 10, "PNG");
composer.attach_image(path, 20, 10, "PNG");
let placeholder2 = composer.attached_images[0].placeholder.clone();
// Move cursor to roughly middle of placeholder
if let Some(start_pos) = composer.textarea.text().find(&placeholder2) {
@@ -2182,7 +2182,7 @@ mod tests {
let path1 = PathBuf::from("/tmp/image_dup1.png");
let path2 = PathBuf::from("/tmp/image_dup2.png");
composer.attach_image(path1.clone(), 10, 5, "PNG");
composer.attach_image(path1, 10, 5, "PNG");
// separate placeholders with a space for clarity
composer.handle_paste(" ".into());
composer.attach_image(path2.clone(), 10, 5, "PNG");
@@ -2231,7 +2231,7 @@ mod tests {
assert!(composer.textarea.text().starts_with("[image 3x2 PNG] "));
let imgs = composer.take_recent_submission_images();
assert_eq!(imgs, vec![tmp_path.clone()]);
assert_eq!(imgs, vec![tmp_path]);
}
#[test]

View File

@@ -564,7 +564,7 @@ mod tests {
let (tx_raw, rx) = unbounded_channel::<AppEvent>();
let tx = AppEventSender::new(tx_raw);
let mut pane = BottomPane::new(BottomPaneParams {
app_event_tx: tx.clone(),
app_event_tx: tx,
frame_requester: FrameRequester::test_dummy(),
has_input_focus: true,
enhanced_keys_supported: false,

View File

@@ -649,9 +649,7 @@ impl TextArea {
}
fn add_element(&mut self, range: Range<usize>) {
let elem = TextElement {
range: range.clone(),
};
let elem = TextElement { range };
self.elements.push(elem);
self.elements.sort_by_key(|e| e.range.start);
}

View File

@@ -574,14 +574,14 @@ impl ChatWidget {
self.active_exec_cell = Some(history_cell::new_active_exec_command(
ev.call_id.clone(),
ev.command.clone(),
ev.parsed_cmd.clone(),
ev.parsed_cmd,
));
}
} else {
self.active_exec_cell = Some(history_cell::new_active_exec_command(
ev.call_id.clone(),
ev.command.clone(),
ev.parsed_cmd.clone(),
ev.parsed_cmd,
));
}
@@ -804,7 +804,7 @@ impl ChatWidget {
"attach_image path={path:?} width={width} height={height} format={format_label}",
);
self.bottom_pane
.attach_image(path.clone(), width, height, format_label);
.attach_image(path, width, height, format_label);
self.request_redraw();
}
@@ -986,7 +986,7 @@ impl ChatWidget {
// Only show the text portion in conversation history.
if !text.is_empty() {
self.add_to_history(history_cell::new_user_prompt(text.clone()));
self.add_to_history(history_cell::new_user_prompt(text));
}
}
@@ -1055,10 +1055,10 @@ impl ChatWidget {
EventMsg::PlanUpdate(update) => self.on_plan_update(update),
EventMsg::ExecApprovalRequest(ev) => {
// For replayed events, synthesize an empty id (these should not occur).
self.on_exec_approval_request(id.clone().unwrap_or_default(), ev)
self.on_exec_approval_request(id.unwrap_or_default(), ev)
}
EventMsg::ApplyPatchApprovalRequest(ev) => {
self.on_apply_patch_approval_request(id.clone().unwrap_or_default(), ev)
self.on_apply_patch_approval_request(id.unwrap_or_default(), ev)
}
EventMsg::ExecCommandBegin(ev) => self.on_exec_command_begin(ev),
EventMsg::ExecCommandOutputDelta(delta) => self.on_exec_command_output_delta(delta),

View File

@@ -20,7 +20,7 @@ pub(crate) fn spawn_agent(
) -> UnboundedSender<Op> {
let (codex_op_tx, mut codex_op_rx) = unbounded_channel::<Op>();
let app_event_tx_clone = app_event_tx.clone();
let app_event_tx_clone = app_event_tx;
tokio::spawn(async move {
let NewConversation {
conversation_id: _,
@@ -71,7 +71,7 @@ pub(crate) fn spawn_agent_from_existing(
) -> UnboundedSender<Op> {
let (codex_op_tx, mut codex_op_rx) = unbounded_channel::<Op>();
let app_event_tx_clone = app_event_tx.clone();
let app_event_tx_clone = app_event_tx;
tokio::spawn(async move {
// Forward the captured `SessionConfigured` event so it can be rendered in the UI.
let ev = codex_core::protocol::Event {

View File

@@ -352,7 +352,7 @@ fn exec_approval_decision_truncates_multiline_and_long_commands() {
let long = format!("echo {}", "a".repeat(200));
let ev_long = ExecApprovalRequestEvent {
call_id: "call-long".into(),
command: vec!["bash".into(), "-lc".into(), long.clone()],
command: vec!["bash".into(), "-lc".into(), long],
cwd: std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")),
reason: None,
};

View File

@@ -737,10 +737,10 @@ mod tests {
let mut changes: HashMap<PathBuf, FileChange> = HashMap::new();
changes.insert(
abs_old.clone(),
abs_old,
FileChange::Update {
unified_diff: patch,
move_path: Some(abs_new.clone()),
move_path: Some(abs_new),
},
);

View File

@@ -697,7 +697,7 @@ fn spinner(start_time: Option<Instant>) -> Span<'static> {
pub(crate) fn new_active_mcp_tool_call(invocation: McpInvocation) -> PlainHistoryCell {
let title_line = Line::from(vec!["tool".magenta(), " running...".dim()]);
let lines: Vec<Line> = vec![title_line, format_mcp_invocation(invocation.clone())];
let lines: Vec<Line> = vec![title_line, format_mcp_invocation(invocation)];
PlainHistoryCell { lines }
}
@@ -1324,7 +1324,7 @@ fn format_mcp_invocation<'a>(invocation: McpInvocation) -> Line<'a> {
let invocation_spans = vec![
invocation.server.clone().cyan(),
".".into(),
invocation.tool.clone().cyan(),
invocation.tool.cyan(),
"(".into(),
args_str.dim(),
")".into(),

View File

@@ -432,7 +432,7 @@ impl AuthModeWidget {
match &mut *guard {
SignInState::ApiKeyEntry(state) => {
if state.value.is_empty() {
if let Some(prefill) = prefill_from_env.clone() {
if let Some(prefill) = prefill_from_env {
state.value = prefill;
state.prepopulated_from_env = true;
} else {

View File

@@ -71,7 +71,7 @@ impl OnboardingScreen {
config,
} = args;
let cwd = config.cwd.clone();
let codex_home = config.codex_home.clone();
let codex_home = config.codex_home;
let mut steps: Vec<Step> = vec![Step::Welcome(WelcomeWidget {
is_logged_in: !matches!(login_status, LoginStatus::NotAuthenticated),
})];

View File

@@ -244,7 +244,7 @@ impl UserApprovalWidget {
"You ".into(),
"approved".bold(),
" codex to run ".into(),
snippet.clone().dim(),
snippet.dim(),
" this time".bold(),
]);
}
@@ -254,7 +254,7 @@ impl UserApprovalWidget {
"You ".into(),
"approved".bold(),
" codex to run ".into(),
snippet.clone().dim(),
snippet.dim(),
" every time this session".bold(),
]);
}
@@ -264,7 +264,7 @@ impl UserApprovalWidget {
"You ".into(),
"did not approve".bold(),
" codex to run ".into(),
snippet.clone().dim(),
snippet.dim(),
]);
}
ReviewDecision::Abort => {
@@ -273,7 +273,7 @@ impl UserApprovalWidget {
"You ".into(),
"canceled".bold(),
" the request to run ".into(),
snippet.clone().dim(),
snippet.dim(),
]);
}
}