Skip to content

Fix for Useless conditional - #211

Merged
PDowney merged 1 commit into
masterfrom
finding-autofix-dfbf32e8
Apr 20, 2026
Merged

PDowney merged 1 commit into
masterfrom
finding-autofix-dfbf32e8

Conversation

@PDowney

@PDowney PDowney commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

To fix this, remove the redundant if (storage) guards in the two inner cleanup blocks and call storage.removeItem('servicePreferences') directly.
This preserves functionality because execution can only reach those blocks after the earlier if (!storage) return null; guard.

Where to change:

  • File: config/var/www/admin/control-panel/external-services/external-services.js
  • Region: loadServicePreferences() around lines 1488–1511.
  • No new imports, methods, or dependencies are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Thanks for contributing to EngineScript! 🎉

If your PR fixes an issue or relates to a specific environment, please consider including the sanitized output
of es.debug to show the environment where you tested your changes.
Remember to remove any sensitive information before sharing.

We'll review your PR soon!

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sonarqubecloud

Copy link
Copy Markdown

@PDowney
PDowney marked this pull request as ready for review April 20, 2026 23:21
Copilot AI review requested due to automatic review settings April 20, 2026 23:21
@PDowney
PDowney merged commit 4da5821 into master Apr 20, 2026
14 of 15 checks passed
@github-actions
github-actions Bot deleted the finding-autofix-dfbf32e8 branch April 20, 2026 23:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 calling storage.removeItem('servicePreferences') in two cleanup paths.
  • Kept existing error handling via try/catch around removeItem calls.

Comment on lines 1486 to 1490
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) {

Copilot AI Apr 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants