Skip to content

Commit

Permalink
Review of code analysis warnings (#295)
Browse files Browse the repository at this point in the history
* Sonar issues

* Review warnings/messages

* Review warnings/messages

* Revert "Review warnings/messages"

This reverts commit 932e47f.

* Review of code analysis information

---------

Signed-off-by: Si Carter <[email protected]>
  • Loading branch information
k3ldar authored Jul 5, 2024
1 parent d8bb6fc commit de428db
Show file tree
Hide file tree
Showing 228 changed files with 1,174 additions and 967 deletions.
12 changes: 6 additions & 6 deletions DAL/PluginManager.DAL.TextFiles/Providers/AccountProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public bool SetDeliveryAddress(in long userId, in DeliveryAddress deliveryAddres

public List<DeliveryAddress> GetDeliveryAddresses(in long userId)
{
List<DeliveryAddress> Result = new();
List<DeliveryAddress> Result = [];
UserDataRow user = _users.Select(userId);

if (user == null)
Expand Down Expand Up @@ -510,7 +510,7 @@ public bool SetMarketingPreferences(in Int64 userId, in Marketing marketing)

public List<Order> OrdersGet(in Int64 userId)
{
List<Order> Result = new();
List<Order> Result = [];

UserDataRow user = _users.Select(userId);

Expand All @@ -521,7 +521,7 @@ public List<Order> OrdersGet(in Int64 userId)

userOrders.ForEach(o =>
{
List<OrderItem> orderItems = new();
List<OrderItem> orderItems = [];
List<OrderItemDataRow> userOrderItems = _ordersItems.Select().Where(oi => oi.OrderId.Equals(o.Id)).ToList();
Expand Down Expand Up @@ -560,7 +560,7 @@ public void OrderPaid(in Order order, in PaymentStatus paymentStatus, in string

_invoices.Insert(newInvoice);

List<InvoiceItemDataRow> invoiceItems = new();
List<InvoiceItemDataRow> invoiceItems = [];
List<OrderItemDataRow> orderItems = _ordersItems.Select().Where(oi => oi.OrderId.Equals(orderDataRow.Id)).ToList();

orderItems.ForEach(oi =>
Expand Down Expand Up @@ -588,7 +588,7 @@ public void OrderPaid(in Order order, in PaymentStatus paymentStatus, in string

public List<Invoice> InvoicesGet(in Int64 userId)
{
List<Invoice> Result = new();
List<Invoice> Result = [];
UserDataRow user = _users.Select(userId);

if (user == null)
Expand All @@ -598,7 +598,7 @@ public List<Invoice> InvoicesGet(in Int64 userId)

userInvoices.ForEach(i =>
{
List<InvoiceItem> invoiceItems = new();
List<InvoiceItem> invoiceItems = [];
List<InvoiceItemDataRow> userOrderItems = _invoiceItems.Select().Where(ii => ii.InvoiceId.Equals(i.Id)).ToList();
Expand Down
4 changes: 2 additions & 2 deletions DAL/PluginManager.DAL.TextFiles/Providers/BlogProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private static bool BlogHasTag(BlogDataRow tableBlog, string[] tags)

private List<BlogItem> ConvertTableBlogToBlogItem(List<BlogDataRow> tableBlogs)
{
List<BlogItem> Result = new();
List<BlogItem> Result = [];

tableBlogs.ForEach(blog => Result.Add(ConvertTableBlogToBlogItem(blog)));

Expand All @@ -180,7 +180,7 @@ private BlogItem ConvertTableBlogToBlogItem(BlogDataRow blog)
return null;

BlogItem Result = new(Convert.ToInt32(blog.Id), blog.UserId, blog.Title, blog.Excerpt, blog.BlogText, blog.Username, blog.Published,
blog.PublishDateTime, blog.Created, blog.Updated, blog.Tags, new List<BlogComment>());
blog.PublishDateTime, blog.Created, blog.Updated, blog.Tags, []);

List<BlogCommentDataRow> comments = _blogComments.Select().Where(bc => bc.BlogId.Equals(blog.Id)).ToList();

Expand Down
10 changes: 5 additions & 5 deletions DAL/PluginManager.DAL.TextFiles/Providers/ClaimsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public AuthenticationProperties GetAuthenticationProperties()

public List<ClaimsIdentity> GetUserClaims(in long userId)
{
List<ClaimsIdentity> Result = new();
List<ClaimsIdentity> Result = [];

UserDataRow user = _users.Select(userId);
List<Claim> userClaims = new();
List<Claim> userClaims = [];


if (user == null)
Expand Down Expand Up @@ -115,7 +115,7 @@ public List<ClaimsIdentity> GetUserClaims(in long userId)

private void GetUserClaims(UserDataRow user, List<ClaimsIdentity> Result)
{
List<Claim> webClaims = new();
List<Claim> webClaims = [];

UserClaimsDataRow claims = _userClaims.Select().FirstOrDefault(uc => uc.UserId.Equals(user.Id));

Expand Down Expand Up @@ -157,7 +157,7 @@ public bool SetClaimsForUser(in long id, in List<string> claims)

public List<string> GetAllClaims()
{
List<string> Result = new();
List<string> Result = [];

foreach (IClaimsService claimsService in _pluginClassesService.GetPluginClasses<IClaimsService>())
{
Expand All @@ -173,7 +173,7 @@ public List<string> GetAllClaims()

public List<string> GetClaimsForUser(in long id)
{
List<string> Result = new();
List<string> Result = [];

UserDataRow user = _users.Select(id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public List<Country> GetVisibleCountries()

private static List<Country> ConvertTableCountriesToCountries(IReadOnlyList<CountryDataRow> tableCountries)
{
List<Country> Result = new();
List<Country> Result = [];

foreach (CountryDataRow tableCountry in tableCountries)
{
Expand Down
8 changes: 4 additions & 4 deletions DAL/PluginManager.DAL.TextFiles/Providers/DownloadProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public List<DownloadCategory> DownloadCategoriesGet(in long userId)

if (cacheItem == null)
{
List<DownloadCategory> result = new();
List<DownloadCategory> result = [];

long user = userId;

IEnumerable<DownloadCategoryDataRow> categories = _downloadCategoryData.Select().Where(dc => dc.UserId.Equals(user) || dc.UserId.Equals(0));

foreach (DownloadCategoryDataRow category in categories)
{
List<DownloadItem> downloads = new();
List<DownloadItem> downloads = [];

IEnumerable<DownloadItemsDataRow> items = _downloadItemData.Select().Where(di => di.CategoryId.Equals(category.Id) && (di.UserId.Equals(0) || di.UserId.Equals(user)));

Expand All @@ -103,13 +103,13 @@ public List<DownloadCategory> DownloadCategoriesGet()

if (cacheItem == null)
{
List<DownloadCategory> result = new();
List<DownloadCategory> result = [];

IEnumerable<DownloadCategoryDataRow> categories = _downloadCategoryData.Select().Where(dc => dc.UserId.Equals(0));

foreach (DownloadCategoryDataRow category in categories)
{
List<DownloadItem> downloads = new();
List<DownloadItem> downloads = [];

IEnumerable<DownloadItemsDataRow> items = _downloadItemData.Select().Where(di => di.CategoryId.Equals(category.Id) && di.UserId.Equals(0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public long CreateCustomPage()

public List<LookupListItem> GetCustomPageList()
{
List<LookupListItem> Result = new();
List<LookupListItem> Result = [];

IReadOnlyList<ContentPageDataRow> pages = _pageData.Select();

Expand All @@ -88,7 +88,7 @@ public List<LookupListItem> GetCustomPageList()

public List<IDynamicContentPage> GetCustomPages()
{
List<IDynamicContentPage> Result = new();
List<IDynamicContentPage> Result = [];

IReadOnlyList<ContentPageDataRow> pages = _pageData.Select();

Expand Down
19 changes: 9 additions & 10 deletions DAL/PluginManager.DAL.TextFiles/Providers/HelpdeskProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public List<Feedback> GetFeedback(in bool publiclyVisible)
else
allFeedback = _feedbackDataRow.Select().ToList();

List<Feedback> Result = new();
List<Feedback> Result = [];

allFeedback.ForEach(f => Result.Add(new Feedback(f.Id, f.UserName, f.Message, f.ShowOnWebsite)));

Expand Down Expand Up @@ -142,7 +142,7 @@ public List<LookupListItem> GetTicketDepartments()

if (cacheItem == null)
{
List<LookupListItem> Result = new();
List<LookupListItem> Result = [];

List<TicketDepartmentsDataRow> departments = _ticketDepartments.Select().ToList();

Expand All @@ -160,7 +160,7 @@ public List<LookupListItem> GetTicketPriorities()

if (cacheItem == null)
{
List<LookupListItem> Result = new();
List<LookupListItem> Result = [];

List<TicketPrioritiesDataRow> departments = _ticketPriority.Select().ToList();

Expand All @@ -178,7 +178,7 @@ public List<LookupListItem> GetTicketStatus()

if (cacheItem == null)
{
List<LookupListItem> Result = new();
List<LookupListItem> Result = [];

List<TicketStatusDataRow> departments = _ticketStatus.Select().ToList();

Expand Down Expand Up @@ -263,10 +263,9 @@ public bool SubmitTicket(in long userId, in int department, in int priority,
userName,
email,
userName,
new List<HelpdeskTicketMessage>()
{
[
new(DateTime.Now, userName, message)
});
]);

return true;
}
Expand Down Expand Up @@ -421,7 +420,7 @@ public void KnowledgebaseView(in KnowledgeBaseItem item)

private List<KnowledgeBaseGroup> ConvertFaqDataListToKbGroupList(IEnumerable<FaqDataRow> faqDataRow, KnowledgeBaseGroup parent)
{
List<KnowledgeBaseGroup> Result = new();
List<KnowledgeBaseGroup> Result = [];

foreach (FaqDataRow item in faqDataRow)
{
Expand All @@ -443,7 +442,7 @@ private KnowledgeBaseGroup ConvertFaqDataRowToKbGroup(FaqDataRow faqDataRow, Kno

private List<KnowledgeBaseItem> ConvertFaqItemDataToFaqItemList(FaqDataRow faqDataItem)
{
List<KnowledgeBaseItem> Result = new();
List<KnowledgeBaseItem> Result = [];

foreach (FaqItemDataRow item in _faqItemDataRow.Select().Where(i => i.ParentId.Equals(faqDataItem.Id)))
{
Expand All @@ -458,7 +457,7 @@ private HelpdeskTicket ConvertTicketDataRow(TicketDataRow ticketDataRow, List<Ti
if (ticketDataRow == null)
return null;

List<HelpdeskTicketMessage> messageList = new();
List<HelpdeskTicketMessage> messageList = [];

foreach (TicketMessageDataRow messageDataRow in messages)
messageList.Add(new HelpdeskTicketMessage(messageDataRow.Created, messageDataRow.UserName, messageDataRow.Message));
Expand Down
4 changes: 2 additions & 2 deletions DAL/PluginManager.DAL.TextFiles/Providers/LicenceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public LicenceProvider(ISimpleDBOperations<UserDataRow> users,

public List<LicenceType> LicenceTypesGet()
{
List<LicenceType> Result = new();
List<LicenceType> Result = [];
IReadOnlyList<LicenseTypeDataRow> licenseTypes = _licenseTypes.Select();

foreach (LicenseTypeDataRow row in licenseTypes)
Expand All @@ -74,7 +74,7 @@ public List<LicenceType> LicenceTypesGet()

public List<Licence> LicencesGet(in Int64 userId)
{
List<Licence> Result = new();
List<Licence> Result = [];

UserDataRow user = _users.Select(userId);

Expand Down
10 changes: 5 additions & 5 deletions DAL/PluginManager.DAL.TextFiles/Providers/ProductProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ public ProductGroup ProductGroupGet(in int id)

public int ProductCountForGroup(ProductGroup productGroup)
{
return _productData.Select(r => r.ProductGroupId.Equals(productGroup.Id)).Count();
return _productData.Select(r => r.ProductGroupId.Equals(productGroup.Id)).Count;
}

public List<ProductGroup> ProductGroupsGet()
{
IReadOnlyList<ProductGroupDataRow> allGroups = _productGroupsData.Select();

List<ProductGroup> Result = new();
List<ProductGroup> Result = [];

foreach (ProductGroupDataRow group in allGroups)
{
Expand Down Expand Up @@ -160,7 +160,7 @@ public List<Product> GetProducts(in int page, in int pageSize)

List<ProductDataRow> allProducts = _productData.Select().OrderBy(p => p.Name).ToList();

List<Product> Result = new();
List<Product> Result = [];

(int start, int end, bool isEmpty) = GetPageStartAndEnd(page, pageSize, allProducts.Count);

Expand All @@ -186,7 +186,7 @@ public List<Product> GetProducts(in ProductGroup productGroup, in int page, in i
int prodGroup = productGroup.Id;
List<ProductDataRow> allProducts = _productData.Select().Where(p => p.ProductGroupId.Equals(prodGroup)).OrderBy(p => p.Name).ToList();

List<Product> Result = new();
List<Product> Result = [];

(int start, int end, bool isEmpty) = GetPageStartAndEnd(page, pageSize, allProducts.Count);

Expand Down Expand Up @@ -298,7 +298,7 @@ private static Product ConvertProductDataRowToProduct(ProductDataRow product)
return null;

return new Product((int)product.Id, product.ProductGroupId, product.Name, product.Description, product.Features, product.VideoLink,
new string[] { "NoImage" }, product.RetailPrice, product.Sku, product.IsDownload, product.AllowBackorder, product.IsVisible);
["NoImage"], product.RetailPrice, product.Sku, product.IsDownload, product.AllowBackorder, product.IsVisible);
}

#endregion Private Members
Expand Down
10 changes: 5 additions & 5 deletions DAL/PluginManager.DAL.TextFiles/Providers/ResourceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public ResourceItem AddResourceItem(long categoryId, ResourceType resourceType,

public List<ResourceItem> RetrieveAllResourceItems()
{
List<ResourceItem> resources = new();
List<ResourceItem> resources = [];

foreach (ResourceItemDataRow resourceItemDataRow in _resourceItems.Select())
{
Expand Down Expand Up @@ -339,7 +339,7 @@ public List<ResourceItem> RetrieveUserBookmarks(long userId)
return ConvertResourceItemDataRowsToResourceItemList(resourceBookmarks);
}

return new List<ResourceItem>();
return [];
}

#region Private Methods
Expand All @@ -350,7 +350,7 @@ private static List<ResourceItem> ConvertResourceItemDataRowsToResourceItemList(
if (resourceItemList == null)
return null;

List<ResourceItem> result = new();
List<ResourceItem> result = [];

foreach (ResourceItemDataRow resourceItemDataRow in resourceItemList)
{
Expand Down Expand Up @@ -401,7 +401,7 @@ private ResourceCategory ConvertResourceCategoryDataRowToResourceCategory(Resour
if (resourceRow == null)
return null;

List<ResourceItem> resources = new();
List<ResourceItem> resources = [];

foreach (ResourceItemDataRow resourceItemDataRow in _resourceItems.Select(ri => ri.CategoryId.Equals(resourceRow.Id)))
{
Expand All @@ -427,7 +427,7 @@ private ResourceCategory ConvertResourceCategoryDataRowToResourceCategory(Resour

private static List<ResourceCategory> ConvertResourceDataRowsToResourceList(IReadOnlyList<ResourceCategoryDataRow> resources)
{
List<ResourceCategory> result = new();
List<ResourceCategory> result = [];

foreach (ResourceCategoryDataRow row in resources)
{
Expand Down
2 changes: 1 addition & 1 deletion DAL/PluginManager.DAL.TextFiles/Providers/SeoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public bool GetSeoDataForRoute(in string route, out string title,
title = String.Empty;
metaDescription = String.Empty;
author = String.Empty;
keywords = new();
keywords = [];
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private static List<T> CopySessionData<T, D>(IEnumerable<D> baseData, bool isBot
where T : SessionBaseData
where D : SessionStatsBaseData
{
List<T> Result = new();
List<T> Result = [];

foreach (SessionStatsBaseData data in baseData)
{
Expand Down Expand Up @@ -251,7 +251,7 @@ private static List<SessionUserAgent> AmalgamateSessionData(List<SessionYearly>
}

if (Result == null)
return new List<SessionUserAgent>();
return [];

return Result.OrderBy(o => o.IsBot).ThenByDescending(d => d.Count).ToList();
}
Expand Down
Loading

0 comments on commit de428db

Please sign in to comment.