Fix for Useless conditional - #211
Conversation
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
|
Thanks for contributing to EngineScript! 🎉 If your PR fixes an issue or relates to a specific environment, please consider including the sanitized output We'll review your PR soon! |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
There was a problem hiding this comment.
Pull request overview
This PR removes redundant if (storage) guards in loadServicePreferences() when clearing invalid/oversized stored preferences, relying on the existing early-return when localStorage is unavailable.
Changes:
- Removed unnecessary
if (storage)checks before callingstorage.removeItem('servicePreferences')in two cleanup paths. - Kept existing error handling via
try/catcharoundremoveItemcalls.
| if (storedPrefs.length > MAX_PREFERENCES_SIZE) { | ||
| console.warn('Stored service preferences exceed allowed size; resetting to defaults.'); | ||
| try { | ||
| if (storage) { | ||
| storage.removeItem('servicePreferences'); | ||
| } | ||
| storage.removeItem('servicePreferences'); | ||
| } catch (removeError) { |
There was a problem hiding this comment.
Project convention requires updating the root CHANGELOG.md whenever the codebase is modified; please add an entry describing this service-preferences cleanup (see .github/copilot-instructions.md:48-53).



To fix this, remove the redundant
if (storage)guards in the two inner cleanup blocks and callstorage.removeItem('servicePreferences')directly.This preserves functionality because execution can only reach those blocks after the earlier
if (!storage) return null;guard.Where to change:
config/var/www/admin/control-panel/external-services/external-services.jsloadServicePreferences()around lines 1488–1511.Suggested fixes powered by Copilot Autofix. Review carefully before merging.