-
Notifications
You must be signed in to change notification settings - Fork 26
Issue: Nested if statement should be merged for clarity and readability #703
Copy link
Copy link
Labels
C#C# related codeC# related codeMaintainabilitybugSomething isn't workingSomething isn't workingcode cleanupcleaning-up codecleaning-up codegood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededrefactoringRefactoring codeRefactoring code
Description
What version of FlowSynx?
1.2.3
Describe the bug
There’s a redundant nested if statement that can be merged into a single conditional statement.
This simplifies the logic and improves readability without changing functionality.
File: src/FlowSynx.Infrastructure/PluginHost/Cache/PluginCacheService.cs
Methos: RegisterEvictionCallback
Current Implementation
private void RegisterEvictionCallback(MemoryCacheEntryOptions options)
{
options.RegisterPostEvictionCallback((_, evictedValue, reason, _) =>
{
if (reason is EvictionReason.Expired or EvictionReason.Removed)
{
if (evictedValue is IPluginLoader pluginHandle)
{
pluginHandle.Unload();
}
}
});
}Proposed Fix
Merge the two if statements into one combined condition.
private void RegisterEvictionCallback(MemoryCacheEntryOptions options)
{
options.RegisterPostEvictionCallback((_, evictedValue, reason, _) =>
{
if ((reason is EvictionReason.Expired or EvictionReason.Removed) &&
evictedValue is IPluginLoader pluginHandle)
{
pluginHandle.Unload();
}
});
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C#C# related codeC# related codeMaintainabilitybugSomething isn't workingSomething isn't workingcode cleanupcleaning-up codecleaning-up codegood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededrefactoringRefactoring codeRefactoring code