Skip to content

Commit

Permalink
analizators/U2U1100
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Jan 12, 2022
1 parent 6961f38 commit 66cf28b
Show file tree
Hide file tree
Showing 37 changed files with 83 additions and 85 deletions.
2 changes: 1 addition & 1 deletion common/ASC.Common/Logging/SpecialFolderPathConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected override void Convert(TextWriter writer, object state)
var args = Environment.CommandLine.Split(' ');
for (var i = 0; i < args.Length - 1; i++)
{
if (args[i].Equals(Option.Substring(CMD_LINE.Length), StringComparison.InvariantCultureIgnoreCase))
if (args[i].Contains(Option, StringComparison.InvariantCultureIgnoreCase))
{
result = args[i + 1];
}
Expand Down
4 changes: 2 additions & 2 deletions common/ASC.Core.Common/Context/Impl/CoreConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public bool Personal
get
{
//TODO:if (CustomMode && HttpContext.Current != null && HttpContext.Current.Request.SailfishApp()) return true;
return personal ?? (bool)(personal = string.Compare(Configuration["core:personal"], "true", true) == 0);
return personal ?? (bool)(personal = Configuration["core:personal"].Equals("true", StringComparison.OrdinalIgnoreCase));
}
}

public bool CustomMode
{
get { return customMode ?? (bool)(customMode = string.Compare(Configuration["core:custom-mode"], "true", true) == 0); }
get { return customMode ?? (bool)(customMode = Configuration["core:custom-mode"].Equals("true", StringComparison.OrdinalIgnoreCase)); }
}
}

Expand Down
6 changes: 3 additions & 3 deletions common/ASC.Core.Common/Context/Impl/UserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ public UserInfo GetUserByUserName(string username)
public UserInfo GetUserBySid(string sid)
{
return GetUsersInternal()
.FirstOrDefault(u => u.Sid != null && string.Compare(u.Sid, sid, StringComparison.CurrentCultureIgnoreCase) == 0) ?? Constants.LostUser;
.FirstOrDefault(u => u.Sid != null && u.Sid.Equals(sid, StringComparison.CurrentCultureIgnoreCase)) ?? Constants.LostUser;
}

