Skip to content

Commit

Permalink
analizators/U2U1023
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Jan 12, 2022
1 parent 3ff7aec commit 6961f38
Show file tree
Hide file tree
Showing 29 changed files with 39 additions and 49 deletions.
4 changes: 2 additions & 2 deletions common/ASC.Common/DIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public bool TryAdd(Type service, Type implementation = null)
}
else
{
Type c = null;
Type c;
var a1 = a.GetGenericTypeDefinition();
var b = a.GetGenericArguments().FirstOrDefault();

Expand Down Expand Up @@ -297,7 +297,7 @@ public bool TryAdd(Type service, Type implementation = null)
}
else
{
Type c = null;
Type c;
var a1 = a.GetGenericTypeDefinition();
var b = a.GetGenericArguments().FirstOrDefault();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
var denyAction = denyActions[i];
var denySubject = denySubjects[i];

var reason = "";
string reason;
if (denySubject != null && denyAction != null)
reason = string.Format("{0}:{1} access denied {2}.",
action.Name,
Expand Down
3 changes: 1 addition & 2 deletions common/ASC.Core.Common/Encryption/EncryptionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ public string GeneratePassword(int length, int numberOfNonAlphanumericCharacters
throw new ArgumentException("min_required_non_alphanumeric_characters_incorrect", "numberOfNonAlphanumericCharacters");
}

var array = new byte[length];
var array2 = new char[length];
var num = 0;

array = RandomNumberGenerator.GetBytes(length);
var array = RandomNumberGenerator.GetBytes(length);

for (var i = 0; i < length; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/Notify/Engine/InterceptorStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void AddInternal(ISendInterceptor interceptor, Dictionary<string, ISendI

private ISendInterceptor GetInternal(string name, Dictionary<string, ISendInterceptor> storage)
{
ISendInterceptor interceptor = null;
ISendInterceptor interceptor;
lock (syncRoot)
{
storage.TryGetValue(name, out interceptor);
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/Notify/Engine/NotifyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private NotifyResult SendNotify(NotifyRequest request, IServiceScope serviceScop
sendResponces.AddRange(SendGroupNotify(request, serviceScope));
}

NotifyResult result = null;
NotifyResult result;
if (sendResponces == null || sendResponces.Count == 0)
{
result = new NotifyResult(SendResult.OK, sendResponces);
Expand Down
3 changes: 1 addition & 2 deletions common/ASC.Core.Common/Notify/RecipientProviderImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public virtual IRecipient[] GetGroupEntries(IRecipientsGroup group)
if (group == null) throw new ArgumentNullException("group");

var result = new List<IRecipient>();
var groupID = Guid.Empty;
if (TryParseGuid(group.ID, out groupID))
if (TryParseGuid(group.ID, out var groupID))
{
var coreGroup = UserManager.GetGroupInfo(groupID);
if (coreGroup.ID != Constants.LostGroupInfo.ID)
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Data.Backup.Core/Core/DbBackupProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private List<XElement> BackupDatabase(int tenant, ConnectionStringSettings conne
}

xml.Add(new XElement(table));
DataTable dataTable = null;
DataTable dataTable;
while (true)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private T Upload<T>(T folderId, string localPath)
var chunkedUploadSession = fileDao.CreateUploadSession(newFile, source.Length);
chunkedUploadSession.CheckQuota = false;

var bytesRead = 0;
int bytesRead;

while ((bytesRead = source.Read(buffer, 0, (int)SetupInfo.ChunkUploadSize)) > 0)
{
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 @@ -284,7 +284,7 @@ private void DumpTableData(string t, string dir, int count)
}

Logger.DebugFormat("dump table data start {0}", t);
var searchWithPrimary = false;
bool searchWithPrimary;
string primaryIndex;
var primaryIndexStep = 0;
var primaryIndexStart = 0;
Expand Down
1 change: 0 additions & 1 deletion common/ASC.Data.Backup.Core/Tasks/Data/TableInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public TableInfo(string name, string tenantColumn = null, string idColumn = null
IdColumn = idColumn;
IdType = idType;
TenantColumn = tenantColumn;
UserIDColumns = new string[0];
DateColumns = new Dictionary<string, bool>();
InsertMethod = InsertMethod.Insert;
}
Expand Down
12 changes: 5 additions & 7 deletions common/ASC.Data.Encryption/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,14 @@ public int GetMetadataLength()

private byte[] GenerateRandom(int length)
{
var random = new byte[length];

random = RandomNumberGenerator.GetBytes(length);
var random = RandomNumberGenerator.GetBytes(length);

return random;
}

private byte[] GenerateKey()
{
var key = new byte[keyLength];
byte[] key;

using (var deriveBytes = new Rfc2898DeriveBytes(Password, Salt, Iterations, HashAlgorithmName.SHA256))
{
Expand All @@ -263,7 +261,7 @@ private byte[] GenerateKey()

private byte[] GenerateHmacKey()
{
var hmacKey = new byte[hmacKeyLength];
byte[] hmacKey;

using (var sha512 = SHA512.Create())
{
Expand All @@ -274,8 +272,8 @@ private byte[] GenerateHmacKey()
}

private byte[] ComputeHmacHash(Stream stream)
{
var hmacHash = new byte[hmacHashLength];
{
byte[] hmacHash;

stream.Seek(metadataLength - ivLength, SeekOrigin.Begin); // Move position to (IV + encrypted data)

Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Data.Storage/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void IronReadToStream(this IDataStore store, string domain, string
tryCurrent++;
using var stream = store.GetReadStream(domain, path, offset);
var buffer = new byte[BufferSize];
var readed = 0;
int readed;
while ((readed = stream.Read(buffer, 0, BufferSize)) > 0)
{
readTo.Write(buffer, 0, readed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,9 @@ public override string[] ListDirectoriesRelative(string domain, string path, boo

public override string[] ListFilesRelative(string domain, string path, string pattern, bool recursive)
{
var paths = new List<string>();

var client = GetClient();

paths = client.ListObjects(_private_container, null, null, null, MakePath(domain, path), _region).Select(x => x.Name).ToList();
var paths = client.ListObjects(_private_container, null, null, null, MakePath(domain, path), _region).Select(x => x.Name);

return paths
.Where(x => Wildcard.IsMatch(pattern, Path.GetFileName(x)))
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.CRM/Server/Classes/CSVReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private object ReadNextObject()
quoted = true;

// Find the end of the next value
string nextObjectString = "";
string nextObjectString;
int i = 0;
int len = currentLine.Length;
bool foundEnd = false;
Expand Down Expand Up @@ -231,7 +231,7 @@ public DataTable CreateDataTable(bool headerRow)
{
// Read the CSV data into rows
List<List<object>> rows = new List<List<object>>();
List<object> readRow = null;
List<object> readRow;
while ((readRow = ReadRow()) != null)
rows.Add(readRow);

Expand Down
2 changes: 1 addition & 1 deletion products/ASC.CRM/Server/Classes/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public static byte[] ToByteArray(Stream inputStream)
{
var br = new MemoryStream();
var data = new byte[1024];
var readed = 0;
int readed;

while ((readed = inputStream.Read(data, 0, data.Length)) > 0)
{
Expand Down
6 changes: 3 additions & 3 deletions products/ASC.CRM/Server/Classes/LocalizedEnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private class LookupTable : Dictionary<string, object> { }
/// <returns></returns>
private LookupTable GetLookupTable(CultureInfo culture)
{
LookupTable result = null;
LookupTable result;
if (culture == null)
culture = CultureInfo.CurrentCulture;

Expand Down Expand Up @@ -191,7 +191,7 @@ private string GetFlagValueText(CultureInfo culture, object value)
private object GetValue(CultureInfo culture, string text)
{
LookupTable lookupTable = GetLookupTable(culture);
object result = null;
object result;
lookupTable.TryGetValue(text, out result);
return result;
}
Expand All @@ -203,7 +203,7 @@ private object GetFlagValue(CultureInfo culture, string text)
ulong result = 0;
foreach (string textValue in textValues)
{
object value = null;
object value;
string trimmedTextValue = textValue.Trim();
if (!lookupTable.TryGetValue(trimmedTextValue, out value))
{
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.CRM/Server/Core/Dao/ContactDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ private void UpdateContactFromDb(Contact contact)
String title;
int companyID;

var displayName = String.Empty;
string displayName;

if (contact is Company)
{
Expand Down Expand Up @@ -1346,7 +1346,7 @@ private int SaveContactToDb(Contact contact)
String title;
int companyID;

var displayName = String.Empty;
string displayName;

if (contact is Company)
{
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.CRM/Server/Core/Dao/TaskDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public List<object[]> GetInfoForReminder(DateTime scheduleDate)
int entityId)
{

int result = 0;
int result;

_logger.DebugFormat("Starting GetTasksCount: {0}", DateTime.Now.ToString());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public FileHandlerMiddleware(RequestDelegate next)

var filePath = String.Format("folder_{0}/message_{1}.html", (messageId / 1000 + 1) * 1000, messageId);

string messageContent = string.Empty;
string messageContent;

using (var streamReader = new StreamReader(global.GetStore().GetReadStream("mail_messages", filePath)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private bool CheckPermission()

var addressTemplateStr = JsonSerializer.Serialize(addressTemplate);

var isCompany = false;
bool isCompany;

var isCompanyString = GetValue("is_company");
var firstName = GetValue("firstName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ public void SendAboutImportCompleted(Guid recipientID, EntityType entityType)

var recipient = notifySource.GetRecipientsProvider().GetRecipient(recipientID.ToString());

var entitiyListTitle = "";
var entitiyListRelativeURL = "";
string entitiyListTitle;
string entitiyListRelativeURL;

switch (entityType)
{
Expand Down
3 changes: 1 addition & 2 deletions products/ASC.CRM/Server/Utils/Import/CSV/ImportTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ private void ImportTaskData(DaoFactory _daoFactory)
}

var alertValue = GetPropertyValue("alertValue");
int alertIntVal = 0;

if (Int32.TryParse(alertValue, out alertIntVal))
if (Int32.TryParse(alertValue, out var alertIntVal))
obj.AlertValue = alertIntVal;
else
obj.AlertValue = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public void Transfer(ResumableUploadSession googleDriveSession, Stream stream, l
googleDriveSession.BytesToTransfer));
request.Content = new StreamContent(stream);
using var httpClient = new HttpClient();
HttpResponseMessage response = null;
HttpResponseMessage response;

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public override void RunJob(DistributedTask distributedTask, CancellationToken c

if (stream != null)
{
var archiveExtension = "";
string archiveExtension;

using(var zip = scope.ServiceProvider.GetService<CompressToArchive>())
{
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.Files/Server/Helpers/FilesControllerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ public IEnumerable<FileOperationWraper> DeleteFolder(T folderId, bool deleteAfte

public IEnumerable<FileEntryWrapper> MoveOrCopyBatchCheck(BatchModel batchModel)
{
var checkedFiles = new List<object>();
var checkedFolders = new List<object>();
List<object> checkedFiles;
List<object> checkedFolders;

if (batchModel.DestFolderId.ValueKind == JsonValueKind.Number)
{
Expand Down
4 changes: 1 addition & 3 deletions web/ASC.Web.Core/CommonPhotoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public static Image DoThumbnail(Image image, Size size, bool crop, bool transpar
var maxSide = realWidth > realHeight ? realWidth : realHeight;
var minSide = realWidth < realHeight ? realWidth : realHeight;

var alignWidth = true;
if (crop) alignWidth = (minSide == realWidth);
else alignWidth = (maxSide == realWidth);
var alignWidth = crop ? (minSide == realWidth) : (maxSide == realWidth);

var scaleFactor = (alignWidth) ? (realWidth / (1.0 * width)) : (realHeight / (1.0 * height));

Expand Down
2 changes: 1 addition & 1 deletion web/ASC.Web.Core/Notify/StudioPeriodicNotify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public void SendPersonalLetters(string senderName, DateTime scheduleDate)
Log.Info("Start SendLettersPersonal...");


var activeTenants = new List<Tenant>();
List<Tenant> activeTenants;

using (var scope = ServiceProvider.CreateScope())
{
Expand Down
2 changes: 1 addition & 1 deletion web/ASC.Web.Core/WebItemSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public bool IsAvailableForMe(Guid id)
public bool IsAvailableForUser(Guid itemId, Guid @for)
{
var id = itemId.ToString();
var result = false;
bool result;

var tenant = TenantManager.GetCurrentTenant();
var dic = WebItemSecurityCache.GetOrInsert(tenant.TenantId);
Expand Down
2 changes: 1 addition & 1 deletion web/ASC.Web.Core/WhiteLabel/TenantWhiteLabelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public void SetLogo(TenantWhiteLabelSettings tenantWhiteLabelSettings, Dictionar

public void SetLogoFromStream(TenantWhiteLabelSettings tenantWhiteLabelSettings, WhiteLabelLogoTypeEnum type, string fileExt, Stream fileStream, IDataStore storage = null)
{
byte[] data = null;
byte[] data;
using (var memoryStream = new MemoryStream())
{
fileStream.CopyTo(memoryStream);
Expand Down

0 comments on commit 6961f38

Please sign in to comment.