From 20b60958a831be779b86d98c8618a2fd22ed5768 Mon Sep 17 00:00:00 2001 From: SuhorukovAnton Date: Wed, 19 Jan 2022 13:24:11 +0300 Subject: [PATCH] analizators/U2U1022 --- .../Caching/CachedTenantService.cs | 5 ++-- .../Context/Impl/SubscriptionManager.cs | 2 +- common/ASC.Core.Common/Core/UserInfo.cs | 2 +- common/ASC.Core.Common/Data/DbUserService.cs | 2 +- .../Notify/Engine/NotifyEngine.cs | 6 ++--- .../Notify/Patterns/PatternFormatter.cs | 2 +- .../Notify/RecipientProviderImpl.cs | 2 +- .../Notify/TopSubscriptionProvider.cs | 6 ++--- common/ASC.Core.Common/Tenants/TenantQuota.cs | 2 +- .../DiscStorage/DiscDataStore.cs | 4 +-- common/ASC.Data.Storage/StorageHandler.cs | 2 +- common/ASC.IPSecurity/IPSecurity.cs | 2 +- common/ASC.MessagingSystem/MessagePolicy.cs | 2 +- .../Sharpbox/SharpBoxProviderInfo.cs | 2 +- .../Core/Helpers/ThirdpartyConfiguration.cs | 2 +- .../Core/Services/FFmpegService/FFmpeg.cs | 2 +- web/ASC.Web.Core/Files/FileUtility.cs | 26 +++++++++---------- .../Notify/StudioWhatsNewNotify.cs | 6 ++--- .../Users/Import/TextFileUserImporter.cs | 2 +- 19 files changed, 40 insertions(+), 39 deletions(-) diff --git a/common/ASC.Core.Common/Caching/CachedTenantService.cs b/common/ASC.Core.Common/Caching/CachedTenantService.cs index 04fc243e34b..8981515906f 100644 --- a/common/ASC.Core.Common/Caching/CachedTenantService.cs +++ b/common/ASC.Core.Common/Caching/CachedTenantService.cs @@ -294,8 +294,9 @@ public byte[] GetTenantSettings(int tenant, string key) var data = cache.Get(cacheKey); if (data == null) { - data = Service.GetTenantSettings(tenant, key); - cache.Insert(cacheKey, data ?? new byte[0], DateTime.UtcNow + SettingsExpiration); + data = Service.GetTenantSettings(tenant, key); + + cache.Insert(cacheKey, data ?? Array.Empty(), DateTime.UtcNow + SettingsExpiration); } return data == null ? null : data.Length == 0 ? null : data; } diff --git a/common/ASC.Core.Common/Context/Impl/SubscriptionManager.cs b/common/ASC.Core.Common/Context/Impl/SubscriptionManager.cs index c2a048e8929..5a8d54f609d 100644 --- a/common/ASC.Core.Common/Context/Impl/SubscriptionManager.cs +++ b/common/ASC.Core.Common/Context/Impl/SubscriptionManager.cs @@ -117,7 +117,7 @@ public string[] GetSubscriptionMethod(string sourceID, string actionID, string r m = methods.FirstOrDefault(); } - return m != null ? m.Methods : new string[0]; + return m != null ? m.Methods : Array.Empty(); } public string[] GetRecipients(string sourceID, string actionID, string objectID) diff --git a/common/ASC.Core.Common/Core/UserInfo.cs b/common/ASC.Core.Common/Core/UserInfo.cs index d13357cdf64..f7dde013082 100644 --- a/common/ASC.Core.Common/Core/UserInfo.cs +++ b/common/ASC.Core.Common/Core/UserInfo.cs @@ -138,7 +138,7 @@ public CultureInfo GetCulture() string[] IDirectRecipient.Addresses { - get { return !string.IsNullOrEmpty(Email) ? new[] { Email } : new string[0]; } + get { return !string.IsNullOrEmpty(Email) ? new[] { Email } : Array.Empty(); } } public bool CheckActivation diff --git a/common/ASC.Core.Common/Data/DbUserService.cs b/common/ASC.Core.Common/Data/DbUserService.cs index 8b4bf71903e..2416310efa9 100644 --- a/common/ASC.Core.Common/Data/DbUserService.cs +++ b/common/ASC.Core.Common/Data/DbUserService.cs @@ -365,7 +365,7 @@ public byte[] GetUserPhoto(int tenant, Guid id) .Select(r => r.Photo) .FirstOrDefault(); - return photo ?? new byte[0]; + return photo ?? Array.Empty(); } public IEnumerable GetUsers(int tenant) diff --git a/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs b/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs index c5074392dce..b8cb130cd86 100644 --- a/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs +++ b/common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs @@ -507,7 +507,7 @@ private void PrepareRequestFillSenders(NotifyRequest request, IServiceScope serv var subscriptionProvider = request.GetSubscriptionProvider(serviceScope); var senderNames = new List(); - senderNames.AddRange(subscriptionProvider.GetSubscriptionMethod(request.NotifyAction, request.Recipient) ?? new string[0]); + senderNames.AddRange(subscriptionProvider.GetSubscriptionMethod(request.NotifyAction, request.Recipient) ?? Array.Empty()); senderNames.AddRange(request.Arguments.OfType().Select(tag => (string)tag.Value)); request.SenderNames = senderNames.ToArray(); @@ -554,12 +554,12 @@ private void PrepareRequestFillTags(NotifyRequest request, IServiceScope service { throw new NotifyException(string.Format("For pattern \"{0}\" formatter not instanced.", pattern), exc); } - var tags = new string[0]; + var tags = Array.Empty(); try { if (formatter != null) { - tags = formatter.GetTags(pattern) ?? new string[0]; + tags = formatter.GetTags(pattern) ?? Array.Empty(); } } catch (Exception exc) diff --git a/common/ASC.Core.Common/Notify/Patterns/PatternFormatter.cs b/common/ASC.Core.Common/Notify/Patterns/PatternFormatter.cs index 7722248520e..40a0d196a69 100644 --- a/common/ASC.Core.Common/Notify/Patterns/PatternFormatter.cs +++ b/common/ASC.Core.Common/Notify/Patterns/PatternFormatter.cs @@ -98,7 +98,7 @@ protected virtual void AfterFormat(INoticeMessage message) protected virtual string[] SearchTags(string text) { - if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(tagSearchPattern)) return new string[0]; + if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(tagSearchPattern)) return Array.Empty(); var maches = RegEx.Matches(text); var findedTags = new List(maches.Count); diff --git a/common/ASC.Core.Common/Notify/RecipientProviderImpl.cs b/common/ASC.Core.Common/Notify/RecipientProviderImpl.cs index d86468d01eb..e57bbbd7ee8 100644 --- a/common/ASC.Core.Common/Notify/RecipientProviderImpl.cs +++ b/common/ASC.Core.Common/Notify/RecipientProviderImpl.cs @@ -111,7 +111,7 @@ public virtual string[] GetRecipientAddresses(IDirectRecipient recipient, string if (senderName == ASC.Core.Configuration.Constants.NotifyTelegramSenderSysName) return new[] { user.ID.ToString() }; } } - return new string[0]; + return Array.Empty(); } /// diff --git a/common/ASC.Core.Common/Notify/TopSubscriptionProvider.cs b/common/ASC.Core.Common/Notify/TopSubscriptionProvider.cs index 1d8c92f0cb1..01351c226d8 100644 --- a/common/ASC.Core.Common/Notify/TopSubscriptionProvider.cs +++ b/common/ASC.Core.Common/Notify/TopSubscriptionProvider.cs @@ -34,7 +34,7 @@ namespace ASC.Notify.Model { public class TopSubscriptionProvider : ISubscriptionProvider { - private readonly string[] defaultSenderMethods = new string[0]; + private readonly string[] defaultSenderMethods = Array.Empty(); private readonly ISubscriptionProvider subscriptionProvider; private readonly IRecipientProvider recipientProvider; @@ -165,12 +165,12 @@ public virtual string[] GetSubscriptions(INotifyAction action, IRecipient recipi if (action == null) throw new ArgumentNullException("action"); var objects = new List(); - var direct = subscriptionProvider.GetSubscriptions(action, recipient, checkSubscription) ?? new string[0]; + var direct = subscriptionProvider.GetSubscriptions(action, recipient, checkSubscription) ?? Array.Empty(); MergeObjects(objects, direct); var parents = WalkUp(recipient); foreach (var parent in parents) { - direct = subscriptionProvider.GetSubscriptions(action, parent, checkSubscription) ?? new string[0]; + direct = subscriptionProvider.GetSubscriptions(action, parent, checkSubscription) ?? Array.Empty(); if (recipient is IDirectRecipient) { foreach (var groupsubscr in direct) diff --git a/common/ASC.Core.Common/Tenants/TenantQuota.cs b/common/ASC.Core.Common/Tenants/TenantQuota.cs index 32b0778d96d..a6b3a2070b2 100644 --- a/common/ASC.Core.Common/Tenants/TenantQuota.cs +++ b/common/ASC.Core.Common/Tenants/TenantQuota.cs @@ -307,7 +307,7 @@ public bool GetFeature(string feature) internal void SetFeature(string feature, bool set) { var features = (Features == null - ? new string[] { } + ? Array.Empty() : Features.Split(' ', ',', ';')).ToList(); if (set && !features.Contains(feature)) { diff --git a/common/ASC.Data.Storage/DiscStorage/DiscDataStore.cs b/common/ASC.Data.Storage/DiscStorage/DiscDataStore.cs index 45f667da44c..6bce910864c 100644 --- a/common/ASC.Data.Storage/DiscStorage/DiscDataStore.cs +++ b/common/ASC.Data.Storage/DiscStorage/DiscDataStore.cs @@ -543,7 +543,7 @@ public override string[] ListDirectoriesRelative(string domain, string path, boo entries, x => x.Substring(targetDir.Length)); } - return new string[0]; + return Array.Empty(); } public override string[] ListFilesRelative(string domain, string path, string pattern, bool recursive) @@ -560,7 +560,7 @@ public override string[] ListFilesRelative(string domain, string path, string pa entries, x => x.Substring(targetDir.Length)); } - return new string[0]; + return Array.Empty(); } public override bool IsFile(string domain, string path) diff --git a/common/ASC.Data.Storage/StorageHandler.cs b/common/ASC.Data.Storage/StorageHandler.cs index 6a26f7c3e89..280e6597f4f 100644 --- a/common/ASC.Data.Storage/StorageHandler.cs +++ b/common/ASC.Data.Storage/StorageHandler.cs @@ -102,7 +102,7 @@ public Task Invoke(HttpContext context) return Task.CompletedTask; } - var headers = header.Length > 0 ? header.Split('&').Select(HttpUtility.UrlDecode) : new string[] { }; + var headers = header.Length > 0 ? header.Split('&').Select(HttpUtility.UrlDecode) : Array.Empty(); if (storage.IsSupportInternalUri) { diff --git a/common/ASC.IPSecurity/IPSecurity.cs b/common/ASC.IPSecurity/IPSecurity.cs index a4e7de46f6e..aedd7234668 100644 --- a/common/ASC.IPSecurity/IPSecurity.cs +++ b/common/ASC.IPSecurity/IPSecurity.cs @@ -101,7 +101,7 @@ public bool Verify() } var ips = string.IsNullOrWhiteSpace(requestIps) - ? new string[] { } + ? Array.Empty() : requestIps.Split(new[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries); if (ips.Any(requestIp => restrictions.Any(restriction => MatchIPs(GetIpWithoutPort(requestIp), restriction.Ip)))) diff --git a/common/ASC.MessagingSystem/MessagePolicy.cs b/common/ASC.MessagingSystem/MessagePolicy.cs index 5ea1803eeb8..8637aa30aa5 100644 --- a/common/ASC.MessagingSystem/MessagePolicy.cs +++ b/common/ASC.MessagingSystem/MessagePolicy.cs @@ -43,7 +43,7 @@ public MessagePolicy(IConfiguration configuration) { secretIps = configuration["messaging.secret-ips"] == null - ? new string[] { } + ? Array.Empty() : configuration["messaging.secret-ips"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } diff --git a/products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxProviderInfo.cs b/products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxProviderInfo.cs index b8f1a4b192e..6234ca6a489 100644 --- a/products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxProviderInfo.cs +++ b/products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxProviderInfo.cs @@ -141,7 +141,7 @@ public SharpBoxStorageDisposableWrapper() internal CloudStorage CreateStorage(AuthData _authData, nSupportedCloudConfigurations _providerKey) { - var prms = new object[] { }; + var prms = Array.Empty(); if (!string.IsNullOrEmpty(_authData.Url)) { var uri = _authData.Url; diff --git a/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs b/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs index 201f6639507..741ed1b3d06 100644 --- a/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs +++ b/products/ASC.Files/Core/Helpers/ThirdpartyConfiguration.cs @@ -47,7 +47,7 @@ public List ThirdPartyProviders { get { - return thirdPartyProviders ??= (Configuration.GetSection("files:thirdparty:enable").Get() ?? new string[] { }).ToList(); + return thirdPartyProviders ??= (Configuration.GetSection("files:thirdparty:enable").Get() ?? Array.Empty()).ToList(); } } public ThirdpartyConfigurationData(IConfiguration configuration) diff --git a/products/ASC.Files/Core/Services/FFmpegService/FFmpeg.cs b/products/ASC.Files/Core/Services/FFmpegService/FFmpeg.cs index 14686197a3d..a5672a9ee89 100644 --- a/products/ASC.Files/Core/Services/FFmpegService/FFmpeg.cs +++ b/products/ASC.Files/Core/Services/FFmpegService/FFmpeg.cs @@ -64,7 +64,7 @@ public FFmpegService(IOptionsMonitor optionsMonitor, IConfiguration config FFmpegPath = configuration["files:ffmpeg:value"]; FFmpegArgs = configuration["files:ffmpeg:args"] ?? "-i - -preset ultrafast -movflags frag_keyframe+empty_moov -f {0} -"; - ConvertableMedia = (configuration.GetSection("files:ffmpeg:exts").Get() ?? new string[] { }).ToList(); + ConvertableMedia = (configuration.GetSection("files:ffmpeg:exts").Get() ?? Array.Empty()).ToList(); if (string.IsNullOrEmpty(FFmpegPath)) { diff --git a/web/ASC.Web.Core/Files/FileUtility.cs b/web/ASC.Web.Core/Files/FileUtility.cs index 06a680c24e1..39f569d493d 100644 --- a/web/ASC.Web.Core/Files/FileUtility.cs +++ b/web/ASC.Web.Core/Files/FileUtility.cs @@ -49,20 +49,20 @@ public FileUtilityConfiguration(IConfiguration configuration) } private List extsIndexing; - public List ExtsIndexing { get => extsIndexing ??= (Configuration.GetSection("files:index").Get() ?? new string[] { }).ToList(); } + public List ExtsIndexing { get => extsIndexing ??= (Configuration.GetSection("files:index").Get() ?? Array.Empty()).ToList(); } private List extsImagePreviewed; - public List ExtsImagePreviewed { get => extsImagePreviewed ??= (Configuration.GetSection("files:viewed-images").Get() ?? new string[] { }).ToList(); } + public List ExtsImagePreviewed { get => extsImagePreviewed ??= (Configuration.GetSection("files:viewed-images").Get() ?? Array.Empty()).ToList(); } private List extsMediaPreviewed; - public List ExtsMediaPreviewed { get => extsMediaPreviewed ??= (Configuration.GetSection("files:viewed-media").Get() ?? new string[] { }).ToList(); } + public List ExtsMediaPreviewed { get => extsMediaPreviewed ??= (Configuration.GetSection("files:viewed-media").Get() ?? Array.Empty()).ToList(); } private List extsWebPreviewed; public List ExtsWebPreviewed { get { - return extsWebPreviewed ??= (Configuration.GetSection("files:docservice:viewed-docs").Get() ?? new string[] { }).ToList(); + return extsWebPreviewed ??= (Configuration.GetSection("files:docservice:viewed-docs").Get() ?? Array.Empty()).ToList(); } } @@ -71,19 +71,19 @@ public List ExtsWebEdited { get { - return extsWebEdited ??= (Configuration.GetSection("files:docservice:edited-docs").Get() ?? new string[] { }).ToList(); + return extsWebEdited ??= (Configuration.GetSection("files:docservice:edited-docs").Get() ?? Array.Empty()).ToList(); } } private List extsWebEncrypt; - public List ExtsWebEncrypt { get => extsWebEncrypt ??= (Configuration.GetSection("files:docservice:encrypted-docs").Get() ?? new string[] { }).ToList(); } + public List ExtsWebEncrypt { get => extsWebEncrypt ??= (Configuration.GetSection("files:docservice:encrypted-docs").Get() ?? Array.Empty()).ToList(); } private List extsWebReviewed; public List ExtsWebReviewed { get { - return extsWebReviewed ??= (Configuration.GetSection("files:docservice:reviewed-docs").Get() ?? new string[] { }).ToList(); + return extsWebReviewed ??= (Configuration.GetSection("files:docservice:reviewed-docs").Get() ?? Array.Empty()).ToList(); } } @@ -92,7 +92,7 @@ public List ExtsWebCustomFilterEditing { get { - return extsWebCustomFilterEditing ??= (Configuration.GetSection("files:docservice:customfilter-docs").Get() ?? new string[] { }).ToList(); + return extsWebCustomFilterEditing ??= (Configuration.GetSection("files:docservice:customfilter-docs").Get() ?? Array.Empty()).ToList(); } } @@ -101,7 +101,7 @@ public List ExtsWebRestrictedEditing { get { - return extsWebRestrictedEditing ??= (Configuration.GetSection("files:docservice:formfilling-docs").Get() ?? new string[] { }).ToList(); + return extsWebRestrictedEditing ??= (Configuration.GetSection("files:docservice:formfilling-docs").Get() ?? Array.Empty()).ToList(); } } @@ -110,7 +110,7 @@ public List ExtsWebCommented { get { - return extsWebCommented ??= (Configuration.GetSection("files:docservice:commented-docs").Get() ?? new string[] { }).ToList(); + return extsWebCommented ??= (Configuration.GetSection("files:docservice:commented-docs").Get() ?? Array.Empty()).ToList(); } } @@ -119,7 +119,7 @@ public List ExtsWebTemplate { get { - return extsWebTemplate ??= (Configuration.GetSection("files:docservice:template-docs").Get() ?? new string[] { }).ToList(); + return extsWebTemplate ??= (Configuration.GetSection("files:docservice:template-docs").Get() ?? Array.Empty()).ToList(); } } @@ -128,14 +128,14 @@ public List ExtsMustConvert { get { - return extsMustConvert ??= (Configuration.GetSection("files:docservice:convert-docs").Get() ?? new string[] { }).ToList(); + return extsMustConvert ??= (Configuration.GetSection("files:docservice:convert-docs").Get() ?? Array.Empty()).ToList(); } } private List extsCoAuthoring; public List ExtsCoAuthoring { - get => extsCoAuthoring ??= (Configuration.GetSection("files:docservice:coauthor-docs").Get() ?? new string[] { }).ToList(); + get => extsCoAuthoring ??= (Configuration.GetSection("files:docservice:coauthor-docs").Get() ?? Array.Empty()).ToList(); } public Dictionary InternalExtension diff --git a/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs b/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs index 081862b2c97..bee1e9770d3 100644 --- a/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs +++ b/web/ASC.Web.Core/Notify/StudioWhatsNewNotify.cs @@ -142,7 +142,7 @@ public void SendMsgWhatsNew(DateTime scheduleDate) UserAbsoluteURL = f.Author != null && f.Author.UserInfo != null ? commonLinkUtility.GetFullAbsolutePath(f.Author.UserInfo.GetUserProfilePageURL(commonLinkUtility)) : string.Empty, Title = HtmlUtil.GetText(f.Title, 512), URL = commonLinkUtility.GetFullAbsolutePath(f.ItemUrl), - BreadCrumbs = new string[0], + BreadCrumbs = Array.Empty(), Action = GetWhatsNewActionText(f) }).ToList()); @@ -165,7 +165,7 @@ public void SendMsgWhatsNew(DateTime scheduleDate) UserAbsoluteURL = prawbc.Author != null && prawbc.Author.UserInfo != null ? commonLinkUtility.GetFullAbsolutePath(prawbc.Author.UserInfo.GetUserProfilePageURL(commonLinkUtility)) : string.Empty, Title = HtmlUtil.GetText(prawbc.Title, 512), URL = commonLinkUtility.GetFullAbsolutePath(prawbc.ItemUrl), - BreadCrumbs = new string[0], + BreadCrumbs = Array.Empty(), Action = GetWhatsNewActionText(prawbc) }); } @@ -185,7 +185,7 @@ public void SendMsgWhatsNew(DateTime scheduleDate) UserAbsoluteURL = ls.Author != null && ls.Author.UserInfo != null ? commonLinkUtility.GetFullAbsolutePath(ls.Author.UserInfo.GetUserProfilePageURL(commonLinkUtility)) : string.Empty, Title = HtmlUtil.GetText(ls.Title, 512), URL = commonLinkUtility.GetFullAbsolutePath(ls.ItemUrl), - BreadCrumbs = i == 0 ? new string[1] { gr.Key } : new string[0], + BreadCrumbs = i == 0 ? new string[1] { gr.Key } : Array.Empty(), Action = GetWhatsNewActionText(ls) }); } diff --git a/web/ASC.Web.Core/Users/Import/TextFileUserImporter.cs b/web/ASC.Web.Core/Users/Import/TextFileUserImporter.cs index 9e6634862a1..1f46253b113 100644 --- a/web/ASC.Web.Core/Users/Import/TextFileUserImporter.cs +++ b/web/ASC.Web.Core/Users/Import/TextFileUserImporter.cs @@ -115,7 +115,7 @@ private UserInfo GetExportedUser(string line, IDictionary map var value = ConvertFromString(dataFields[j], propinfo.PropertyType); if (value != null) { - propinfo.SetValue(exportedUser, value, new object[] { }); + propinfo.SetValue(exportedUser, value, Array.Empty()); } } }