Skip to content

Commit

Permalink
Fix potential null value issue in MergeDefaultConfig (#29)
Browse files Browse the repository at this point in the history
* Fix potential null value issue in MergeDefaultConfig

* 🔧 Simplify default config value assignment

Simplify the assignment of default configuration values by removing
unnecessary conditional checks. This change improves code readability
and reduces complexity.

---------

Co-authored-by: Lee Miller <[email protected]>
  • Loading branch information
lanyeeee and lemillermicrosoft authored Oct 19, 2023
1 parent 591e2d1 commit deed85c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions apps/SKonsole/ConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ private void MergeDefaultConfig()
};

bool hasChanged = false;

foreach (var defaultConfigItem in defaultConfig)
{
if (string.IsNullOrWhiteSpace(this._config[defaultConfigItem.Key]))
if (!this._config.TryGetValue(defaultConfigItem.Key, out string? value) || string.IsNullOrWhiteSpace(value))
{
this._config[defaultConfigItem.Key] = defaultConfigItem.Value;
hasChanged = true;
Expand Down

0 comments on commit deed85c

Please sign in to comment.