Skip to content

Commit 5dced53

Browse files
fix(store): drop dead-condition re-check in EditWarningCheck across Product/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
1 parent 2da0b6b commit 5dced53

5 files changed

Lines changed: 5 additions & 10 deletions

File tree

src/Web/Grand.Web.Store/Controllers/BlogController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public class BlogController(
4646
protected override void EditWarningCheck(BlogPost blogPost)
4747
{
4848
if (!blogPost.LimitedToStores ||
49-
(blogPost.LimitedToStores &&
50-
blogPost.Stores.Contains(PostScope.DefaultStoreId) &&
49+
(blogPost.Stores.Contains(PostScope.DefaultStoreId) &&
5150
blogPost.Stores.Count > 1))
5251
Warning(TranslationService.GetResource("Admin.Content.Blog.BlogPosts.Permissions"));
5352
}

src/Web/Grand.Web.Store/Controllers/BrandController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public class BrandController(
3838
protected override void EditWarningCheck(Brand brand)
3939
{
4040
if (!brand.LimitedToStores ||
41-
(brand.LimitedToStores &&
42-
brand.Stores.Contains(Scope.DefaultStoreId) &&
41+
(brand.Stores.Contains(Scope.DefaultStoreId) &&
4342
brand.Stores.Count > 1))
4443
Warning(TranslationService.GetResource("Admin.Catalog.Brands.Permissions"));
4544
}

src/Web/Grand.Web.Store/Controllers/CategoryController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public class CategoryController(
3838
protected override void EditWarningCheck(Category category)
3939
{
4040
if (!category.LimitedToStores ||
41-
(category.LimitedToStores &&
42-
category.Stores.Contains(Scope.DefaultStoreId) &&
41+
(category.Stores.Contains(Scope.DefaultStoreId) &&
4342
category.Stores.Count > 1))
4443
Warning(TranslationService.GetResource("Admin.Catalog.Categories.Permissions"));
4544
}

src/Web/Grand.Web.Store/Controllers/CollectionController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public class CollectionController(
4040
protected override void EditWarningCheck(Collection collection)
4141
{
4242
if (!collection.LimitedToStores ||
43-
(collection.LimitedToStores &&
44-
collection.Stores.Contains(Scope.DefaultStoreId) &&
43+
(collection.Stores.Contains(Scope.DefaultStoreId) &&
4544
collection.Stores.Count > 1))
4645
Warning(TranslationService.GetResource("Admin.Catalog.Collections.Permissions"));
4746
}

src/Web/Grand.Web.Store/Controllers/ProductController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public class ProductController(
5050
protected override void EditWarningCheck(Product product)
5151
{
5252
if (!product.LimitedToStores ||
53-
(product.LimitedToStores &&
54-
product.Stores.Contains(Scope.DefaultStoreId) &&
53+
(product.Stores.Contains(Scope.DefaultStoreId) &&
5554
product.Stores.Count > 1))
5655
Warning(TranslationService.GetResource("Admin.Catalog.Products.Permissions"));
5756
}

0 commit comments

Comments
 (0)