Skip to content

Commit

Permalink
analizators/U2U1202
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Jan 19, 2022
1 parent 4b211c0 commit fbb50e6
Show file tree
Hide file tree
Showing 45 changed files with 84 additions and 84 deletions.
4 changes: 2 additions & 2 deletions common/ASC.Core.Common/Data/DbUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ private IQueryable<DbGroup> GetGroupQuery(int tenant)

q = q.Where(r => !r.Removed);

if (includeGroups != null && includeGroups.Any())
if (includeGroups != null && includeGroups.Count > 0)
{
Expression or = Expression.Empty();

Expand All @@ -711,7 +711,7 @@ private IQueryable<DbGroup> GetGroupQuery(int tenant)
}
}

if (excludeGroups != null && excludeGroups.Any())
if (excludeGroups != null && excludeGroups.Count > 0)
{
foreach (var eg in excludeGroups)
{
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/MultiRegionHostedSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public List<Tenant> FindTenants(string login, string password, string passwordHa
error = exception;
}
}
if (!result.Any() && error != null)
if (result.Count == 0 && error != null)
{
throw error;
}
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void NotifySender(object state)
NotifyRequest request = null;
lock (requests)
{
if (requests.Any())
if (requests.Count > 0)
{
request = requests.Dequeue();
}
Expand Down Expand Up @@ -425,7 +425,7 @@ private SendResponse CreateNoticeMessageFromNotifyRequest(NotifyRequest request,
var recipient = request.Recipient as IDirectRecipient;

var addresses = recipient.Addresses;
if (addresses == null || !addresses.Any())
if (addresses == null || addresses.Length == 0)
{
addresses = recipientProvider.GetRecipientAddresses(request.Recipient as IDirectRecipient, sender);
recipient = new DirectRecipient(request.Recipient.ID, request.Recipient.Name, addresses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static bool IsSubscribed(this ISubscriptionProvider provider, ILog log, I
if (subscriptionRecord != null)
{
var properties = subscriptionRecord.GetType().GetProperties();
if (properties.Any())
if (properties.Length > 0)
{
var property = properties.Single(p => p.Name == "Subscribed");
if (property != null)
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/Notify/RecipientProviderImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public IDirectRecipient FilterRecipientAddresses(IDirectRecipient recipient)
if (recipient.CheckActivation)
{
//It's direct email
if (recipient.Addresses != null && recipient.Addresses.Any())
if (recipient.Addresses != null && recipient.Addresses.Length > 0)
{
//Filtering only missing users and users who activated already
var filteredAddresses = from address in recipient.Addresses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public List<TelegramUser> GetUser(int telegramId)
if (users != null) return users;

users = TgDao.GetUser(telegramId);
if (users.Any()) Cache.Insert(key, users, Expiration);
if (users.Count > 0) Cache.Insert(key, users, Expiration);
return users;
}

Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Data.Backup.Core/Core/NotifyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private void MigrationNotify(Tenant tenant, INotifyAction action, string region,
.Where(u => notify ? u.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated) : u.IsOwner(tenant))
.ToArray();

if (users.Any())
if (users.Length > 0)
{
var args = CreateArgs(scope, region, url);
if (action == Actions.MigrationPortalSuccessV115)
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Data.Backup.Core/Tasks/BackupPortalTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private void SaveToFile(string path, string t, IReadOnlyCollection<string> colum
{
Logger.DebugFormat("save to file {0}", t);
List<object[]> portion;
while ((portion = data.Take(BatchLimit).ToList()).Any())
while ((portion = data.Take(BatchLimit).ToList()).Count > 0)
{
using (var sw = new StreamWriter(path, true))
using (var writer = new JsonTextWriter(sw))
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Data.Backup.Core/Tasks/Data/TableInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public bool HasIdColumn()

public bool HasDateColumns()
{
return DateColumns.Any();
return DateColumns.Count > 0;
}

public bool HasTenantColumn()
Expand Down
2 changes: 1 addition & 1 deletion common/services/ASC.ElasticSearch/Core/SearchSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void Set(List<SearchSettingsItem> items)
var settings = SettingsManager.Load<SearchSettings>();

var settingsItems = settings.Items;
var toReIndex = !settingsItems.Any() ? items.Where(r => r.Enabled).ToList() : items.Where(item => settingsItems.Any(r => r.ID == item.ID && r.Enabled != item.Enabled)).ToList();
var toReIndex = settingsItems.Count == 0 ? items.Where(r => r.Enabled).ToList() : items.Where(item => settingsItems.Any(r => r.ID == item.ID && r.Enabled != item.Enabled)).ToList();

settings.Items = items;
settings.Data = JsonConvert.SerializeObject(items);
Expand Down
4 changes: 2 additions & 2 deletions common/services/ASC.ElasticSearch/Engine/BaseIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ internal void Index(T data, bool immediately = true)

internal void Index(List<T> data, bool immediately = true)
{
if (!data.Any()) return;
if (data.Count == 0) return;

CreateIfNotExist(data[0]);

Expand Down Expand Up @@ -495,7 +495,7 @@ private IBulkIndexOperation<T> GetMeta(BulkIndexDescriptor<T> desc, T data)
{
var result = request.Index(IndexName);

if (fields.Any())
if (fields.Length > 0)
{
result.Script(GetScriptUpdateByQuery(data, fields));
}
Expand Down
4 changes: 2 additions & 2 deletions common/services/ASC.ElasticSearch/Engine/FactoryIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public bool Index(T data, bool immediately = true)
public void Index(List<T> data, bool immediately = true, int retry = 0)
{
var t = ServiceProvider.GetService<T>();
if (!Support(t) || !data.Any()) return;
if (!Support(t) || data.Count == 0) return;

try
{
Expand Down Expand Up @@ -276,7 +276,7 @@ public void Index(List<T> data, bool immediately = true, int retry = 0)
public Task IndexAsync(List<T> data, bool immediately = true, int retry = 0)
{
var t = ServiceProvider.GetService<T>();
if (!Support(t) || !data.Any()) return Task.CompletedTask;
if (!Support(t) || data.Count == 0) return Task.CompletedTask;

return InternalIndexAsync(data, immediately, retry);
}
Expand Down
2 changes: 1 addition & 1 deletion common/services/ASC.ElasticSearch/Service/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void ReIndex(List<string> toReIndex, int tenant)
tasks.Add(instance.ReIndex());
}

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

Task.WhenAll(tasks).ContinueWith(r =>
{
Expand Down
8 changes: 4 additions & 4 deletions products/ASC.Files/Core/Core/Dao/TeamlabDao/FileDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public File<int> SaveFile(File<int> file, Stream fileStream, bool checkQuota = t

parentFoldersIds = parentFolders.Select(r => r.ParentId).ToList();

if (parentFoldersIds.Any())
if (parentFoldersIds.Count == 0)
{
var folderToUpdate = FilesDbContext.Folders
.Where(r => parentFoldersIds.Contains(r.Id));
Expand Down Expand Up @@ -581,7 +581,7 @@ public File<int> ReplaceFileVersion(File<int> file, Stream fileStream)

parentFoldersIds = parentFolders.Select(r => r.ParentId).ToList();

if (parentFoldersIds.Any())
if (parentFoldersIds.Count > 0)
{
var folderToUpdate = FilesDbContext.Folders
.Where(r => parentFoldersIds.Contains(r.Id));
Expand Down Expand Up @@ -1268,14 +1268,14 @@ public IEnumerable<int> GetTenantsWithFeeds(DateTime fromTime)
var q1 = FilesDbContext.Files
.Where(r => r.ModifiedOn > fromTime)
.GroupBy(r => r.TenantId)
.Where(r => r.Count() > 0)
.Where(r => r.Any())
.Select(r => r.Key)
.ToList();

var q2 = FilesDbContext.Security
.Where(r => r.TimeStamp > fromTime)
.GroupBy(r => r.TenantId)
.Where(r => r.Count() > 0)
.Where(r => r.Any())
.Select(r => r.Key)
.ToList();

Expand Down
4 changes: 2 additions & 2 deletions products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,14 +1219,14 @@ public IEnumerable<int> GetTenantsWithFeedsForFolders(DateTime fromTime)
var q1 = FilesDbContext.Files
.Where(r => r.ModifiedOn > fromTime)
.GroupBy(r => r.TenantId)
.Where(r => r.Count() > 0)
.Where(r => r.Any())
.Select(r => r.Key)
.ToList();

var q2 = FilesDbContext.Security
.Where(r => r.TimeStamp > fromTime)
.GroupBy(r => r.TenantId)
.Where(r => r.Count() > 0)
.Where(r => r.Any())
.Select(r => r.Key)
.ToList();

Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private IEnumerable<FileShareRecord> GetPureShareRecordsDb(List<string> files, L

var q = GetQuery(r => folders.Contains(r.EntryId) && r.EntryType == FileEntryType.Folder);

if (files.Any())
if (files.Count > 0)
{
q = q.Union(GetQuery(r => files.Contains(r.EntryId) && r.EntryType == FileEntryType.File));
}
Expand Down
8 changes: 4 additions & 4 deletions products/ASC.Files/Core/Core/Dao/TeamlabDao/TagDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ private void RemoveTagInDb(Tag tag)
FilesDbContext.TagLink.RemoveRange(toDelete);
FilesDbContext.SaveChanges();

var count = Query(FilesDbContext.TagLink).Count(r => r.TagId == id);
if (count == 0)
var any = Query(FilesDbContext.TagLink).Any(r => r.TagId == id);
if (!any)
{
var tagToDelete = Query(FilesDbContext.Tag).Where(r => r.Id == id);
FilesDbContext.Tag.RemoveRange(tagToDelete);
Expand Down Expand Up @@ -479,7 +479,7 @@ public IEnumerable<Tag> GetNewTags(Guid subject, IEnumerable<FileEntry<T>> fileE
entryTypes.Add((int)entryType);
}

if (entryIds.Any())
if (entryIds.Count > 0)
{
var sqlQuery = Query(FilesDbContext.Tag)
.Join(FilesDbContext.TagLink, r => r.Id, l => l.TagId, (tag, link) => new TagLinkData { Tag = tag, Link = link })
Expand Down Expand Up @@ -751,7 +751,7 @@ public IEnumerable<Tag> GetNewTags(Guid subject, Folder<T> parentFolder, bool de
.Concat(folderIds.ConvertAll(r => $"onedrive-{r}"))
.ToList();

if (thirdpartyFolderIds.Any())
if (thirdpartyFolderIds.Count > 0)
{
result.AddRange(FromQuery(newTagsForSBoxQuery(FilesDbContext, tenantId, subject, thirdpartyFolderIds)));
}
Expand Down
14 changes: 7 additions & 7 deletions products/ASC.Files/Core/Core/FileStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public DataWrapper<T> GetFolderItems(T parentId, int from, int count, FilterType

var breadCrumbs = EntryManager.GetBreadCrumbs(parentId, folderDao);

var prevVisible = breadCrumbs.ElementAtOrDefault(breadCrumbs.Count() - 2);
var prevVisible = breadCrumbs.ElementAtOrDefault(breadCrumbs.Count - 2);
if (prevVisible != null)
{
if (prevVisible is Folder<string> f1) parent.FolderID = (T)Convert.ChangeType(f1.ID, typeof(T));
Expand Down Expand Up @@ -985,7 +985,7 @@ public File<T> LockFile(T fileId, bool lockfile)
}

var usersDrop = FileTracker.GetEditingBy(file.ID).Where(uid => uid != AuthContext.CurrentAccount.ID).Select(u => u.ToString()).ToArray();
if (usersDrop.Any())
if (usersDrop.Length > 0)
{
var fileStable = file.Forcesave == ForcesaveType.None ? file : fileDao.GetFileStable(file.ID, file.Version);
var docKey = DocumentServiceHelper.GetDocKey(fileStable);
Expand Down Expand Up @@ -1164,7 +1164,7 @@ public List<FileEntry> GetNewItems(T folderId)

result = new List<FileEntry>(EntryManager.SortEntries<T>(result, new OrderBy(SortedByType.DateAndTime, false)));

if (!result.Any())
if (result.Count == 0)
{
MarkAsRead(new List<JsonElement>() { JsonDocument.Parse(JsonSerializer.Serialize(folderId)).RootElement }, new List<JsonElement>() { }); //TODO
}
Expand All @@ -1180,7 +1180,7 @@ public List<FileEntry> GetNewItems(T folderId)

public List<FileOperationResult> MarkAsRead(List<JsonElement> foldersId, List<JsonElement> filesId)
{
if (!foldersId.Any() && !filesId.Any()) return GetTasksStatuses();
if (foldersId.Count == 0 && filesId.Count == 0) return GetTasksStatuses();
return FileOperationsManager.MarkAsRead(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), foldersId, filesId);
}

Expand Down Expand Up @@ -1385,7 +1385,7 @@ public List<FileOperationResult> TerminateTasks()

public List<FileOperationResult> BulkDownload(Dictionary<JsonElement, string> folders, Dictionary<JsonElement, string> files)
{
ErrorIf(!folders.Any() && !files.Any(), FilesCommonResource.ErrorMassage_BadRequest);
ErrorIf(folders.Count == 0 && files.Count == 0, FilesCommonResource.ErrorMassage_BadRequest);

return FileOperationsManager.Download(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), folders, files, GetHttpHeaders());
}
Expand Down Expand Up @@ -1452,7 +1452,7 @@ public List<FileOperationResult> BulkDownload(Dictionary<JsonElement, string> fo

var folders = folderDao.GetFolders(foldersId);
var foldersProject = folders.Where(folder => folder.FolderType == FolderType.BUNCH).ToList();
if (foldersProject.Any())
if (foldersProject.Count > 0)
{
var toSubfolders = destFolderDao.GetFolders(toFolder.ID);

Expand Down Expand Up @@ -1487,7 +1487,7 @@ public List<FileOperationResult> BulkDownload(Dictionary<JsonElement, string> fo
public List<FileOperationResult> MoveOrCopyItems(List<JsonElement> foldersId, List<JsonElement> filesId, JsonElement destFolderId, FileConflictResolveType resolve, bool ic, bool deleteAfter = false)
{
List<FileOperationResult> result;
if (foldersId.Any() || filesId.Any())
if (foldersId.Count > 0 || filesId.Count > 0)
{
result = FileOperationsManager.MoveOrCopy(AuthContext.CurrentAccount.ID, TenantManager.GetCurrentTenant(), foldersId, filesId, destFolderId, ic, resolve, !deleteAfter, GetHttpHeaders());
}
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Core/Core/Search/FactoryIndexerFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ List<int> getIds(DateTime lastIndexed)
}
}

if (tasks.Any())
if (tasks.Count > 0)
{
Task.WaitAll(tasks.ToArray());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ List<int> getIds(DateTime lastIndexed)
}
}

if (tasks.Any())
if (tasks.Count > 0)
{
Task.WaitAll(tasks.ToArray());
}
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.Files/Core/Core/Security/FileSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ private List<FileEntry> GetSharesForMe<T>(IEnumerable<FileShareRecord> records,
failedRecords.Add(failedRecord);
}

if (failedRecords.Any())
if (failedRecords.Count > 0)
{
securityDao.DeleteShareRecords(failedRecords);
}
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.Files/Core/Core/Thirdparty/CrossDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal class CrossDao //Additional SharpBox
if (fromFileFavoriteTag != null) fromFileTags.AddRange(fromFileFavoriteTag);
if (fromFileTemplateTag != null) fromFileTags.AddRange(fromFileTemplateTag);

if (fromFileTags.Any())
if (fromFileTags.Count > 0)
{
fromFileTags.ForEach(x => x.EntryId = toFile.ID);

Expand Down Expand Up @@ -179,7 +179,7 @@ internal class CrossDao //Additional SharpBox
var tagDao = ServiceProvider.GetService<ITagDao<TFrom>>();
var fromFileNewTags = tagDao.GetNewTags(Guid.Empty, fromFolder).ToList();

if (fromFileNewTags.Any())
if (fromFileNewTags.Count > 0)
{
fromFileNewTags.ForEach(x => x.EntryId = toFolderId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public IEnumerable<Tag> GetNewTags(Guid subject, Folder<string> parentFolder, bo
.Select(r => r.HashId)
.ToList();

if (!entryIDs.Any()) return new List<Tag>();
if (entryIDs.Count == 0) return new List<Tag>();

var q = from r in FilesDbContext.Tag
from l in FilesDbContext.TagLink.Where(a => a.TenantId == r.TenantId && a.TagId == r.Id).DefaultIfEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public List<File<string>> GetFiles(string parentId, OrderBy orderBy, FilterType
.GetFiles(selector.ConvertId(parentId), orderBy, filterType, subjectGroup, subjectID, searchText, searchInContent, withSubfolders)
.Where(r => r != null).ToList();

if (!result.Any()) return new List<File<string>>();
if (result.Count > 0) return new List<File<string>>();

SetSharedProperty(result);

Expand Down

0 comments on commit fbb50e6

Please sign in to comment.