fix(store): drop dead-condition re-check in EditWarningCheck (Product/Collection/Brand/Category/Blog) - #811
Merged
Conversation
…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
Contributor
There was a problem hiding this comment.
🟢 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
EditWarningCheckcondition in Product/Collection/Brand/Category/Blog controllers by removing the deadLimitedToStoresre-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CodeQL flagged a constant-condition finding on PR #809 (Page consolidation):
PageController.EditWarningCheck'sif (!x.LimitedToStores || (x.LimitedToStores && ...))re-checksx.LimitedToStoresinside the OR's second branch, which is alwaystruethere since that branch only runs once the first branch's!x.LimitedToStoreshas already evaluatedfalse.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) andNewsController(#810).ProductController.EditWarningCheckCollectionController.EditWarningCheckBrandController.EditWarningCheckCategoryController.EditWarningCheckBlogController.EditWarningCheckNo behavior change — purely removing dead code flagged by static analysis.
Validation
dotnet build src/Web/Grand.Web.Store/Grand.Web.Store.csproj— 0 errorsdotnet test src/Tests/Grand.Web.Store.Testsfiltered to Product/Collection/Brand/Category/Blog controller tests — 17/17 passed🤖 Generated with Claude Code