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

MMF-4048 Feature/severity modes #5843

Merged
merged 22 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
53ec8e5
SLVS-1582 Support new SLCore DTOs for rule descriptions (#5798)
georgii-borovinskikh-sonarsource Nov 7, 2024
9eb47fd
SLVS-1590 Add SLCore rpc contracts for taint issues (#5808)
georgii-borovinskikh-sonarsource Nov 7, 2024
20e75a5
SLVS-1596 Add GetEffectiveIssueDetailsAsync (#5814)
vnaskos-sonar Nov 8, 2024
53471d7
SLVS-1589 Update RaisedFindingDto to support new MQR/Std mode with ov…
gabriela-trutan-sonarsource Nov 11, 2024
d874560
SLVS-1606 Update SLCore to 10.9 release (#5817)
gabriela-trutan-sonarsource Nov 11, 2024
182600e
SLVS-1563 Raise CurrentConfigurationScopeChanged when configuration s…
gabriela-trutan-sonarsource Oct 30, 2024
0ef0ce1
SLVS-1612 Update the RaiseFindingToAnalysisIssueConverter (#5819)
gabriela-trutan-sonarsource Nov 11, 2024
515cc73
SLVS-1613 Add conversion from TaintVulnerabilityDto to IAnalysisIssue…
georgii-borovinskikh-sonarsource Nov 12, 2024
c881a43
SLVS-1597 Store SLCore issue id in AnalysisIssue (#5823)
gabriela-trutan-sonarsource Nov 12, 2024
be9af17
SLVS-1614 Fix Category in the error list for MQR mode (#5822)
gabriela-trutan-sonarsource Nov 12, 2024
c4e925c
SLVS-1621 Clean up custom SSE implementation for taints (#5826)
georgii-borovinskikh-sonarsource Nov 14, 2024
97546b3
SLVS-1592 Update TaintStore with taints from SLCore (#5821)
georgii-borovinskikh-sonarsource Nov 14, 2024
940f50a
SLVS-1598 Use getEffectiveIssueDetails for issues with SLCore id inst…
gabriela-trutan-sonarsource Nov 14, 2024
b2b09aa
SLVS-1616 TaintIssuesControl & TaintIssuesControlViewModel: remove An…
georgii-borovinskikh-sonarsource Nov 14, 2024
dc98648
SLVS-1623 Move CleanCodeAttribute enum conversion from IRuleInfoConve…
gabriela-trutan-sonarsource Nov 15, 2024
ddb5690
SLVS-1628 Remove taint related methods from SonarQubeService (#5833)
georgii-borovinskikh-sonarsource Nov 15, 2024
f4b44d5
SLVS-1632 Add the ISonarProjectBranchSlCoreService interface (#5835)
vnaskos-sonar Nov 15, 2024
435529c
SLVS-1625 CaYC: Replace Moq with Nsubstitute (#5836)
gabriela-trutan-sonarsource Nov 15, 2024
4db7b60
SLVS-1622 Receive server taint vulnerabilities updates via SLCore (#5…
georgii-borovinskikh-sonarsource Nov 18, 2024
a6cf39a
SLVS-1630 Provide issue context to rule help (#5840)
georgii-borovinskikh-sonarsource Nov 18, 2024
2cb2439
SLVS-1602 Improve branch-awareness for SLCore integration (#5844)
vnaskos-sonar Nov 20, 2024
2473e4c
SLVS-1635 Update SLCore to 10.10.0.79572 (#5845)
georgii-borovinskikh-sonarsource Nov 20, 2024
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
7 changes: 6 additions & 1 deletion SonarLint.VisualStudio.Integration.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,9 @@
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Async/@EntryIndexedValue">False</s:String>
<s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Mutable/@EntryIndexedValue">False</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpAutoNaming/IsNotificationDisabled/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Dpa/IsNoEtwHostNotificationEnabled/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/Dpa/IsNoEtwHostNotificationEnabled/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002EMemberReordering_002EMigrations_002ECSharpFileLayoutPatternRemoveIsAttributeUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
1 change: 1 addition & 0 deletions src/CFamily.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,7 @@
"type": "Project",
"dependencies": {
"SonarLint.VisualStudio.ConnectedMode": "[1.0.0, )",
"SonarLint.VisualStudio.IssueVisualization.Security": "[1.0.0, )",
"SonarLint.VisualStudio.SLCore": "[1.0.0, )"
}
},
Expand Down
103 changes: 46 additions & 57 deletions src/ConnectedMode.UnitTests/ServerSentEvents/SSESessionFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,81 +18,70 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/


using System;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents;
using SonarLint.VisualStudio.Core;
using SonarLint.VisualStudio.TestInfrastructure;
using SonarQube.Client;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents.Taint;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents.Issue;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents.QualityProfile;

namespace SonarLint.VisualStudio.ConnectedMode.UnitTests.ServerSentEvents
namespace SonarLint.VisualStudio.ConnectedMode.UnitTests.ServerSentEvents;

[TestClass]
public class SSESessionFactoryTests
{
[TestClass]
public class SSESessionFactoryTests
[TestMethod]
public void MefCtor_CheckIsExported()
{
[TestMethod]
public void MefCtor_CheckIsExported()
{
MefTestHelpers.CheckTypeCanBeImported<SSESessionFactory, ISSESessionFactory>(
MefTestHelpers.CreateExport<ISonarQubeService>(),
MefTestHelpers.CreateExport<ITaintServerEventSourcePublisher>(),
MefTestHelpers.CreateExport<IIssueServerEventSourcePublisher>(),
MefTestHelpers.CreateExport<IQualityProfileServerEventSourcePublisher>(),
MefTestHelpers.CreateExport<ILogger>(),
MefTestHelpers.CreateExport<IThreadHandling>());
}
MefTestHelpers.CheckTypeCanBeImported<SSESessionFactory, ISSESessionFactory>(
MefTestHelpers.CreateExport<ISonarQubeService>(),
MefTestHelpers.CreateExport<IIssueServerEventSourcePublisher>(),
MefTestHelpers.CreateExport<IQualityProfileServerEventSourcePublisher>(),
MefTestHelpers.CreateExport<ILogger>(),
MefTestHelpers.CreateExport<IThreadHandling>());
}

[TestMethod]
public void Create_ReturnsCorrectType()
{
var testSubject = CreateTestSubject();
[TestMethod]
public void Create_ReturnsCorrectType()
{
var testSubject = CreateTestSubject();

var sseSession = testSubject.Create("MyProjectName", null);
var sseSession = testSubject.Create("MyProjectName", null);

sseSession.Should().NotBeNull().And.BeOfType<SSESessionFactory.SSESession>();
}
sseSession.Should().NotBeNull().And.BeOfType<SSESessionFactory.SSESession>();
}

[TestMethod]
public void Create_AfterDispose_Throws()
{
var testSubject = CreateTestSubject();
[TestMethod]
public void Create_AfterDispose_Throws()
{
var testSubject = CreateTestSubject();

testSubject.Dispose();
Action act = () => testSubject.Create("MyProjectName", null);
testSubject.Dispose();
Action act = () => testSubject.Create("MyProjectName", null);

act.Should().Throw<ObjectDisposedException>();
}
act.Should().Throw<ObjectDisposedException>();
}

[TestMethod]
public void Dispose_IdempotentAndDisposesPublishers()
{
var taintPublisherMock = new Mock<ITaintServerEventSourcePublisher>();
var issuesPublisherMock = new Mock<IIssueServerEventSourcePublisher>();
var qualityProfilePublisherMock = new Mock<IQualityProfileServerEventSourcePublisher>();
var testSubject = CreateTestSubject(taintPublisherMock, issuesPublisherMock, qualityProfilePublisherMock);
[TestMethod]
public void Dispose_IdempotentAndDisposesPublishers()
{
var issuesPublisherMock = new Mock<IIssueServerEventSourcePublisher>();
var qualityProfilePublisherMock = new Mock<IQualityProfileServerEventSourcePublisher>();
var testSubject = CreateTestSubject(issuesPublisherMock, qualityProfilePublisherMock);

testSubject.Dispose();
testSubject.Dispose();
testSubject.Dispose();
testSubject.Dispose();
testSubject.Dispose();
testSubject.Dispose();

taintPublisherMock.Verify(p => p.Dispose(), Times.Once);
issuesPublisherMock.Verify(p => p.Dispose(), Times.Once);
qualityProfilePublisherMock.Verify(p => p.Dispose(), Times.Once);
}
issuesPublisherMock.Verify(p => p.Dispose(), Times.Once);
qualityProfilePublisherMock.Verify(p => p.Dispose(), Times.Once);
}

private SSESessionFactory CreateTestSubject(Mock<ITaintServerEventSourcePublisher> taintPublisher = null,
Mock<IIssueServerEventSourcePublisher> issuePublisher = null,
Mock<IQualityProfileServerEventSourcePublisher> qualityProfileServerEventSourcePublisher = null)
{
return new SSESessionFactory(Mock.Of<ISonarQubeService>(),
taintPublisher?.Object ?? Mock.Of<ITaintServerEventSourcePublisher>(),
issuePublisher?.Object ?? Mock.Of<IIssueServerEventSourcePublisher>(),
qualityProfileServerEventSourcePublisher?.Object ?? Mock.Of<IQualityProfileServerEventSourcePublisher>(),
private SSESessionFactory CreateTestSubject(Mock<IIssueServerEventSourcePublisher> issuePublisher = null,
Mock<IQualityProfileServerEventSourcePublisher> qualityProfileServerEventSourcePublisher = null) =>
new(Mock.Of<ISonarQubeService>(),
issuePublisher?.Object ?? Mock.Of<IIssueServerEventSourcePublisher>(),
qualityProfileServerEventSourcePublisher?.Object ?? Mock.Of<IQualityProfileServerEventSourcePublisher>(),
Mock.Of<IThreadHandling>(),
Mock.Of<ILogger>());
}
}
Mock.Of<ILogger>());
}
23 changes: 1 addition & 22 deletions src/ConnectedMode.UnitTests/ServerSentEvents/SSESessionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents;
using SonarLint.VisualStudio.Core;
using SonarLint.VisualStudio.TestInfrastructure;
using SonarQube.Client;
using SonarQube.Client.Models.ServerSentEvents;
using SonarQube.Client.Models.ServerSentEvents.ClientContract;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents.Taint;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents.Issue;
using SonarLint.VisualStudio.ConnectedMode.ServerSentEvents.QualityProfile;

Expand Down Expand Up @@ -62,22 +55,17 @@ public async Task PumpAllAsync_SelectsPublisherCorrectlyAndPreservesOrderWithinT
var inputSequence = new IServerEvent[]
{
Mock.Of<IIssueChangedServerEvent>(),
Mock.Of<ITaintVulnerabilityRaisedServerEvent>(),
Mock.Of<IQualityProfileEvent>(),
Mock.Of<IIssueChangedServerEvent>(),
Mock.Of<ITaintVulnerabilityClosedServerEvent>(),
Mock.Of<ITaintVulnerabilityClosedServerEvent>(),
Mock.Of<IQualityProfileEvent>(),
Mock.Of<IIssueChangedServerEvent>(),
Mock.Of<ITaintVulnerabilityRaisedServerEvent>()
};
testScope.SetUpSwitchToBackgroundThread();
var sseStreamMock = testScope.SetUpSQServiceToSuccessfullyReturnSSEStreamReader();
testScope.SetUpSSEStreamReaderToReturnEventsSequenceAndExit(sseStreamMock, inputSequence);

await testScope.TestSubject.PumpAllAsync();

CheckEventsSequence<ITaintServerEvent>(testScope.TaintPublisherMock.Invocations);
CheckEventsSequence<IIssueChangedServerEvent>(testScope.IssuePublisherMock.Invocations);
CheckEventsSequence<IQualityProfileEvent>(testScope.QualityProfilePublisherMock.Invocations);

Expand All @@ -100,18 +88,15 @@ public async Task PumpAllAsync_WhenNullEvent_Ignores()
testScope.SetUpSSEStreamReaderToReturnEventsSequenceAndExit(sseStreamMock,
new IServerEvent[]
{
Mock.Of<ITaintVulnerabilityRaisedServerEvent>(),
Mock.Of<IQualityProfileEvent>(),
null,
Mock.Of<ITaintVulnerabilityRaisedServerEvent>(),
Mock.Of<IIssueChangedServerEvent>(),
Mock.Of<IQualityProfileEvent>(),
Mock.Of<IIssueChangedServerEvent>()
});

await testScope.TestSubject.PumpAllAsync();

testScope.TaintPublisherMock.Verify(publisher => publisher.Publish(It.IsAny<ITaintServerEvent>()), Times.Exactly(2));
testScope.IssuePublisherMock.Verify(publisher => publisher.Publish(It.IsAny<IIssueChangedServerEvent>()), Times.Exactly(2));
testScope.QualityProfilePublisherMock.Verify(publisher => publisher.Publish(It.IsAny<IQualityProfileEvent>()), Times.Exactly(2));
}
Expand All @@ -126,16 +111,13 @@ public async Task PumpAllAsync_WhenUnsupportedEvent_Ignores()
testScope.SetUpSSEStreamReaderToReturnEventsSequenceAndExit(sseStreamMock,
new IServerEvent[]
{
Mock.Of<ITaintVulnerabilityRaisedServerEvent>(),
Mock.Of<IQualityProfileEvent>(),
Mock.Of<IDummyServerEvent>(),
Mock.Of<ITaintVulnerabilityRaisedServerEvent>(),
Mock.Of<IIssueChangedServerEvent>()
});

await testScope.TestSubject.PumpAllAsync();

testScope.TaintPublisherMock.Verify(publisher => publisher.Publish(It.IsAny<ITaintServerEvent>()), Times.Exactly(2));
testScope.IssuePublisherMock.Verify(publisher => publisher.Publish(It.IsAny<IIssueChangedServerEvent>()), Times.Exactly(1));
testScope.QualityProfilePublisherMock.Verify(publisher => publisher.Publish(It.IsAny<IQualityProfileEvent>()), Times.Exactly(1));
}
Expand Down Expand Up @@ -232,7 +214,6 @@ public TestScope()
{
mockRepository = new MockRepository(MockBehavior.Strict);
SonarQubeServiceMock = mockRepository.Create<ISonarQubeService>();
TaintPublisherMock = mockRepository.Create<ITaintServerEventSourcePublisher>(MockBehavior.Loose);
IssuePublisherMock = mockRepository.Create<IIssueServerEventSourcePublisher>(MockBehavior.Loose);
QualityProfilePublisherMock = mockRepository.Create<IQualityProfileServerEventSourcePublisher>(MockBehavior.Loose);
ThreadHandlingMock = mockRepository.Create<IThreadHandling>();
Expand All @@ -241,18 +222,16 @@ public TestScope()

var factory = new SSESessionFactory(
SonarQubeServiceMock.Object,
TaintPublisherMock.Object,
IssuePublisherMock.Object,
QualityProfilePublisherMock.Object,
ThreadHandlingMock.Object,
LoggerMock.Object);

TestSubject = factory.Create("blalala", OnSessionFailedAsyncMock.Object);
}

private Mock<IThreadHandling> ThreadHandlingMock { get; }
public Mock<ISonarQubeService> SonarQubeServiceMock { get; }
public Mock<ITaintServerEventSourcePublisher> TaintPublisherMock { get; }
public Mock<IIssueServerEventSourcePublisher> IssuePublisherMock { get; }
public Mock<IQualityProfileServerEventSourcePublisher> QualityProfilePublisherMock { get; }
public Mock<ILogger> LoggerMock { get; }
Expand Down
Loading