public UserInfo GetSsoUserByNameId(string nameId)
{
return GetUsersInternal()
.FirstOrDefault(u => !string.IsNullOrEmpty(u.SsoNameId) && string.Compare(u.SsoNameId, nameId, StringComparison.CurrentCultureIgnoreCase) == 0) ?? Constants.LostUser;
.FirstOrDefault(u => !string.IsNullOrEmpty(u.SsoNameId) && u.SsoNameId.Equals(nameId, StringComparison.CurrentCultureIgnoreCase)) ?? Constants.LostUser;
}
public bool IsUserNameExists(string username)
{
Expand Down Expand Up @@ -239,7 +239,7 @@ public UserInfo[] Search(string text, EmployeeStatus status)

public UserInfo[] Search(string text, EmployeeStatus status, Guid groupId)
{
if (text == null || text.Trim() == string.Empty) return new UserInfo[0];
if (text == null || text.Trim().Length == 0) return new UserInfo[0];

var words = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (words.Length == 0) return new UserInfo[0];
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/Data/DbSubscriptionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void RemoveSubscriptions(int tenant, string sourceId, string actionId, st
.Where(r => r.Source == sourceId)
.Where(r => r.Action == actionId);

if (objectId != string.Empty)
if (objectId.Length != 0)
{
q = q.Where(r => r.Object == (objectId ?? string.Empty));
}
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/EF/LinqExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static IOrderedQueryable<T> ThenBy<T>(this IOrderedQueryable<T> query, st
private static PropertyInfo GetPropertyInfo(Type objType, string name)
{
var properties = objType.GetProperties();
var matchedProperty = properties.FirstOrDefault(p => p.Name.ToLower() == name.ToLower());
var matchedProperty = properties.FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
if (matchedProperty == null)
throw new ArgumentException("name");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void SendMessage(string callerUserName, string calleeUserName, string mes
var tenant = tenantId == -1
? TenantManager.GetTenant(domain)
: TenantManager.GetTenant(tenantId);
var isTenantUser = callerUserName == string.Empty;
var isTenantUser = callerUserName.Length == 0;
var message = new MessageClass
{
UserName = isTenantUser ? tenant.GetTenantDomain(CoreSettings) : callerUserName,
Expand Down
2 changes: 1 addition & 1 deletion common/ASC.Core.Common/Notify/Telegram/TelegramHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public RegStatus UserIsConnected(Guid userId, int tenantId)
public string CurrentRegistrationLink(Guid userId, int tenantId)
{
var token = GetCurrentToken(userId, tenantId);
if (token == null || token == "") return "";
if (token == null || token.Length == 0) return "";

return GetLink(token);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private ValidationResult ValidateEmailKeyInternal(string email, string key, Time

var hash = GetMashineHashedData(BitConverter.GetBytes(ms), Encoding.ASCII.GetBytes(email));
var key2 = DoStringFromBytes(hash);
var key2_good = string.Compare(parts[1], key2, StringComparison.InvariantCultureIgnoreCase) == 0;
var key2_good = parts[1].Equals(key2, StringComparison.OrdinalIgnoreCase);
if (!key2_good) return ValidationResult.Invalid;
var ms_current = (long)(DateTime.UtcNow - _from).TotalMilliseconds;
return validInterval >= TimeSpan.FromMilliseconds(ms_current - ms) ? ValidationResult.Ok : ValidationResult.Expired;
Expand Down
6 changes: 3 additions & 3 deletions common/ASC.Data.Backup.Core/Core/DbBackupProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private Configuration GetConfiguration(string config)
{
var map = new ExeConfigurationFileMap
{
ExeConfigFilename = string.Compare(Path.GetExtension(config), ".config", true) == 0 ? config : CrossPlatform.PathCombine(config, "Web.config")
ExeConfigFilename = string.Equals(Path.GetExtension(config), ".config", StringComparison.OrdinalIgnoreCase) ? config : CrossPlatform.PathCombine(config, "Web.config")
};
return ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
}
Expand Down Expand Up @@ -194,11 +194,11 @@ private List<XElement> BackupDatabase(int tenant, ConnectionStringSettings conne
private void RestoreDatabase(ConnectionStringSettings connectionString, IEnumerable<XElement> elements, IDataReadOperator reader)
{
var dbName = connectionString.Name;
var dbElement = elements.SingleOrDefault(e => string.Compare(e.Name.LocalName, connectionString.Name, true) == 0);
var dbElement = elements.SingleOrDefault(e => string.Equals(e.Name.LocalName, connectionString.Name, StringComparison.OrdinalIgnoreCase));
if (dbElement != null && dbElement.Attribute("ref") != null)
{
dbName = dbElement.Attribute("ref").Value;
dbElement = elements.Single(e => string.Compare(e.Name.LocalName, dbElement.Attribute("ref").Value, true) == 0);
dbElement = elements.Single(e => string.Equals(e.Name.LocalName, dbElement.Attribute("ref").Value, StringComparison.OrdinalIgnoreCase));
}
if (dbElement == null) return;

Expand Down
4 changes: 2 additions & 2 deletions common/ASC.Data.Backup.Core/Core/DbHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public DbHelper(IOptionsMonitor<ILog> options, ConnectionStringSettings connecti
connect.ConnectionString = connectionString.ConnectionString;
connect.Open();

mysql = connectionString.ProviderName.ToLower().Contains("mysql");
mysql = connectionString.ProviderName.Contains("mysql", StringComparison.OrdinalIgnoreCase);
if (mysql)
{
CreateCommand("set @@session.sql_mode = concat(@@session.sql_mode, ',NO_AUTO_VALUE_ON_ZERO')").ExecuteNonQuery();
Expand Down Expand Up @@ -268,7 +268,7 @@ private string GetWhere(string tableName, int tenant)
{
return string.Format(whereExceptions[tableName.ToLower()], tenant);
}
var tenantColumn = GetColumnsFrom(tableName).FirstOrDefault(c => c.ToLower().StartsWith("tenant"));
var tenantColumn = GetColumnsFrom(tableName).FirstOrDefault(c => c.StartsWith("tenant", StringComparison.OrdinalIgnoreCase));
return tenantColumn != null ?
" where " + Quote(tenantColumn) + " = " + tenant :
" where 1 = 0";
Expand Down
6 changes: 3 additions & 3 deletions products/ASC.CRM/Server/Api/InvoicesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ String currency
)
{
if (!String.IsNullOrEmpty(entityType) && !(
String.Compare(entityType, "contact", true) == 0 ||
String.Compare(entityType, "opportunity", true) == 0 ||
String.Compare(entityType, "case", true) == 0))
string.Equals(entityType, "contact", StringComparison.CurrentCultureIgnoreCase) ||
string.Equals(entityType, "opportunity", StringComparison.CurrentCultureIgnoreCase) ||
string.Equals(entityType, "case", StringComparison.CurrentCultureIgnoreCase)))
throw new ArgumentException();

IEnumerable<InvoiceBaseDto> result;
Expand Down
4 changes: 2 additions & 2 deletions products/ASC.CRM/Server/Api/RelationshipEventsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ public RelationshipEventDto AddHistoryTo([FromBody] AddHistoryToRequestDto inDto

if (!string.IsNullOrEmpty(entityType) &&
!(
string.Compare(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(entityType, "case", StringComparison.OrdinalIgnoreCase) == 0)
string.Equals(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) ||
string.Equals(entityType, "case", StringComparison.OrdinalIgnoreCase))
)
throw new ArgumentException();

Expand Down
18 changes: 9 additions & 9 deletions products/ASC.CRM/Server/Api/TasksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ public IEnumerable<TaskDto> GetAllTasks(

if (!string.IsNullOrEmpty(entityType) &&
!(
string.Compare(entityType, "contact", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(entityType, "case", StringComparison.OrdinalIgnoreCase) == 0)
string.Equals(entityType, "contact", StringComparison.OrdinalIgnoreCase)||
string.Equals(entityType, "opportunity", StringComparison.OrdinalIgnoreCase)||
string.Equals(entityType, "case", StringComparison.OrdinalIgnoreCase))
)
throw new ArgumentException();

Expand Down Expand Up @@ -303,8 +303,8 @@ public TaskDto CreateTask(

if (!string.IsNullOrEmpty(entityType) &&
!(
string.Compare(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(entityType, "case", StringComparison.OrdinalIgnoreCase) == 0
string.Equals(entityType, "opportunity", StringComparison.OrdinalIgnoreCase)||
string.Equals(entityType, "case", StringComparison.OrdinalIgnoreCase)
)
|| categoryId <= 0)
throw new ArgumentException();
Expand Down Expand Up @@ -398,8 +398,8 @@ public IEnumerable<TaskDto> CreateTaskGroup([FromBody] CreateTaskGroupRequestDto

if (
!string.IsNullOrEmpty(entityType) &&
!(string.Compare(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(entityType, "case", StringComparison.OrdinalIgnoreCase) == 0)
!(string.Equals(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) ||
string.Equals(entityType, "case", StringComparison.OrdinalIgnoreCase))
)
throw new ArgumentException();

Expand Down Expand Up @@ -508,8 +508,8 @@ public TaskDto UpdateTask(
var isNotify = inDto.isNotify;

if (!string.IsNullOrEmpty(entityType) &&
!(string.Compare(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) == 0 ||
string.Compare(entityType, "case", StringComparison.OrdinalIgnoreCase) == 0
!(string.Equals(entityType, "opportunity", StringComparison.OrdinalIgnoreCase) ||
string.Equals(entityType, "case", StringComparison.OrdinalIgnoreCase)
) || categoryid <= 0)
throw new ArgumentException();

Expand Down
2 changes: 1 addition & 1 deletion products/ASC.CRM/Server/Classes/CRMSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public ISettings GetDefault(IServiceProvider serviceProvider)

var languageName = System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;

var findedCurrency = currencyProvider.GetAll().Find(item => String.Compare(item.CultureName, languageName, true) == 0);
var findedCurrency = currencyProvider.GetAll().Find(item => string.Equals(item.CultureName, languageName, StringComparison.OrdinalIgnoreCase));

return new CrmSettings()
{
Expand Down
6 changes: 3 additions & 3 deletions products/ASC.CRM/Server/Classes/CSVReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public List<object> ReadRow()

// Build the list of objects in the line
List<object> objects = new List<object>();
while (currentLine != "")
while (currentLine.Length != 0)
objects.Add(ReadNextObject());
return objects;
}
Expand Down Expand Up @@ -185,10 +185,10 @@ private object ReadNextObject()
{
// Check if we've hit the end of the string
if ((!quoted && i == len) // non-quoted strings end with a comma or end of line
|| (!quoted && currentLine.Substring(i, 1) == FieldSep)
|| (!quoted && string.CompareOrdinal(currentLine, i, FieldSep, 0, 1) == 0)
// quoted strings end with a quote followed by a comma or end of line
|| (quoted && i == len - 1 && currentLine.EndsWith("\""))
|| (quoted && currentLine.Substring(i, 2) == "\"" + FieldSep))
|| (quoted && string.CompareOrdinal(currentLine, i, "\"" + FieldSep, 0, 2) == 0))
foundEnd = true;
else
i++;
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.CRM/Server/Core/Dao/CustomFieldDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public void EditItem(CustomField customField)

if (fieldType == CustomFieldType.SelectBox)
{
if (oldMask == customField.Mask || customField.Mask == "")
if (oldMask == customField.Mask || customField.Mask.Length == 0)
{
resultMask = oldMask;
}
Expand Down
2 changes: 1 addition & 1 deletion products/ASC.CRM/Server/Core/Entities/CurrencyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public String Title
public override bool Equals(object obj)
{
var ci = obj as CurrencyInfo;
return ci != null && string.Compare(Title, ci.Title, true) == 0;
return ci != null && string.Equals(Title, ci.Title, StringComparison.OrdinalIgnoreCase);
}

public override int GetHashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public async System.Threading.Tasks.Task Invoke(HttpContext context,
IsPrimary = true
});
}
else if (String.Compare(key, "tag", true) == 0)
else if (string.Equals(key, "tag", StringComparison.OrdinalIgnoreCase))
{
var tags = _context.Request.Form["tag"];

Expand Down
4 changes: 2 additions & 2 deletions products/ASC.CRM/Server/Utils/CurrencyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public Dictionary<CurrencyInfo, Decimal> MoneyConvert(CurrencyInfo baseCurrency)

public bool IsConvertable(String abbreviation)
{
var findedItem = _currencies.Keys.ToList().Find(item => String.Compare(abbreviation, item) == 0);
var findedItem = _currencies.Keys.ToList().Find(item => string.Equals(abbreviation, item));

if (findedItem == null)
throw new ArgumentException(abbreviation);
Expand All @@ -152,7 +152,7 @@ public bool IsConvertable(String abbreviation)

public Decimal MoneyConvert(decimal amount, string from, string to)
{
if (string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to) || string.Compare(from, to, true) == 0) return amount;
if (string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to) || string.Equals(from, to, StringComparison.OrdinalIgnoreCase)) return amount;

var rates = GetExchangeRates();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private String GetPropertyValue(String propertyName)

var values = jsonElement.EnumerateArray().Select(x => x.GetInt32()).ToList().ConvertAll(columnIndex => _columns[columnIndex]);

values.RemoveAll(item => item == String.Empty);
values.RemoveAll(item => item.Length == 0);

return String.Join(",", values.ToArray());
}
Expand Down
14 changes: 7 additions & 7 deletions products/ASC.CRM/Server/Utils/Import/CSV/ImportDeals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ private void ImportOpportunityData(DaoFactory _daoFactory)

if (!string.IsNullOrEmpty(bidTypeStr))
{
if (String.Compare(CRMDealResource.BidType_FixedBid, bidTypeStr, true) == 0)
if (string.Equals(CRMDealResource.BidType_FixedBid, bidTypeStr, StringComparison.OrdinalIgnoreCase))
bidType = BidType.FixedBid;
else if (String.Compare(CRMDealResource.BidType_PerDay, bidTypeStr, true) == 0)
else if (string.Equals(CRMDealResource.BidType_PerDay, bidTypeStr, StringComparison.OrdinalIgnoreCase))
bidType = BidType.PerDay;
else if (String.Compare(CRMDealResource.BidType_PerHour, bidTypeStr, true) == 0)
else if (string.Equals(CRMDealResource.BidType_PerHour, bidTypeStr, StringComparison.OrdinalIgnoreCase))
bidType = BidType.PerHour;
else if (String.Compare(CRMDealResource.BidType_PerMonth, bidTypeStr, true) == 0)
else if (string.Equals(CRMDealResource.BidType_PerMonth, bidTypeStr, StringComparison.OrdinalIgnoreCase))
bidType = BidType.PerMonth;
else if (String.Compare(CRMDealResource.BidType_PerWeek, bidTypeStr, true) == 0)
else if (string.Equals(CRMDealResource.BidType_PerWeek, bidTypeStr, StringComparison.OrdinalIgnoreCase))
bidType = BidType.PerWeek;
else if (String.Compare(CRMDealResource.BidType_PerYear, bidTypeStr, true) == 0)
else if (string.Equals(CRMDealResource.BidType_PerYear, bidTypeStr, StringComparison.OrdinalIgnoreCase))
bidType = BidType.PerYear;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ private void ImportOpportunityData(DaoFactory _daoFactory)
obj.DealMilestoneID = dealMilestones[0].ID;
else
{
var dealMilestone = dealMilestones.Find(item => String.Compare(item.Title, dealMilestoneTitle, true) == 0);
var dealMilestone = dealMilestones.Find(item => string.Equals(item.Title, dealMilestoneTitle, StringComparison.OrdinalIgnoreCase));

if (dealMilestone == null)
obj.DealMilestoneID = dealMilestones[0].ID;
Expand Down
Loading

0 comments on commit 66cf28b

Please sign in to comment.