Skip to content

Commit

Permalink
analizators/U2U1202
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Jan 18, 2022
1 parent 36c26bc commit 84638fe
Show file tree
Hide file tree
Showing 34 changed files with 56 additions and 58 deletions.
4 changes: 2 additions & 2 deletions common/ASC.Api.Core/Model/EmployeeWraperFull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public EmployeeWraperFull GetFull(UserInfo userInfo)
{
var listAdminModules = userInfo.GetListAdminModules(WebItemSecurity);

if (listAdminModules.Any())
if (listAdminModules.Count > 0)
result.ListAdminModules = listAdminModules;
}

Expand All @@ -283,7 +283,7 @@ private void FillConacts(EmployeeWraperFull employeeWraperFull, UserInfo userInf
}
}

if (contacts.Any())
if (contacts.Count > 0)
{
employeeWraperFull.Contacts = contacts;
}
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Common/Utils/DnsLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public bool IsDomainExists(string domainName)

var dnsMessage = GetDnsMessage(domainName);

return dnsMessage.AnswerRecords.Any();
return dnsMessage.AnswerRecords.Count != 0;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/Billing/License/LicenseReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private DateTime Validate(License license)
{
license.PortalCount = TenantManager.GetTenantQuota(Tenant.DEFAULT_TENANT).CountPortals;
}
var activePortals = TenantManager.GetTenants().Count();
var activePortals = TenantManager.GetTenants().Count;
if (activePortals > 1 && license.PortalCount < activePortals)
{
throw new LicensePortalException("License portal count", license.OriginalLicense);
Expand Down
6 changes: 3 additions & 3 deletions common/ASC.Core.Common/Billing/TariffService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,10 @@ private bool SaveBillingInfo(int tenant, Tariff tariffInfo, bool renewal = true)
using var tx = CoreDbContext.Database.BeginTransaction();

// last record is not the same
var count = CoreDbContext.Tariffs
.Count(r => r.Tenant == tenant && r.Tariff == tariffInfo.QuotaId && r.Stamp == tariffInfo.DueDate && r.Quantity == tariffInfo.Quantity);
var any = CoreDbContext.Tariffs
.Any(r => r.Tenant == tenant && r.Tariff == tariffInfo.QuotaId && r.Stamp == tariffInfo.DueDate && r.Quantity == tariffInfo.Quantity);

if (tariffInfo.DueDate == DateTime.MaxValue || renewal || count == 0)
if (tariffInfo.DueDate == DateTime.MaxValue || renewal || any)
{
var efTariff = new DbTariff
{
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.Core.Common/Configuration/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private Dictionary<string, string> AllProps

public bool IsSet
{
get { return Props.Any() && !Props.All(r => string.IsNullOrEmpty(this[r.Key])); }
get { return Props.Count > 0 && !Props.All(r => string.IsNullOrEmpty(this[r.Key])); }
}

static Consumer()
Expand Down Expand Up @@ -152,7 +152,7 @@ public Consumer(
Props = props ?? new Dictionary<string, string>();
Additional = additional ?? new Dictionary<string, string>();

if (props != null && props.Any())
if (props != null && props.Count > 0)
{
CanSet = props.All(r => string.IsNullOrEmpty(r.Value));
}
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/Core/DBResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static void PatchAssembly(IOptionsMonitor<ILog> option, Assembly a, bool
private static bool Accept(Assembly a)
{
var n = a.GetName().Name;
return (n.StartsWith("ASC.") || n.StartsWith("App_GlobalResources")) && a.GetManifestResourceNames().Any();
return (n.StartsWith("ASC.") || n.StartsWith("App_GlobalResources")) && a.GetManifestResourceNames().Length > 0;
}


Expand Down
6 changes: 2 additions & 4 deletions common/ASC.Core.Common/Data/DbAzService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,13 @@ public void RemoveAce(int tenant, AzRecord r)

private bool ExistEscapeRecord(AzRecord r)
{
var count = UserDbContext.Acl
return UserDbContext.Acl
.Where(a => a.Tenant == Tenant.DEFAULT_TENANT)
.Where(a => a.Subject == r.SubjectId)
.Where(a => a.Action == r.ActionId)
.Where(a => a.Object == (r.ObjectId ?? string.Empty))
.Where(a => a.AceType == r.Reaction)
.Count();

return count != 0;
.Any();
}

private void DeleteRecord(AzRecord r)
Expand Down
6 changes: 3 additions & 3 deletions common/ASC.Core.Common/Data/DbTenantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ private void ValidateDomain(string domain, int tenantId, bool validateCharacters
}
if (!exists)
{
exists = 0 < TenantDbContext.Tenants.Where(r => r.Alias == domain && r.Id != tenantId).Count();
exists = TenantDbContext.Tenants.Where(r => r.Alias == domain && r.Id != tenantId).Any();
}
if (!exists)
{
exists = 0 < TenantDbContext.Tenants
exists = TenantDbContext.Tenants
.Where(r => r.MappedDomain == domain && r.Id != tenantId && !(r.Status == TenantStatus.RemovePending || r.Status == TenantStatus.Restoring))
.Count();
.Any();
}
if (exists)
{
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Data.Storage/Encryption/EncryptionOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private IEnumerable<string> GetFiles(List<string> domains, List<string> progress
{
IEnumerable<string> files = targetStore.ListFilesRelative(targetDomain, "\\", "*.*", true);

if (progress.Any())
if (progress.Count > 0)
{
files = files.Where(path => !progress.Contains(path));
}
Expand Down
8 changes: 4 additions & 4 deletions common/ASC.Data.Storage/GoogleCloud/GoogleCloudStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public override void DeleteFiles(string domain, string folderPath, string patter

public override void DeleteFiles(string domain, List<string> paths)
{
if (!paths.Any()) return;
if (paths.Count == 0) return;

var keysToDel = new List<string>();

Expand All @@ -416,7 +416,7 @@ public override void DeleteFiles(string domain, List<string> paths)
}
}

if (!keysToDel.Any()) return;
if (keysToDel.Count == 0) return;

using var storage = GetStorage();

Expand Down Expand Up @@ -521,7 +521,7 @@ public override bool IsFile(string domain, string path)

var objects = storage.ListObjects(_bucket, MakePath(domain, path), null);

return objects.Count() > 0;
return objects.Any();
}

public override async Task<bool> IsFileAsync(string domain, string path)
Expand All @@ -530,7 +530,7 @@ public override async Task<bool> IsFileAsync(string domain, string path)

var objects = await storage.ListObjectsAsync(_bucket, MakePath(domain, path)).ReadPageAsync(1);

return objects.Count() > 0;
return objects.Any();
}

public override bool IsDirectory(string domain, string path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public override void DeleteFiles(string domain, string folderPath, string patter

public override void DeleteFiles(string domain, List<string> paths)
{
if (!paths.Any()) return;
if (paths.Count == 0) return;

var keysToDel = new List<string>();

Expand All @@ -444,7 +444,7 @@ public override void DeleteFiles(string domain, List<string> paths)
}
}

if (!keysToDel.Any()) return;
if (keysToDel.Count == 0) return;

var client = GetClient();

Expand Down Expand Up @@ -537,7 +537,7 @@ public override bool IsFile(string domain, string path)
var client = GetClient();
var objects = client.ListObjects(_private_container, null, null, null, MakePath(domain, path), _region);

return objects.Count() > 0;
return objects.Any();
}

public override Task<bool> IsFileAsync(string domain, string path)
Expand Down
6 changes: 3 additions & 3 deletions common/ASC.Data.Storage/S3/S3Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private void InvalidateCloudFront(params string[] paths)
Paths = new Paths
{
Items = paths.ToList(),
Quantity = paths.Count()
Quantity = paths.Length
}
}
};
Expand Down Expand Up @@ -472,7 +472,7 @@ public override void Delete(string domain, string path)

public override void DeleteFiles(string domain, List<string> paths)
{
if (!paths.Any()) return;
if (paths.Count == 0) return;

var keysToDel = new List<string>();

Expand Down Expand Up @@ -501,7 +501,7 @@ public override void DeleteFiles(string domain, List<string> paths)
}
}

if (!keysToDel.Any())
if (keysToDel.Count == 0)
return;

using (var client = GetClient())
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Data.Storage/WebPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public string GetPath(HttpContext httpContext, IOptionsMonitor<ILog> options, st
if (Appenders.Any())
{
var avaliableAppenders = Appenders.Where(x => x.Extensions != null && x.Extensions.Split('|').Contains(ext) || string.IsNullOrEmpty(ext)).ToList();
var avaliableAppendersCount = avaliableAppenders.LongCount();
var avaliableAppendersCount = avaliableAppenders.Count;

Appender appender;
if (avaliableAppendersCount > 1)
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.FederatedLogin/Helpers/OAuth20TokenHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public OAuth20TokenHelper(IHttpContextAccessor httpContextAccessor, ConsumerFact

var stateUriBuilder = new UriBuilder(u.Scheme, u.Host, u.Port, $"thirdparty/{loginProvider.Name.ToLower()}/code");

if (additionalStateArgs != null && additionalStateArgs.Any())
if (additionalStateArgs != null && additionalStateArgs.Count > 0)
{
var stateQuery = "";
stateQuery = additionalStateArgs.Keys
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Feed/Data/FeedAggregateDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void SaveFeeds(IEnumerable<FeedRow> feeds, string key, DateTime value)
SaveFeedsPortion(feedsPortion, aggregatedDate);
feedsPortion.Clear();
}
if (feedsPortion.Any())
if (feedsPortion.Count > 0)
{
SaveFeedsPortion(feedsPortion, aggregatedDate);
}
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.IPSecurity/IPSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public bool Verify()
{
var restrictions = IPRestrictionsService.Get(tenant.TenantId).ToList();

if (!restrictions.Any()) return true;
if (restrictions.Count == 0) return true;

if (string.IsNullOrWhiteSpace(requestIps = CurrentIpForTest))
{
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.MessagingSystem/DbSender/MessagesRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static void AddLoginEvent(EventMessage message, MessagesContext dbContex
Action = (int)message.Action
};

if (message.Description != null && message.Description.Any())
if (message.Description != null && message.Description.Count > 0)
{
le.Description =
JsonConvert.SerializeObject(message.Description, new JsonSerializerSettings
Expand Down Expand Up @@ -210,7 +210,7 @@ private static void AddAuditEvent(EventMessage message, Messages dbContext)
Target = message.Target?.ToString()
};

if (message.Description != null && message.Description.Any())
if (message.Description != null && message.Description.Count > 0)
{
ae.Description =
JsonConvert.SerializeObject(GetSafeDescription(message.Description), new JsonSerializerSettings
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.MessagingSystem/MessageTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public MessageTarget Parse(string value)

var items = value.Split(',');

if (!items.Any()) return null;
if (items.Count == 0) return null;

return new MessageTarget(Option)
{
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.VoipService/Dao/CachedVoipDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public override IEnumerable<VoipPhone> GetNumbers(params string[] ids)
cache.Insert(GetCacheKey(TenantID), numbers, DateTime.UtcNow.Add(timeout));
}

return ids.Any() ? numbers.Where(r => ids.Contains(r.Id) || ids.Contains(r.Number)).ToList() : numbers;
return ids.Length > 0 ? numbers.Where(r => ids.Contains(r.Id) || ids.Contains(r.Number)).ToList() : numbers;
}

public static string GetCacheKey(int tenant)
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.VoipService/Dao/VoipDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public virtual IEnumerable<VoipPhone> GetNumbers(params string[] ids)
{
var numbers = VoipDbContext.VoipNumbers.Where(r => r.TenantId == TenantID);

if (ids.Any())
if (ids.Length > 0)
{
numbers = numbers.Where(r => ids.Any(a => a == r.Number || a == r.Id));
}
Expand Down
4 changes: 2 additions & 2 deletions common/services/ASC.AuditTrail/Mappers/AuditActionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public string GetActionText(AuditEvent evt)
{
var actionText = Actions[(MessageAction)evt.Action].GetActionText();

if (evt.Description == null || !evt.Description.Any()) return actionText;
if (evt.Description == null || evt.Description.Count > 0) return actionText;

var description = evt.Description
.Select(t => t.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
Expand Down Expand Up @@ -100,7 +100,7 @@ public string GetActionText(LoginEvent evt)
{
var actionText = Actions[(MessageAction)evt.Action].GetActionText();

if (evt.Description == null || !evt.Description.Any()) return actionText;
if (evt.Description == null || evt.Description.Count > 0) return actionText;

var description = evt.Description
.Select(t => t.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
Expand Down
4 changes: 2 additions & 2 deletions common/services/ASC.ClearEvents/ClearEventsServiceLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ private void GetOldEvents<T>(Expression<Func<Messages, DbSet<T>>> func, string s

ids = ae.Select(r => r.ef).ToList();

if (!ids.Any()) return;
if (ids.Count == 0) return;

table.RemoveRange(ids);
ef.SaveChanges();

} while (ids.Any());
} while (ids.Count > 0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/services/ASC.Data.Backup/BackupCleanerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal void DeleteExpiredBackups(BackupCleanerService backupCleanerService)
if (schedule != null)
{
var scheduledBackupsToRemove = scheduledBackups.OrderByDescending(r => r.CreatedOn).Skip(schedule.BackupsStored).ToList();
if (scheduledBackupsToRemove.Any())
if (scheduledBackupsToRemove.Count > 0)
{
log.DebugFormat("only last {0} scheduled backup records are to keep for tenant {1} so {2} records must be removed", schedule.BackupsStored, schedule.TenantId, scheduledBackupsToRemove.Count);
backupsToRemove.AddRange(scheduledBackupsToRemove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void AggregateFeeds(object interval)
var toTime = DateTime.UtcNow;

var tenants = Attempt(10, () => module.GetTenantsWithFeeds(fromTime)).ToList();
Log.DebugFormat("Find {1} tenants for module {0}.", module.GetType().Name, tenants.Count());
Log.DebugFormat("Find {1} tenants for module {0}.", module.GetType().Name, tenants.Count);

foreach (var tenant in tenants)
{
Expand Down
4 changes: 2 additions & 2 deletions common/services/ASC.TelegramService/Core/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ private object[] ParseParams(MethodInfo cmd, string[] args)

var cmdArgs = cmd.GetParameters();

if (cmdArgs.Any() && args == null || cmdArgs.Count() != args.Count()) throw new Exception("Wrong parameters count");
for (var i = 0; i < cmdArgs.Count(); i++)
if (cmdArgs.Length > 0 && args == null || cmdArgs.Length != args.Length) throw new Exception("Wrong parameters count");
for (var i = 0; i < cmdArgs.Length; i++)
{
var type = cmdArgs[i].ParameterType;

Expand Down
4 changes: 2 additions & 2 deletions products/ASC.Files/Core/Model/Binders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
var defaultBindingContext = bindingContext as DefaultModelBindingContext;
var composite = bindingContext.ValueProvider as CompositeValueProvider;

if (defaultBindingContext != null && composite != null && !composite.Any())
if (defaultBindingContext != null && composite != null && composite.Count == 0)
{
bindingContext.ValueProvider = defaultBindingContext.OriginalValueProvider;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
var defaultBindingContext = bindingContext as DefaultModelBindingContext;
var composite = bindingContext.ValueProvider as CompositeValueProvider;

if (defaultBindingContext != null && composite != null && !composite.Any())
if (defaultBindingContext != null && composite != null && composite.Count == 0)
{
bindingContext.ValueProvider = defaultBindingContext.OriginalValueProvider;
}
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Server/Controllers/FilesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public IEnumerable<FolderContentWrapper<int>> GetRootFolders(Guid userIdOrGroupI

if (!IsVisitor
&& !withoutAdditionalFolder
&& FileUtility.ExtsWebTemplate.Any()
&& FileUtility.ExtsWebTemplate.Count > 0
&& FilesSettingsHelper.TemplatesSection)
{
result.Add(GlobalFolderHelper.FolderTemplates);
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.Files/Service/Core/FilesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override bool VisibleFor(Feed.Aggregator.Feed feed, object data, Guid use

var owner = (Guid)feed.Target;
var groupUsers = UserManager.GetUsersByGroup(owner).Select(x => x.ID).ToList();
if (!groupUsers.Any())
if (groupUsers.Count == 0)
{
groupUsers.Add(owner);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ private bool IsTarget(object target, Guid userId)
if (target == null) return true;
var owner = (Guid)target;
var groupUsers = UserManager.GetUsersByGroup(owner).Select(x => x.ID).ToList();
if (!groupUsers.Any())
if (groupUsers.Count == 0)
{
groupUsers.Add(owner);
}
Expand Down
Loading

0 comments on commit 84638fe

Please sign in to comment.