Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable IDE0100 (Remove redundant equality) #70896

Merged
merged 1 commit into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.src.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ dotnet_diagnostic.IDE0084.severity = none
dotnet_diagnostic.IDE0090.severity = silent

# IDE0100: Remove redundant equality
dotnet_diagnostic.IDE0100.severity = suggestion
dotnet_diagnostic.IDE0100.severity = warning

# IDE0110: Remove unnecessary discard
dotnet_diagnostic.IDE0110.severity = warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ private bool TypeSignatureHasVarsNeedingCallingConventionConverter(ref NativePar
for (uint i = 0; i < data; i++)
result = TypeSignatureHasVarsNeedingCallingConventionConverter(ref parser, moduleHandle, context, HasVarsInvestigationLevel.NotParameter) || result;

if ((result == true) && (investigationLevel == HasVarsInvestigationLevel.Parameter))
if (result && (investigationLevel == HasVarsInvestigationLevel.Parameter))
{
if (!TryComputeHasInstantiationDeterminedSize(genericTypeDef, context, out result))
Environment.FailFast("Unable to setup calling convention converter correctly");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected DataTable CloneAndFilterCollection(string collectionName, string[]? hi

foreach (DataRow row in sourceTable.Rows)
{
if (SupportedByCurrentVersion(row) == true)
if (SupportedByCurrentVersion(row))
{
newRow = destinationTable.NewRow();
for (int i = 0; i < destinationColumns.Count; i++)
Expand Down Expand Up @@ -195,7 +195,7 @@ private static DataColumn[] FilterColumns(DataTable sourceTable, string[]? hidde
int columnCount = 0;
foreach (DataColumn sourceColumn in sourceTable.Columns)
{
if (IncludeThisColumn(sourceColumn, hiddenColumnNames) == true)
if (IncludeThisColumn(sourceColumn, hiddenColumnNames))
{
columnCount++;
}
Expand All @@ -211,7 +211,7 @@ private static DataColumn[] FilterColumns(DataTable sourceTable, string[]? hidde

foreach (DataColumn sourceColumn in sourceTable.Columns)
{
if (IncludeThisColumn(sourceColumn, hiddenColumnNames) == true)
if (IncludeThisColumn(sourceColumn, hiddenColumnNames))
{
DataColumn newDestinationColumn = new DataColumn(sourceColumn.ColumnName, sourceColumn.DataType);
destinationColumns.Add(newDestinationColumn);
Expand Down Expand Up @@ -269,7 +269,7 @@ internal DataRow FindMetaDataCollectionRow(string collectionName)
{
if (collectionName == candidateCollectionName)
{
if (haveExactMatch == true)
if (haveExactMatch)
{
throw ADP.CollectionNameIsNotUnique(collectionName);
}
Expand Down Expand Up @@ -304,7 +304,7 @@ internal DataRow FindMetaDataCollectionRow(string collectionName)
}
}

if ((haveExactMatch == false) && (haveMultipleInexactMatches == true))
if (!haveExactMatch && haveMultipleInexactMatches)
{
throw ADP.AmbigousCollectionName(collectionName);
}
Expand Down Expand Up @@ -528,7 +528,7 @@ private bool SupportedByCurrentVersion(DataRow requestedCollectionRow)
}

// if the minmum version was ok what about the maximum version
if (result == true)
if (result)
{
versionColumn = tableColumns[_maximumVersion];
if (versionColumn != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static bool TryReadSlow(ref SequenceReader<byte> reader, out long value)
if (reader.TryCopyTo(temp))
{
bool result = TryRead(temp, out value, out int bytesRead);
Debug.Assert(result == true);
Debug.Assert(result);
Debug.Assert(bytesRead == length);

reader.Advance(bytesRead);
Expand Down Expand Up @@ -190,7 +190,7 @@ public static bool TryWrite(Span<byte> buffer, long longToEncode, out int bytesW
public static int WriteInteger(Span<byte> buffer, long longToEncode)
{
bool res = TryWrite(buffer, longToEncode, out int bytesWritten);
Debug.Assert(res == true);
Debug.Assert(res);
return bytesWritten;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static byte[] EncodeStaticIndexedHeaderFieldToArray(int index)
Span<byte> buffer = stackalloc byte[IntegerEncoder.MaxInt32EncodedLength];

bool res = EncodeStaticIndexedHeaderField(index, buffer, out int bytesWritten);
Debug.Assert(res == true);
Debug.Assert(res);

return buffer.Slice(0, bytesWritten).ToArray();
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public static byte[] EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(int

temp[0] = 0b01110000;
bool res = IntegerEncoder.Encode(index, 4, temp, out int headerBytesWritten);
Debug.Assert(res == true);
Debug.Assert(res);

return temp.Slice(0, headerBytesWritten).ToArray();
}
Expand All @@ -102,7 +102,7 @@ public static byte[] EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(int
{
Span<byte> temp = value.Length < 256 ? stackalloc byte[256 + IntegerEncoder.MaxInt32EncodedLength * 2] : new byte[value.Length + IntegerEncoder.MaxInt32EncodedLength * 2];
bool res = EncodeLiteralHeaderFieldWithStaticNameReference(index, value, temp, out int bytesWritten);
Debug.Assert(res == true);
Debug.Assert(res);
return temp.Slice(0, bytesWritten).ToArray();
}

Expand Down Expand Up @@ -168,7 +168,7 @@ public static byte[] EncodeLiteralHeaderFieldWithoutNameReferenceToArray(string
Span<byte> temp = name.Length < 256 ? stackalloc byte[256 + IntegerEncoder.MaxInt32EncodedLength] : new byte[name.Length + IntegerEncoder.MaxInt32EncodedLength];

bool res = EncodeNameString(name, temp, out int nameLength);
Debug.Assert(res == true);
Debug.Assert(res);

return temp.Slice(0, nameLength).ToArray();
}
Expand All @@ -178,7 +178,7 @@ public static byte[] EncodeLiteralHeaderFieldWithoutNameReferenceToArray(string
Span<byte> temp = (name.Length + value.Length) < 256 ? stackalloc byte[256 + IntegerEncoder.MaxInt32EncodedLength * 2] : new byte[name.Length + value.Length + IntegerEncoder.MaxInt32EncodedLength * 2];

bool res = EncodeLiteralHeaderFieldWithoutNameReference(name, value, temp, out int bytesWritten);
Debug.Assert(res == true);
Debug.Assert(res);

return temp.Slice(0, bytesWritten).ToArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void SetPredefType(PredefinedType predef)

public bool IsSealed()
{
return _isSealed == true;
return _isSealed;
}

public void SetSealed(bool @sealed)
Expand Down Expand Up @@ -248,7 +248,7 @@ public void SetHasConversion()

public bool HasPubNoArgCtor()
{
return _hasPubNoArgCtor == true;
return _hasPubNoArgCtor;
}

public void SetHasPubNoArgCtor(bool hasPubNoArgCtor)
Expand All @@ -258,7 +258,7 @@ public void SetHasPubNoArgCtor(bool hasPubNoArgCtor)

public bool IsSkipUDOps()
{
return _isSkipUDOps == true;
return _isSkipUDOps;
}

public void SetSkipUDOps(bool skipUDOps)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private bool ContainsInnerAtomicComposition
{
set
{
if (value == true && _containsInnerAtomicComposition == true)
if (value && _containsInnerAtomicComposition)
{
throw new InvalidOperationException(SR.AtomicComposition_AlreadyNested);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ ImportCardinality IAttributedImport.Cardinality
{
get
{
if (AllowDefault == true)
if (AllowDefault)
{
return ImportCardinality.ZeroOrOne;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override int Read(Span<byte> buffer)
Debug.Assert(_stream.Position != 0, "Expected the first byte to be read first");
if (_stream.Position == 1)
{
Debug.Assert(_readFirstByte == true);
Debug.Assert(_readFirstByte);
// Add the first byte read by ReadByte into buffer here
buffer[0] = _firstByte;
return _stream.Read(buffer.Slice(1)) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ internal void SerializeConstraints(SerializationInfo info, StreamingContext cont
{
ForeignKeyConstraint? fk = c as ForeignKeyConstraint;
Debug.Assert(fk != null);
bool shouldSerialize = (allConstraints == true) || (fk.Table == this && fk.RelatedTable == this);
bool shouldSerialize = allConstraints || (fk.Table == this && fk.RelatedTable == this);

if (shouldSerialize)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ If one of the operands is true the result is true
break;
}

if ((bool)vLeft == true)
if ((bool)vLeft)
{
value = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private object EvalFunction(FunctionId id, object[] argumentValues, DataRow? row

object first = _arguments![0].Eval(row, version);

if (DataExpression.ToBoolean(first) != false)
if (DataExpression.ToBoolean(first))
{
return _arguments[1].Eval(row, version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private object EvalUnaryOp(int op, object vl)
}
else
{
if (DataExpression.ToBoolean(vl) != false)
if (DataExpression.ToBoolean(vl))
return false;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ private void AssertValid()
Debug.Assert(!Convert.IsDBNull(row[_column, rowVersion]));

// If we are on the Text column, we should always have fOnValue == true
Debug.Assert((_column.ColumnMapping == MappingType.SimpleContent) ? (_fOnValue == true) : true);
Debug.Assert((_column.ColumnMapping == MappingType.SimpleContent) ? _fOnValue : true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ private void AssertValid()
Debug.Assert(!Convert.IsDBNull(row[_column, rowVersion]));

// If we are on the Text column, we should always have _fOnValue == true
Debug.Assert((_column.ColumnMapping == MappingType.SimpleContent) ? (_fOnValue == true) : true);
Debug.Assert((_column.ColumnMapping == MappingType.SimpleContent) ? _fOnValue : true);
}
if (_column == null)
Debug.Assert(!_fOnValue);
Expand Down
24 changes: 12 additions & 12 deletions src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ internal ElementState AutoFoliationState
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private void BindForLoad()
{
Debug.Assert(_ignoreXmlEvents == true);
Debug.Assert(_ignoreXmlEvents);
_ignoreDataSetEvents = true;
_mapper.SetupMapping(this, _dataSet);
if (_dataSet.Tables.Count > 0)
Expand Down Expand Up @@ -252,7 +252,7 @@ private void BindSpecialListeners()
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private void UnBindSpecialListeners()
{
Debug.Assert(_fDataRowCreatedSpecial == true);
Debug.Assert(_fDataRowCreatedSpecial);
_dataSet.DataRowCreated -= new DataRowCreatedEventHandler(OnDataRowCreatedSpecial);
_fDataRowCreatedSpecial = false;
}
Expand Down Expand Up @@ -504,7 +504,7 @@ private XmlElement EnsureNonRowDocumentElement()
private XmlElement DemoteDocumentElement()
{
// Changes of Xml here should not affect ROM
Debug.Assert(_ignoreXmlEvents == true);
Debug.Assert(_ignoreXmlEvents);
// There should be no reason to call this function if docElem is not a rowElem
Debug.Assert(GetRowFromElement(DocumentElement) != null);

Expand Down Expand Up @@ -1005,8 +1005,8 @@ internal XmlNode CloneTree(DataPointer other)
[RequiresUnreferencedCode(DataSet.RequiresUnreferencedCodeMessage)]
private XmlNode CloneTreeInternal(DataPointer other)
{
Debug.Assert(_ignoreDataSetEvents == true);
Debug.Assert(_ignoreXmlEvents == true);
Debug.Assert(_ignoreDataSetEvents);
Debug.Assert(_ignoreXmlEvents);
Debug.Assert(IsFoliationEnabled == false);

// Create the diconnected tree based on the other navigator
Expand Down Expand Up @@ -1392,7 +1392,7 @@ private bool NeedXSI_NilAttr(DataRow row)
private void OnAddRow(DataRow row)
{
// Xml operations in this func should not trigger ROM operations
Debug.Assert(_ignoreXmlEvents == true);
Debug.Assert(_ignoreXmlEvents);

XmlBoundElement rowElement = (XmlBoundElement)(GetElementFromRow(row));
Debug.Assert(rowElement != null);
Expand Down Expand Up @@ -1665,7 +1665,7 @@ private void OnColumnValuesChanged(DataRow row, XmlBoundElement rowElement)
private void OnDeleteRow(DataRow row, XmlBoundElement rowElement)
{
// IgnoreXmlEvents s/b on since we are manipulating the XML tree and we not want this to reflect in ROM view.
Debug.Assert(_ignoreXmlEvents == true);
Debug.Assert(_ignoreXmlEvents);
// Special case when rowElem is document element: we create a new docElem, move the current one as a child of
// the new created docElem, then process as if the docElem is not a rowElem
if (rowElement == DocumentElement)
Expand Down Expand Up @@ -1742,7 +1742,7 @@ private void OnNestedParentChange(DataRow child, XmlBoundElement childElement, D
{
Debug.Assert(child.Element == childElement && childElement.Row == child);
// This function is (and s/b) called as a result of ROM changes, therefore XML changes done here should not be sync-ed to ROM
Debug.Assert(_ignoreXmlEvents == true);
Debug.Assert(_ignoreXmlEvents);
#if DEBUG
// In order to check that this move does not change the connected/disconnected state of the node
bool fChildElementConnected = IsConnected(childElement);
Expand Down Expand Up @@ -1831,7 +1831,7 @@ private void OnNodeChanging(object sender, XmlNodeChangedEventArgs args)
{
if (_ignoreXmlEvents)
return;
if (DataSet.EnforceConstraints != false)
if (DataSet.EnforceConstraints)
throw new InvalidOperationException(SR.DataDom_EnforceConstraintsShouldBeOff);
}

Expand Down Expand Up @@ -1886,7 +1886,7 @@ private void OnNodeInserting(object sender, XmlNodeChangedEventArgs args)
{
if (_ignoreXmlEvents)
return;
if (DataSet.EnforceConstraints != false)
if (DataSet.EnforceConstraints)
throw new InvalidOperationException(SR.DataDom_EnforceConstraintsShouldBeOff);
}

Expand Down Expand Up @@ -1938,7 +1938,7 @@ private void OnNodeRemoving(object sender, XmlNodeChangedEventArgs args)
{
if (_ignoreXmlEvents)
return;
if (DataSet.EnforceConstraints != false)
if (DataSet.EnforceConstraints)
throw new InvalidOperationException(SR.DataDom_EnforceConstraintsShouldBeOff);
}

Expand Down Expand Up @@ -2286,7 +2286,7 @@ private void PromoteChild(XmlNode child, XmlNode prevSibling)
// prevSibling must have a parent, since we want to add a sibling to it
Debug.Assert(prevSibling.ParentNode != null);
Debug.Assert(IsFoliationEnabled == false);
Debug.Assert(IgnoreXmlEvents == true);
Debug.Assert(IgnoreXmlEvents);
// Should not insert after docElem node
Debug.Assert(prevSibling != DocumentElement);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,7 @@ private void DeactivateObject(DbConnectionInternal obj)
// postcondition

// ensure that the connection was processed
Debug.Assert(
returnToGeneralPool == true || destroyObject == true);
Debug.Assert(returnToGeneralPool || destroyObject);
}

internal void DestroyObject(DbConnectionInternal obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ internal static TypeMap UpgradeSignedType(TypeMap typeMap, bool unsigned)
{
// upgrade unsigned types to be able to hold data that has the highest bit set
//
if (unsigned == true)
if (unsigned)
{
return typeMap._dbType switch
{
Expand Down
Loading