Another batch of lint fixes (#36521)

- **Enable a bunch of extra lints**
- **First batch of fixes**
- **More fixes**

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 22:33:44 +02:00 committed by GitHub
parent 69b1c6d6f5
commit 6825715503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 788 additions and 1042 deletions

View file

@ -413,13 +413,10 @@ impl LocalBufferStore {
cx: &mut Context<BufferStore>,
) {
cx.subscribe(worktree, |this, worktree, event, cx| {
if worktree.read(cx).is_local() {
match event {
worktree::Event::UpdatedEntries(changes) => {
Self::local_worktree_entries_changed(this, &worktree, changes, cx);
}
_ => {}
}
if worktree.read(cx).is_local()
&& let worktree::Event::UpdatedEntries(changes) = event
{
Self::local_worktree_entries_changed(this, &worktree, changes, cx);
}
})
.detach();
@ -947,10 +944,9 @@ impl BufferStore {
}
pub fn get_by_path(&self, path: &ProjectPath) -> Option<Entity<Buffer>> {
self.path_to_buffer_id.get(path).and_then(|buffer_id| {
let buffer = self.get(*buffer_id);
buffer
})
self.path_to_buffer_id
.get(path)
.and_then(|buffer_id| self.get(*buffer_id))
}
pub fn get(&self, buffer_id: BufferId) -> Option<Entity<Buffer>> {

View file

@ -4,8 +4,8 @@ use gpui::{Hsla, Rgba};
use lsp::{CompletionItem, Documentation};
use regex::{Regex, RegexBuilder};
const HEX: &'static str = r#"(#(?:[\da-fA-F]{3}){1,2})"#;
const RGB_OR_HSL: &'static str = r#"(rgba?|hsla?)\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*(?:,\s*(1|0?\.\d+))?\s*\)"#;
const HEX: &str = r#"(#(?:[\da-fA-F]{3}){1,2})"#;
const RGB_OR_HSL: &str = r#"(rgba?|hsla?)\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*(?:,\s*(1|0?\.\d+))?\s*\)"#;
static RELAXED_HEX_REGEX: LazyLock<Regex> = LazyLock::new(|| {
RegexBuilder::new(HEX)
@ -141,7 +141,7 @@ mod tests {
use gpui::rgba;
use lsp::{CompletionItem, CompletionItemKind};
pub const COLOR_TABLE: &[(&'static str, Option<u32>)] = &[
pub const COLOR_TABLE: &[(&str, Option<u32>)] = &[
// -- Invalid --
// Invalid hex
("f0f", None),

View file

@ -642,8 +642,8 @@ mod tests {
#[gpui::test]
async fn test_context_server_status(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_2_ID: &'static str = "mcp-2";
const SERVER_1_ID: &str = "mcp-1";
const SERVER_2_ID: &str = "mcp-2";
let (_fs, project) = setup_context_server_test(
cx,
@ -722,8 +722,8 @@ mod tests {
#[gpui::test]
async fn test_context_server_status_events(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_2_ID: &'static str = "mcp-2";
const SERVER_1_ID: &str = "mcp-1";
const SERVER_2_ID: &str = "mcp-2";
let (_fs, project) = setup_context_server_test(
cx,
@ -784,7 +784,7 @@ mod tests {
#[gpui::test(iterations = 25)]
async fn test_context_server_concurrent_starts(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_1_ID: &str = "mcp-1";
let (_fs, project) = setup_context_server_test(
cx,
@ -845,8 +845,8 @@ mod tests {
#[gpui::test]
async fn test_context_server_maintain_servers_loop(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_2_ID: &'static str = "mcp-2";
const SERVER_1_ID: &str = "mcp-1";
const SERVER_2_ID: &str = "mcp-2";
let server_1_id = ContextServerId(SERVER_1_ID.into());
let server_2_id = ContextServerId(SERVER_2_ID.into());
@ -1084,7 +1084,7 @@ mod tests {
#[gpui::test]
async fn test_context_server_enabled_disabled(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_1_ID: &str = "mcp-1";
let server_1_id = ContextServerId(SERVER_1_ID.into());

View file

@ -470,9 +470,8 @@ impl DapStore {
session_id: impl Borrow<SessionId>,
) -> Option<Entity<session::Session>> {
let session_id = session_id.borrow();
let client = self.sessions.get(session_id).cloned();
client
self.sessions.get(session_id).cloned()
}
pub fn sessions(&self) -> impl Iterator<Item = &Entity<Session>> {
self.sessions.values()

View file

@ -174,7 +174,7 @@ impl DapLocator for GoLocator {
request: "launch".to_string(),
mode: "test".to_string(),
program,
args: args,
args,
build_flags,
cwd: build_config.cwd.clone(),
env: build_config.env.clone(),
@ -185,7 +185,7 @@ impl DapLocator for GoLocator {
label: resolved_label.to_string().into(),
adapter: adapter.0.clone(),
build: None,
config: config,
config,
tcp_connection: None,
})
}
@ -220,7 +220,7 @@ impl DapLocator for GoLocator {
request: "launch".to_string(),
mode: "debug".to_string(),
program,
args: args,
args,
build_flags,
})
.unwrap();

View file

@ -226,7 +226,7 @@ impl RunningMode {
fn unset_breakpoints_from_paths(&self, paths: &Vec<Arc<Path>>, cx: &mut App) -> Task<()> {
let tasks: Vec<_> = paths
.into_iter()
.iter()
.map(|path| {
self.request(dap_command::SetBreakpoints {
source: client_source(path),
@ -508,13 +508,12 @@ impl RunningMode {
.ok();
}
let ret = if configuration_done_supported {
if configuration_done_supported {
this.request(ConfigurationDone {})
} else {
Task::ready(Ok(()))
}
.await;
ret
.await
}
});
@ -839,7 +838,7 @@ impl Session {
})
.detach();
let this = Self {
Self {
mode: SessionState::Booting(None),
id: session_id,
child_session_ids: HashSet::default(),
@ -868,9 +867,7 @@ impl Session {
task_context,
memory: memory::Memory::new(),
quirks,
};
this
}
})
}

View file

@ -446,15 +446,12 @@ impl ImageStore {
event: &ImageItemEvent,
cx: &mut Context<Self>,
) {
match event {
ImageItemEvent::FileHandleChanged => {
if let Some(local) = self.state.as_local() {
local.update(cx, |local, cx| {
local.image_changed_file(image, cx);
})
}
}
_ => {}
if let ImageItemEvent::FileHandleChanged = event
&& let Some(local) = self.state.as_local()
{
local.update(cx, |local, cx| {
local.image_changed_file(image, cx);
})
}
}
}
@ -531,13 +528,10 @@ impl ImageStoreImpl for Entity<LocalImageStore> {
impl LocalImageStore {
fn subscribe_to_worktree(&mut self, worktree: &Entity<Worktree>, cx: &mut Context<Self>) {
cx.subscribe(worktree, |this, worktree, event, cx| {
if worktree.read(cx).is_local() {
match event {
worktree::Event::UpdatedEntries(changes) => {
this.local_worktree_entries_changed(&worktree, changes, cx);
}
_ => {}
}
if worktree.read(cx).is_local()
&& let worktree::Event::UpdatedEntries(changes) = event
{
this.local_worktree_entries_changed(&worktree, changes, cx);
}
})
.detach();

View file

@ -2501,8 +2501,8 @@ pub(crate) fn parse_completion_text_edit(
};
Some(ParsedCompletionEdit {
insert_range: insert_range,
replace_range: replace_range,
insert_range,
replace_range,
new_text: new_text.clone(),
})
}

View file

@ -550,7 +550,7 @@ impl LocalLspStore {
if let Some(settings) = settings.binary.as_ref() {
if let Some(arguments) = &settings.arguments {
binary.arguments = arguments.into_iter().map(Into::into).collect();
binary.arguments = arguments.iter().map(Into::into).collect();
}
if let Some(env) = &settings.env {
shell_env.extend(env.iter().map(|(k, v)| (k.clone(), v.clone())));
@ -1060,8 +1060,8 @@ impl LocalLspStore {
};
let delegate: Arc<dyn ManifestDelegate> =
Arc::new(ManifestQueryDelegate::new(worktree.read(cx).snapshot()));
let root = self
.lsp_tree
self.lsp_tree
.get(
project_path,
language.name(),
@ -1069,9 +1069,7 @@ impl LocalLspStore {
&delegate,
cx,
)
.collect::<Vec<_>>();
root
.collect::<Vec<_>>()
}
fn language_server_ids_for_buffer(
@ -2397,7 +2395,8 @@ impl LocalLspStore {
let server_id = server_node.server_id_or_init(|disposition| {
let path = &disposition.path;
let server_id = {
{
let uri =
Url::from_file_path(worktree.read(cx).abs_path().join(&path.path));
@ -2415,9 +2414,7 @@ impl LocalLspStore {
state.add_workspace_folder(uri);
};
server_id
};
server_id
}
})?;
let server_state = self.language_servers.get(&server_id)?;
if let LanguageServerState::Running {
@ -3047,16 +3044,14 @@ impl LocalLspStore {
buffer.edit([(range, text)], None, cx);
}
let transaction = buffer.end_transaction(cx).and_then(|transaction_id| {
buffer.end_transaction(cx).and_then(|transaction_id| {
if push_to_history {
buffer.finalize_last_transaction();
buffer.get_transaction(transaction_id).cloned()
} else {
buffer.forget_transaction(transaction_id)
}
});
transaction
})
})?;
if let Some(transaction) = transaction {
project_transaction.0.insert(buffer_to_edit, transaction);
@ -4370,13 +4365,11 @@ impl LspStore {
if let Some((client, downstream_project_id)) = self.downstream_client.clone()
&& let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id())
{
let mut summaries = diangostic_summaries
.into_iter()
.flat_map(|(path, summaries)| {
summaries
.into_iter()
.map(|(server_id, summary)| summary.to_proto(*server_id, path))
});
let mut summaries = diangostic_summaries.iter().flat_map(|(path, summaries)| {
summaries
.iter()
.map(|(server_id, summary)| summary.to_proto(*server_id, path))
});
if let Some(summary) = summaries.next() {
client
.send(proto::UpdateDiagnosticSummary {
@ -4564,7 +4557,7 @@ impl LspStore {
anyhow::anyhow!(message)
})?;
let response = request
request
.response_from_lsp(
response,
this.upgrade().context("no app context")?,
@ -4572,8 +4565,7 @@ impl LspStore {
language_server.server_id(),
cx.clone(),
)
.await;
response
.await
})
}
@ -4853,7 +4845,7 @@ impl LspStore {
push_to_history: bool,
cx: &mut Context<Self>,
) -> Task<anyhow::Result<ProjectTransaction>> {
if let Some(_) = self.as_local() {
if self.as_local().is_some() {
cx.spawn(async move |lsp_store, cx| {
let buffers = buffers.into_iter().collect::<Vec<_>>();
let result = LocalLspStore::execute_code_action_kind_locally(
@ -7804,7 +7796,7 @@ impl LspStore {
}
None => {
diagnostics_summary = Some(proto::UpdateDiagnosticSummary {
project_id: project_id,
project_id,
worktree_id: worktree_id.to_proto(),
summary: Some(proto::DiagnosticSummary {
path: project_path.path.as_ref().to_proto(),
@ -10054,7 +10046,7 @@ impl LspStore {
cx: &mut Context<Self>,
) -> Task<anyhow::Result<ProjectTransaction>> {
let logger = zlog::scoped!("format");
if let Some(_) = self.as_local() {
if self.as_local().is_some() {
zlog::trace!(logger => "Formatting locally");
let logger = zlog::scoped!(logger => "local");
let buffers = buffers

View file

@ -43,12 +43,9 @@ impl WorktreeRoots {
match event {
WorktreeEvent::UpdatedEntries(changes) => {
for (path, _, kind) in changes.iter() {
match kind {
worktree::PathChange::Removed => {
let path = TriePath::from(path.as_ref());
this.roots.remove(&path);
}
_ => {}
if kind == &worktree::PathChange::Removed {
let path = TriePath::from(path.as_ref());
this.roots.remove(&path);
}
}
}
@ -197,11 +194,8 @@ impl ManifestTree {
evt: &WorktreeStoreEvent,
_: &mut Context<Self>,
) {
match evt {
WorktreeStoreEvent::WorktreeRemoved(_, worktree_id) => {
self.root_points.remove(worktree_id);
}
_ => {}
if let WorktreeStoreEvent::WorktreeRemoved(_, worktree_id) = evt {
self.root_points.remove(worktree_id);
}
}
}

View file

@ -2885,14 +2885,11 @@ impl Project {
event: &DapStoreEvent,
cx: &mut Context<Self>,
) {
match event {
DapStoreEvent::Notification(message) => {
cx.emit(Event::Toast {
notification_id: "dap".into(),
message: message.clone(),
});
}
_ => {}
if let DapStoreEvent::Notification(message) = event {
cx.emit(Event::Toast {
notification_id: "dap".into(),
message: message.clone(),
});
}
}
@ -3179,14 +3176,11 @@ impl Project {
event: &ImageItemEvent,
cx: &mut Context<Self>,
) -> Option<()> {
match event {
ImageItemEvent::ReloadNeeded => {
if !self.is_via_collab() {
self.reload_images([image.clone()].into_iter().collect(), cx)
.detach_and_log_err(cx);
}
}
_ => {}
if let ImageItemEvent::ReloadNeeded = event
&& !self.is_via_collab()
{
self.reload_images([image.clone()].into_iter().collect(), cx)
.detach_and_log_err(cx);
}
None

View file

@ -695,7 +695,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
assert_eq!(
buffer
.completion_triggers()
.into_iter()
.iter()
.cloned()
.collect::<Vec<_>>(),
&[".".to_string(), "::".to_string()]
@ -747,7 +747,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
assert_eq!(
buffer
.completion_triggers()
.into_iter()
.iter()
.cloned()
.collect::<Vec<_>>(),
&[":".to_string()]
@ -766,7 +766,7 @@ async fn test_managing_language_servers(cx: &mut gpui::TestAppContext) {
assert_eq!(
buffer
.completion_triggers()
.into_iter()
.iter()
.cloned()
.collect::<Vec<_>>(),
&[".".to_string(), "::".to_string()]

View file

@ -110,7 +110,7 @@ impl<T: InventoryContents> InventoryFor<T> {
fn global_scenarios(&self) -> impl '_ + Iterator<Item = (TaskSourceKind, T)> {
self.global.iter().flat_map(|(file_path, templates)| {
templates.into_iter().map(|template| {
templates.iter().map(|template| {
(
TaskSourceKind::AbsPath {
id_base: Cow::Owned(format!("global {}", T::GLOBAL_SOURCE_FILE)),

View file

@ -67,13 +67,11 @@ pub struct SshDetails {
impl Project {
pub fn active_project_directory(&self, cx: &App) -> Option<Arc<Path>> {
let worktree = self
.active_entry()
self.active_entry()
.and_then(|entry_id| self.worktree_for_entry(entry_id, cx))
.into_iter()
.chain(self.worktrees(cx))
.find_map(|tree| tree.read(cx).root_dir());
worktree
.find_map(|tree| tree.read(cx).root_dir())
}
pub fn first_project_directory(&self, cx: &App) -> Option<PathBuf> {