fix: resolve CodeQL complex-condition alert and PerformanceView MVVM violation#435
Conversation
…violation - ProcessManagerViewModel: replace chained || with ReadOnlySpan loop in MatchesDescription (CodeQL #302) - PerformanceView: remove PropertyChanged handler and Checked event from code-behind; use EqualityConverter for two-way radio button binding - Add EqualityConverter (reusable IValueConverter for radio button groups) - Add EqualityConverterTests (10 tests: Convert, ConvertBack, null, case sensitivity)
📝 WalkthroughWalkthroughIntroduces a reusable WPF ChangesEqualityConverter & PerformanceView Binding
ProcessManagerViewModel Code Quality Refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
SysManager/SysManager/Helpers/EqualityConverter.cs (1)
25-29: ⚡ Quick winPreserve
ConverterParametertype inConvertBackreturn path.At Line 28, returning
parameter?.ToString()forces string conversion and weakens reusability. Return the rawparameterand short-circuit null toBinding.DoNothing.♻️ Proposed fix
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is true) - return parameter?.ToString(); + return parameter ?? Binding.DoNothing; return Binding.DoNothing; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@SysManager/SysManager/Helpers/EqualityConverter.cs` around lines 25 - 29, The ConvertBack method currently returns parameter?.ToString(), which forces the ConverterParameter to a string; change ConvertBack so when value is true it returns the raw parameter object (not ToString()), and if parameter is null return Binding.DoNothing; keep the existing behavior of returning Binding.DoNothing when value is not true. Ensure you update the ConvertBack method (symbol: ConvertBack) to return parameter directly and use Binding.DoNothing as the null short-circuit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@SysManager/SysManager/Helpers/EqualityConverter.cs`:
- Around line 25-29: The ConvertBack method currently returns
parameter?.ToString(), which forces the ConverterParameter to a string; change
ConvertBack so when value is true it returns the raw parameter object (not
ToString()), and if parameter is null return Binding.DoNothing; keep the
existing behavior of returning Binding.DoNothing when value is not true. Ensure
you update the ConvertBack method (symbol: ConvertBack) to return parameter
directly and use Binding.DoNothing as the null short-circuit.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9c423aa3-3f70-42b7-92ec-953baf56d7b2
📒 Files selected for processing (7)
CHANGELOG.mdSysManager/SysManager.Tests/EqualityConverterTests.csSysManager/SysManager/App.xamlSysManager/SysManager/Helpers/EqualityConverter.csSysManager/SysManager/ViewModels/ProcessManagerViewModel.csSysManager/SysManager/Views/PerformanceView.xamlSysManager/SysManager/Views/PerformanceView.xaml.cs
💤 Files with no reviewable changes (1)
- SysManager/SysManager/Views/PerformanceView.xaml.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build & unit tests
- GitHub Check: Analyze (csharp)
🔇 Additional comments (2)
SysManager/SysManager/ViewModels/ProcessManagerViewModel.cs (1)
168-177: LGTM!SysManager/SysManager/Views/PerformanceView.xaml (1)
64-64: LGTM!Also applies to: 68-68, 72-72
Adds CHANGELOG entries for all 9 releases from the QA bug fix session: - **v0.28.16** — Dispose lifecycle (#395, #410) - **v0.28.17** — CTS disposal + bare catch (#396, #413) - **v0.28.18** — Input validation + null checks (#397, #398) - **v0.28.19** — JSON error handling (#400) - **v0.28.20** — Drive scanning + cache eviction + ConfigureAwait (#401, #402, #403) - **v0.28.21** — Audit logging + error messages (#405, #407) - **v0.28.22** — SHA256 verification (#408, #409) - **v0.28.23** — Service timeout + snapshot persist + traceroute DNS (#414, #415, #416) - **v0.28.24** — Accessibility (#411) 18 bugs fixed in total. Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
…violation (#435) - ProcessManagerViewModel: replace chained || with ReadOnlySpan loop in MatchesDescription (CodeQL #302) - PerformanceView: remove PropertyChanged handler and Checked event from code-behind; use EqualityConverter for two-way radio button binding - Add EqualityConverter (reusable IValueConverter for radio button groups) - Add EqualityConverterTests (10 tests: Convert, ConvertBack, null, case sensitivity) Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
Summary
Two code quality improvements:
1. CodeQL alert #302 — complex condition (ProcessManagerViewModel)
The
MatchesDescriptionmethod had 3 chained||with null-conditional operators, triggering CodeQL'scs/complex-conditionrule. Replaced with aReadOnlySpan<string?>loop that checks each field individually — same behavior, lower cyclomatic complexity.2. PerformanceView MVVM violation
The code-behind had:
PropertyChangedsubscription to sync radio buttons from ViewModelCheckedevent handler to push radio button selection back to ViewModelBoth are now replaced by a reusable
EqualityConverterwith two-way binding. Code-behind reduced from 55 lines to 14 (justInitializeComponent).Files changed
ProcessManagerViewModel.cs— simplifiedMatchesDescriptionPerformanceView.xaml— radio buttons use converter bindingPerformanceView.xaml.cs— removed all code-behind logicHelpers/EqualityConverter.cs— new reusable converterApp.xaml— registeredIsEqualconverterEqualityConverterTests.cs— 10 unit testsCHANGELOG.md— updatedTesting
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests
Refactor