Auto-fix clippy::collapsible_if violations (#36428)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 15:27:24 +02:00 committed by GitHub
parent 9e8ec72bd5
commit 8f567383e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
281 changed files with 6628 additions and 7089 deletions

View file

@ -131,19 +131,19 @@ impl super::LspAdapter for GoLspAdapter {
if let Some(version) = *version {
let binary_path = container_dir.join(format!("gopls_{version}_go_{go_version}"));
if let Ok(metadata) = fs::metadata(&binary_path).await {
if metadata.is_file() {
remove_matching(&container_dir, |entry| {
entry != binary_path && entry.file_name() != Some(OsStr::new("gobin"))
})
.await;
if let Ok(metadata) = fs::metadata(&binary_path).await
&& metadata.is_file()
{
remove_matching(&container_dir, |entry| {
entry != binary_path && entry.file_name() != Some(OsStr::new("gobin"))
})
.await;
return Ok(LanguageServerBinary {
path: binary_path.to_path_buf(),
arguments: server_binary_arguments(),
env: None,
});
}
return Ok(LanguageServerBinary {
path: binary_path.to_path_buf(),
arguments: server_binary_arguments(),
env: None,
});
}
} else if let Some(path) = this
.cached_server_binary(container_dir.clone(), delegate)

View file

@ -244,11 +244,8 @@ pub fn init(languages: Arc<LanguageRegistry>, node: NodeRuntime, cx: &mut App) {
cx.observe_flag::<BasedPyrightFeatureFlag, _>({
let languages = languages.clone();
move |enabled, _| {
if enabled {
if let Some(adapter) = basedpyright_lsp_adapter.take() {
languages
.register_available_lsp_adapter(adapter.name(), move || adapter.clone());
}
if enabled && let Some(adapter) = basedpyright_lsp_adapter.take() {
languages.register_available_lsp_adapter(adapter.name(), move || adapter.clone());
}
}
})

View file

@ -338,31 +338,31 @@ impl LspAdapter for PythonLspAdapter {
let interpreter_path = toolchain.path.to_string();
// Detect if this is a virtual environment
if let Some(interpreter_dir) = Path::new(&interpreter_path).parent() {
if let Some(venv_dir) = interpreter_dir.parent() {
// Check if this looks like a virtual environment
if venv_dir.join("pyvenv.cfg").exists()
|| venv_dir.join("bin/activate").exists()
|| venv_dir.join("Scripts/activate.bat").exists()
{
// Set venvPath and venv at the root level
// This matches the format of a pyrightconfig.json file
if let Some(parent) = venv_dir.parent() {
// Use relative path if the venv is inside the workspace
let venv_path = if parent == adapter.worktree_root_path() {
".".to_string()
} else {
parent.to_string_lossy().into_owned()
};
object.insert("venvPath".to_string(), Value::String(venv_path));
}
if let Some(interpreter_dir) = Path::new(&interpreter_path).parent()
&& let Some(venv_dir) = interpreter_dir.parent()
{
// Check if this looks like a virtual environment
if venv_dir.join("pyvenv.cfg").exists()
|| venv_dir.join("bin/activate").exists()
|| venv_dir.join("Scripts/activate.bat").exists()
{
// Set venvPath and venv at the root level
// This matches the format of a pyrightconfig.json file
if let Some(parent) = venv_dir.parent() {
// Use relative path if the venv is inside the workspace
let venv_path = if parent == adapter.worktree_root_path() {
".".to_string()
} else {
parent.to_string_lossy().into_owned()
};
object.insert("venvPath".to_string(), Value::String(venv_path));
}
if let Some(venv_name) = venv_dir.file_name() {
object.insert(
"venv".to_owned(),
Value::String(venv_name.to_string_lossy().into_owned()),
);
}
if let Some(venv_name) = venv_dir.file_name() {
object.insert(
"venv".to_owned(),
Value::String(venv_name.to_string_lossy().into_owned()),
);
}
}
}
@ -1519,31 +1519,31 @@ impl LspAdapter for BasedPyrightLspAdapter {
let interpreter_path = toolchain.path.to_string();
// Detect if this is a virtual environment
if let Some(interpreter_dir) = Path::new(&interpreter_path).parent() {
if let Some(venv_dir) = interpreter_dir.parent() {
// Check if this looks like a virtual environment
if venv_dir.join("pyvenv.cfg").exists()
|| venv_dir.join("bin/activate").exists()
|| venv_dir.join("Scripts/activate.bat").exists()
{
// Set venvPath and venv at the root level
// This matches the format of a pyrightconfig.json file
if let Some(parent) = venv_dir.parent() {
// Use relative path if the venv is inside the workspace
let venv_path = if parent == adapter.worktree_root_path() {
".".to_string()
} else {
parent.to_string_lossy().into_owned()
};
object.insert("venvPath".to_string(), Value::String(venv_path));
}
if let Some(interpreter_dir) = Path::new(&interpreter_path).parent()
&& let Some(venv_dir) = interpreter_dir.parent()
{
// Check if this looks like a virtual environment
if venv_dir.join("pyvenv.cfg").exists()
|| venv_dir.join("bin/activate").exists()
|| venv_dir.join("Scripts/activate.bat").exists()
{
// Set venvPath and venv at the root level
// This matches the format of a pyrightconfig.json file
if let Some(parent) = venv_dir.parent() {
// Use relative path if the venv is inside the workspace
let venv_path = if parent == adapter.worktree_root_path() {
".".to_string()
} else {
parent.to_string_lossy().into_owned()
};
object.insert("venvPath".to_string(), Value::String(venv_path));
}
if let Some(venv_name) = venv_dir.file_name() {
object.insert(
"venv".to_owned(),
Value::String(venv_name.to_string_lossy().into_owned()),
);
}
if let Some(venv_name) = venv_dir.file_name() {
object.insert(
"venv".to_owned(),
Value::String(venv_name.to_string_lossy().into_owned()),
);
}
}
}

View file

@ -598,12 +598,10 @@ impl ContextProvider for RustContextProvider {
if let Some(path) = local_abs_path
.as_deref()
.and_then(|local_abs_path| local_abs_path.parent())
{
if let Some(package_name) =
&& let Some(package_name) =
human_readable_package_name(path, project_env.as_ref()).await
{
variables.insert(RUST_PACKAGE_TASK_VARIABLE.clone(), package_name);
}
{
variables.insert(RUST_PACKAGE_TASK_VARIABLE.clone(), package_name);
}
if let Some(path) = local_abs_path.as_ref()
&& let Some((target, manifest_path)) =

View file

@ -341,10 +341,10 @@ async fn detect_package_manager(
fs: Arc<dyn Fs>,
package_json_data: Option<PackageJsonData>,
) -> &'static str {
if let Some(package_json_data) = package_json_data {
if let Some(package_manager) = package_json_data.package_manager {
return package_manager;
}
if let Some(package_json_data) = package_json_data
&& let Some(package_manager) = package_json_data.package_manager
{
return package_manager;
}
if fs.is_file(&worktree_root.join("pnpm-lock.yaml")).await {
return "pnpm";