Skip to content

fix(store): drop dead-condition re-check in EditWarningCheck (Product/Collection/Brand/Category/Blog) - #811

Merged
KrzysztofPajak merged 1 commit into
developfrom
fix/store-limitedtostores-dead-condition
Sep 3, 2026
Merged

fix(store): drop dead-condition re-check in EditWarningCheck (Product/Collection/Brand/Category/Blog)#811
KrzysztofPajak merged 1 commit into
developfrom
fix/store-limitedtostores-dead-condition

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Summary

CodeQL flagged a constant-condition finding on PR #809 (Page consolidation): PageController.EditWarningCheck's if (!x.LimitedToStores || (x.LimitedToStores && ...)) re-checks x.LimitedToStores inside the OR's second branch, which is always true there since that branch only runs once the first branch's !x.LimitedToStores has already evaluated false.

The same legacy idiom (predating ARCH-001, inherited via copy across phases) exists identically in five already-merged Store controllers. This PR drops the same dead re-check in all of them, matching the fix applied to PageController (#809) and NewsController (#810).

  • ProductController.EditWarningCheck
  • CollectionController.EditWarningCheck
  • BrandController.EditWarningCheck
  • CategoryController.EditWarningCheck
  • BlogController.EditWarningCheck

No behavior change — purely removing dead code flagged by static analysis.

Validation

  • dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj — 0 errors
  • dotnet test src/Tests/Grand.Web.Store.Tests filtered to Product/Collection/Brand/Category/Blog controller tests — 17/17 passed

🤖 Generated with Claude Code

…roduct/Collection/Brand/Category/Blog

CodeQL flagged this pattern (in the Page consolidation PR): the inner
'x.LimitedToStores &&' re-check in the OR's second branch is always
true, since it's only reached once the first branch's !x.LimitedToStores
has already evaluated false. Same legacy idiom exists identically in
these five already-merged Store controllers; removing the dead
re-check does not change behavior.

- ProductController.EditWarningCheck
- CollectionController.EditWarningCheck
- BrandController.EditWarningCheck
- CategoryController.EditWarningCheck
- BlogController.EditWarningCheck

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01FRztBQVfXimBPMFAioLabo
Copilot AI lite review requested due to automatic review settings September 3, 2026 18:54

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.

🟢 Approval recommended

The change removes provably dead conditional logic without altering behavior (preserved by || short-circuiting) and is narrowly scoped across the intended controllers.

Pull request overview

This PR removes a CodeQL-flagged constant-condition pattern from EditWarningCheck in five Store-area controllers by eliminating the redundant x.LimitedToStores && re-check inside the OR’s second branch (which is only reachable when LimitedToStores is already true).

Changes:

  • Simplified EditWarningCheck condition in Product/Collection/Brand/Category/Blog controllers by removing the dead LimitedToStores re-check in the second OR branch.
  • Kept behavior intact via short-circuit evaluation (||), while addressing static analysis findings consistently across controllers.
File summaries
File Description
src/Web/Grand.Web.Store/Controllers/ProductController.cs Removes redundant LimitedToStores check inside EditWarningCheck’s second OR branch.
src/Web/Grand.Web.Store/Controllers/CollectionController.cs Same redundant-condition removal in EditWarningCheck.
src/Web/Grand.Web.Store/Controllers/CategoryController.cs Same redundant-condition removal in EditWarningCheck.
src/Web/Grand.Web.Store/Controllers/BrandController.cs Same redundant-condition removal in EditWarningCheck.
src/Web/Grand.Web.Store/Controllers/BlogController.cs Same redundant-condition removal in EditWarningCheck (using PostScope.DefaultStoreId).
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@KrzysztofPajak
KrzysztofPajak merged commit e79754f into develop Sep 3, 2026
7 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/store-limitedtostores-dead-condition branch September 3, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants