-
Notifications
You must be signed in to change notification settings - Fork 124
Fix XML suppression comments in CLI suppress command #717
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: gfs <[email protected]>
- Added XML language support to comments.json with prefix "<!--" and suffix "-->" - Added comprehensive unit tests for XML suppression generation - Added unit tests for XML suppression parsing - Added integration tests for CLI suppress command with XML files - Added integration tests for XML suppression with duration and reviewer - Added analysis test to verify suppressions are respected in XML files - Restored nuget.config to original private feed configuration Co-authored-by: gfs <[email protected]>
|
Based on the work initially done in #705 but in a branch on the main repo so it can be iterated on by Copilot and the PR gates run. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes XML suppression comments in the DevSkim CLI to use proper XML comment delimiters (<!-- -->). Previously, XML files were receiving suppression text without comment delimiters, making the suppressions invalid and non-functional.
Changes:
- Added XML language entry to
comments.jsonwith proper prefix (<!--) and suffix (-->) for multi-line comments - Added 13 comprehensive tests covering XML suppression generation, parsing, expiration handling, reviewer attribution, and CLI integration
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
DevSkim-DotNet/Microsoft.DevSkim/resources/comments.json |
Added XML language configuration with correct comment delimiters |
DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs |
Added comprehensive test suite for XML suppression functionality |
Comments suppressed due to low confidence (1)
DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs:538
- This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
foreach (string line in lines)
{
if (line.Contains("<!-- DevSkim: ignore"))
{
Suppression suppression = new Suppression(line);
Assert.IsTrue(suppression.IsInEffect, "Suppression should be in effect");
if (!string.IsNullOrEmpty(reviewerName))
{
Assert.AreEqual(reviewerName, suppression.Reviewer, "Reviewer name should match");
}
if (duration > 0)
{
DateTime expectedExpiration = DateTime.Now.AddDays(duration);
Assert.AreEqual(expectedExpiration.Date, suppression.ExpirationDate, "Expiration date should match");
}
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ements in foreach loops Co-authored-by: gfs <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
DevSkim-DotNet/Microsoft.DevSkim.Tests/SuppressionsTest.cs:532
- This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.
foreach (string line in suppressionLines)
{
Suppression suppression = new Suppression(line);
Assert.IsTrue(suppression.IsInEffect, "Suppression should be in effect");
if (!string.IsNullOrEmpty(reviewerName))
{
Assert.AreEqual(reviewerName, suppression.Reviewer, "Reviewer name should match");
}
if (duration > 0)
{
DateTime expectedExpiration = DateTime.Now.AddDays(duration);
Assert.AreEqual(expectedExpiration.Date, suppression.ExpirationDate, "Expiration date should match");
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| DateTime expectedExpiration = DateTime.Now.AddDays(duration); | ||
| Assert.AreEqual(expectedExpiration.Date, suppression.ExpirationDate, "Expiration date should match"); |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected expiration date should be calculated before calling the suppression command to match the pattern used elsewhere in this test file and to avoid potential timing issues. Move the line DateTime expectedExpiration = DateTime.Now.AddDays(duration); to before line 507 where new SuppressionCommand(opts).Run() is called, similar to how it's done in ExecuteSuppressionsWithReviewerNameAndDate (line 30) and ExecuteSuppressionsWithExpiration (line 166).
|
@copilot apply changes based on the comments in this thread |
…lly cleanup, use Select() for mapping Co-authored-by: gfs <[email protected]>
Applied all three changes from the code review:
Commit: b0d611f |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
suppresscommand.Where()filtering.Select()for mapping in foreach loopSummary
This PR fixes issue #588 where XML suppressions were not properly commented when using the DevSkim CLI suppress command.
Changes Made:
Added XML comment syntax to
comments.jsonxmllanguage withprefix: "<!--"andsuffix: "-->"Added comprehensive test coverage (13 new tests)
Verification:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.