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

@ -543,27 +543,27 @@ impl KeymapFile {
//
// When a struct with no deserializable fields is added by deriving `Action`, an empty
// object schema is produced. The action should be invoked without data in this case.
if let Some(schema) = action_schema {
if schema != empty_object {
let mut matches_action_name = json_schema!({
"const": name
});
if let Some(desc) = description.clone() {
add_description(&mut matches_action_name, desc);
}
if let Some(message) = deprecation_messages.get(name) {
add_deprecation(&mut matches_action_name, message.to_string());
} else if let Some(new_name) = deprecation {
add_deprecation_preferred_name(&mut matches_action_name, new_name);
}
let action_with_input = json_schema!({
"type": "array",
"items": [matches_action_name, schema],
"minItems": 2,
"maxItems": 2
});
keymap_action_alternatives.push(action_with_input);
if let Some(schema) = action_schema
&& schema != empty_object
{
let mut matches_action_name = json_schema!({
"const": name
});
if let Some(desc) = description.clone() {
add_description(&mut matches_action_name, desc);
}
if let Some(message) = deprecation_messages.get(name) {
add_deprecation(&mut matches_action_name, message.to_string());
} else if let Some(new_name) = deprecation {
add_deprecation_preferred_name(&mut matches_action_name, new_name);
}
let action_with_input = json_schema!({
"type": "array",
"items": [matches_action_name, schema],
"minItems": 2,
"maxItems": 2
});
keymap_action_alternatives.push(action_with_input);
}
}
@ -593,10 +593,10 @@ impl KeymapFile {
match fs.load(paths::keymap_file()).await {
result @ Ok(_) => result,
Err(err) => {
if let Some(e) = err.downcast_ref::<std::io::Error>() {
if e.kind() == std::io::ErrorKind::NotFound {
return Ok(crate::initial_keymap_content().to_string());
}
if let Some(e) = err.downcast_ref::<std::io::Error>()
&& e.kind() == std::io::ErrorKind::NotFound
{
return Ok(crate::initial_keymap_content().to_string());
}
Err(err)
}

View file

@ -67,10 +67,10 @@ pub fn watch_config_file(
break;
}
if let Ok(contents) = fs.load(&path).await {
if tx.unbounded_send(contents).is_err() {
break;
}
if let Ok(contents) = fs.load(&path).await
&& tx.unbounded_send(contents).is_err()
{
break;
}
}
})
@ -88,12 +88,11 @@ pub fn watch_config_dir(
executor
.spawn(async move {
for file_path in &config_paths {
if fs.metadata(file_path).await.is_ok_and(|v| v.is_some()) {
if let Ok(contents) = fs.load(file_path).await {
if tx.unbounded_send(contents).is_err() {
return;
}
}
if fs.metadata(file_path).await.is_ok_and(|v| v.is_some())
&& let Ok(contents) = fs.load(file_path).await
&& tx.unbounded_send(contents).is_err()
{
return;
}
}
@ -110,10 +109,10 @@ pub fn watch_config_dir(
}
}
Some(PathEventKind::Created) | Some(PathEventKind::Changed) => {
if let Ok(contents) = fs.load(&event.path).await {
if tx.unbounded_send(contents).is_err() {
return;
}
if let Ok(contents) = fs.load(&event.path).await
&& tx.unbounded_send(contents).is_err()
{
return;
}
}
_ => {}

View file

@ -369,13 +369,12 @@ pub fn replace_top_level_array_value_in_json_text(
if cursor.node().kind() == "," {
remove_range.end = cursor.node().range().end_byte;
}
if let Some(next_newline) = &text[remove_range.end + 1..].find('\n') {
if text[remove_range.end + 1..remove_range.end + next_newline]
if let Some(next_newline) = &text[remove_range.end + 1..].find('\n')
&& text[remove_range.end + 1..remove_range.end + next_newline]
.chars()
.all(|c| c.is_ascii_whitespace())
{
remove_range.end = remove_range.end + next_newline;
}
{
remove_range.end = remove_range.end + next_newline;
}
} else {
while cursor.goto_previous_sibling()
@ -508,10 +507,10 @@ pub fn append_top_level_array_value_in_json_text(
replace_value.insert(0, ',');
}
} else {
if let Some(prev_newline) = text[..replace_range.start].rfind('\n') {
if text[prev_newline..replace_range.start].trim().is_empty() {
replace_range.start = prev_newline;
}
if let Some(prev_newline) = text[..replace_range.start].rfind('\n')
&& text[prev_newline..replace_range.start].trim().is_empty()
{
replace_range.start = prev_newline;
}
let indent = format!("\n{space:width$}", width = tab_size);
replace_value = replace_value.replace('\n', &indent);

View file

@ -346,14 +346,13 @@ impl SettingsStore {
}
let mut profile_value = None;
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() {
if let Some(profiles) = self.raw_user_settings.get("profiles") {
if let Some(profile_settings) = profiles.get(&active_profile.0) {
profile_value = setting_value
.deserialize_setting(profile_settings)
.log_err();
}
}
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>()
&& let Some(profiles) = self.raw_user_settings.get("profiles")
&& let Some(profile_settings) = profiles.get(&active_profile.0)
{
profile_value = setting_value
.deserialize_setting(profile_settings)
.log_err();
}
let server_value = self
@ -482,10 +481,10 @@ impl SettingsStore {
match fs.load(paths::settings_file()).await {
result @ Ok(_) => result,
Err(err) => {
if let Some(e) = err.downcast_ref::<std::io::Error>() {
if e.kind() == std::io::ErrorKind::NotFound {
return Ok(crate::initial_user_settings_content().to_string());
}
if let Some(e) = err.downcast_ref::<std::io::Error>()
&& e.kind() == std::io::ErrorKind::NotFound
{
return Ok(crate::initial_user_settings_content().to_string());
}
Err(err)
}
@ -496,10 +495,10 @@ impl SettingsStore {
match fs.load(paths::global_settings_file()).await {
result @ Ok(_) => result,
Err(err) => {
if let Some(e) = err.downcast_ref::<std::io::Error>() {
if e.kind() == std::io::ErrorKind::NotFound {
return Ok("{}".to_string());
}
if let Some(e) = err.downcast_ref::<std::io::Error>()
&& e.kind() == std::io::ErrorKind::NotFound
{
return Ok("{}".to_string());
}
Err(err)
}
@ -955,13 +954,13 @@ impl SettingsStore {
let mut setting_schema = setting_value.json_schema(&mut generator);
if let Some(key) = setting_value.key() {
if let Some(properties) = combined_schema.get_mut("properties") {
if let Some(properties_obj) = properties.as_object_mut() {
if let Some(target) = properties_obj.get_mut(key) {
merge_schema(target, setting_schema.to_value());
} else {
properties_obj.insert(key.to_string(), setting_schema.to_value());
}
if let Some(properties) = combined_schema.get_mut("properties")
&& let Some(properties_obj) = properties.as_object_mut()
{
if let Some(target) = properties_obj.get_mut(key) {
merge_schema(target, setting_schema.to_value());
} else {
properties_obj.insert(key.to_string(), setting_schema.to_value());
}
}
} else {
@ -1038,16 +1037,15 @@ impl SettingsStore {
| "additionalProperties" => {
if let Some(old_value) =
target_obj.insert(source_key.clone(), source_value.clone())
&& old_value != source_value
{
if old_value != source_value {
log::error!(
"bug: while merging JSON schemas, \
log::error!(
"bug: while merging JSON schemas, \
mismatch `\"{}\": {}` (before was `{}`)",
source_key,
old_value,
source_value
);
}
source_key,
old_value,
source_value
);
}
}
_ => {
@ -1168,35 +1166,31 @@ impl SettingsStore {
if let Some(release_settings) = &self
.raw_user_settings
.get(release_channel::RELEASE_CHANNEL.dev_name())
{
if let Some(release_settings) = setting_value
&& let Some(release_settings) = setting_value
.deserialize_setting(release_settings)
.log_err()
{
release_channel_settings = Some(release_settings);
}
{
release_channel_settings = Some(release_settings);
}
let mut os_settings = None;
if let Some(settings) = &self.raw_user_settings.get(env::consts::OS) {
if let Some(settings) = setting_value.deserialize_setting(settings).log_err() {
os_settings = Some(settings);
}
if let Some(settings) = &self.raw_user_settings.get(env::consts::OS)
&& let Some(settings) = setting_value.deserialize_setting(settings).log_err()
{
os_settings = Some(settings);
}
let mut profile_settings = None;
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>() {
if let Some(profiles) = self.raw_user_settings.get("profiles") {
if let Some(profile_json) = profiles.get(&active_profile.0) {
profile_settings =
setting_value.deserialize_setting(profile_json).log_err();
}
}
if let Some(active_profile) = cx.try_global::<ActiveSettingsProfileName>()
&& let Some(profiles) = self.raw_user_settings.get("profiles")
&& let Some(profile_json) = profiles.get(&active_profile.0)
{
profile_settings = setting_value.deserialize_setting(profile_json).log_err();
}
// If the global settings file changed, reload the global value for the field.
if changed_local_path.is_none() {
if let Some(value) = setting_value
if changed_local_path.is_none()
&& let Some(value) = setting_value
.load_setting(
SettingsSources {
default: &default_settings,
@ -1212,9 +1206,8 @@ impl SettingsStore {
cx,
)
.log_err()
{
setting_value.set_global_value(value);
}
{
setting_value.set_global_value(value);
}
// Reload the local values for the setting.
@ -1223,12 +1216,12 @@ impl SettingsStore {
for ((root_id, directory_path), local_settings) in &self.raw_local_settings {
// Build a stack of all of the local values for that setting.
while let Some(prev_entry) = paths_stack.last() {
if let Some((prev_root_id, prev_path)) = prev_entry {
if root_id != prev_root_id || !directory_path.starts_with(prev_path) {
paths_stack.pop();
project_settings_stack.pop();
continue;
}
if let Some((prev_root_id, prev_path)) = prev_entry
&& (root_id != prev_root_id || !directory_path.starts_with(prev_path))
{
paths_stack.pop();
project_settings_stack.pop();
continue;
}
break;
}