Skip to content
Merged
Prev Previous commit
Next Next commit
Fix suppression with no offset
  • Loading branch information
rjmholt committed Jul 21, 2021
commit e486374c1571a5912758a07b435e3d6d20cacc6c
14 changes: 3 additions & 11 deletions Engine/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1364,20 +1364,12 @@ public Tuple<List<SuppressedRecord>, List<DiagnosticRecord>> SuppressRule(
{
Tuple<int, int> offsetPair = GetOffset(diagnostic);

// If we have no offset, we can't suppress anything
if (offsetPair is null)
{
unsuppressedRecords.Add(diagnostic);
continue;
}

(int startOffset, int endOffset) = offsetPair;

var appliedSuppressions = new List<RuleSuppression>();
foreach (RuleSuppression suppression in ruleSuppressions)
{
// Check that the diagnostic is within the suppressed extent
if (startOffset < suppression.StartOffset || endOffset > suppression.EndOffset)
// Check that the diagnostic is within the suppressed extent, if we have such an extent
if (!(offsetPair is null)
&& (offsetPair.Item1 < suppression.StartOffset || offsetPair.Item2 > suppression.EndOffset))
{
continue;
}
Expand Down