Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SLVS-1731 Remove ISecondaryIssueHashUpdater & SQService.GetSourceCode…
Browse files Browse the repository at this point in the history
…Async (#5927)
georgii-borovinskikh-sonarsource authored and vnaskos-sonar committed Jan 10, 2025
1 parent 32094d5 commit 349ff16
Showing 14 changed files with 10 additions and 600 deletions.
103 changes: 0 additions & 103 deletions src/SonarQube.Client.Tests/CallRealServerTestHarness.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ public void ConfigureSonarQube_Writes_Debug_Messages()
"Registered SonarQube.Client.Api.V2_10.GetVersionRequest for 2.1",
"Registered SonarQube.Client.Api.V2_60.GetPropertiesRequest for 2.6",
"Registered SonarQube.Client.Api.V3_30.ValidateCredentialsRequest for 3.3",
"Registered SonarQube.Client.Api.V5_00.GetSourceCodeRequest for 5.0",
"Registered SonarQube.Client.Api.V5_10.GetIssuesRequest for 5.1",
"Registered SonarQube.Client.Api.V5_10.GetLanguagesRequest for 5.1",
"Registered SonarQube.Client.Api.V5_20.GetQualityProfileChangeLogRequest for 5.2",
@@ -88,7 +87,6 @@ public void ConfigureSonarCloud_Writes_Debug_Messages()
{
"Registered SonarQube.Client.Api.V2_10.GetVersionRequest",
"Registered SonarQube.Client.Api.V3_30.ValidateCredentialsRequest",
"Registered SonarQube.Client.Api.V5_00.GetSourceCodeRequest",
"Registered SonarQube.Client.Api.V5_10.GetLanguagesRequest",
"Registered SonarQube.Client.Api.V5_40.GetModulesRequest",
"Registered SonarQube.Client.Api.V10_2.GetRulesWithCCTRequest",
@@ -141,7 +139,6 @@ public void ConfigureSonarQube_CheckAllRequestsImplemented()
testSubject.Create<IGetRulesRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetVersionRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IValidateCredentialsRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetSourceCodeRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetProjectBranchesRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetExclusionsRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetSonarLintEventStream>(serverInfo).Should().NotBeNull();
@@ -172,7 +169,6 @@ public void ConfigureSonarCloud_CheckAllRequestsImplemented()
testSubject.Create<IGetRulesRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetVersionRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IValidateCredentialsRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetSourceCodeRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetProjectBranchesRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<IGetExclusionsRequest>(serverInfo).Should().NotBeNull();
testSubject.Create<ITransitionIssueRequest>(serverInfo).Should().NotBeNull();
Original file line number Diff line number Diff line change
@@ -46,13 +46,13 @@ public async Task GetProjectDashboardUrl_DisconnectedInTheMiddle_NoException()

protected internal override SonarQubeService CreateTestSubject()
{
return new DisconnectingService(messageHandler.Object, UserAgent, logger, requestFactorySelector, secondaryIssueHashUpdater.Object);
return new DisconnectingService(messageHandler.Object, UserAgent, logger, requestFactorySelector);
}

internal class DisconnectingService : SonarQubeService
{
internal DisconnectingService(HttpMessageHandler messageHandler, string userAgent, ILogger logger, IRequestFactorySelector requestFactorySelector, ISecondaryIssueHashUpdater secondaryIssueHashUpdater)
: base(messageHandler, userAgent, logger, requestFactorySelector, secondaryIssueHashUpdater, null)
internal DisconnectingService(HttpMessageHandler messageHandler, string userAgent, ILogger logger, IRequestFactorySelector requestFactorySelector)
: base(messageHandler, userAgent, logger, requestFactorySelector, null)
{
}

85 changes: 0 additions & 85 deletions src/SonarQube.Client.Tests/SonarQubeService_GetSourceCodeAsync.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -46,13 +46,13 @@ public async Task GetViewHotspotUrl_DisconnectedInTheMiddle_NoException()

protected internal override SonarQubeService CreateTestSubject()
{
return new DisconnectingService(messageHandler.Object, UserAgent, logger, requestFactorySelector, secondaryIssueHashUpdater.Object);
return new DisconnectingService(messageHandler.Object, UserAgent, logger, requestFactorySelector);
}

internal class DisconnectingService : SonarQubeService
{
internal DisconnectingService(HttpMessageHandler messageHandler, string userAgent, ILogger logger, IRequestFactorySelector requestFactorySelector, ISecondaryIssueHashUpdater secondaryIssueHashUpdater)
: base(messageHandler, userAgent, logger, requestFactorySelector, secondaryIssueHashUpdater, null)
internal DisconnectingService(HttpMessageHandler messageHandler, string userAgent, ILogger logger, IRequestFactorySelector requestFactorySelector)
: base(messageHandler, userAgent, logger, requestFactorySelector, null)
{
}

4 changes: 2 additions & 2 deletions src/SonarQube.Client.Tests/SonarQubeService_Miscellaneous.cs
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ public async Task SonarQubeService_UsesFactorySelector(string serverUrl, bool is
var selectorMock = new Mock<IRequestFactorySelector>();
selectorMock.Setup(x => x.Select(isSonarCloud, logger)).Returns(requestFactoryMock.Object);

var testSubject = new SonarQubeService(Mock.Of<HttpMessageHandler>(), "user-agent", logger, selectorMock.Object, Mock.Of<ISecondaryIssueHashUpdater>(), null);
var testSubject = new SonarQubeService(Mock.Of<HttpMessageHandler>(), "user-agent", logger, selectorMock.Object, null);
await testSubject.ConnectAsync(connectionInfo, CancellationToken.None);

selectorMock.Verify(x => x.Select(isSonarCloud, logger), Times.Once);
@@ -109,7 +109,7 @@ public async Task SonarQubeService_FactorySelector_RequestsNewFactoryOnEachConne
selectorMock.Setup(x => x.Select(false /* isSonarCloud */, logger)).Returns(qubeFactoryMock.Object);
selectorMock.Setup(x => x.Select(true /* isSonarCloud */, logger)).Returns(cloudFactoryMock.Object);

var testSubject = new SonarQubeService(Mock.Of<HttpMessageHandler>(), "user-agent", logger, selectorMock.Object, Mock.Of<ISecondaryIssueHashUpdater>(), null);
var testSubject = new SonarQubeService(Mock.Of<HttpMessageHandler>(), "user-agent", logger, selectorMock.Object, null);

// 1. Connect to SonarQube
await testSubject.ConnectAsync(sonarQubeConnectionInfo, CancellationToken.None);
4 changes: 1 addition & 3 deletions src/SonarQube.Client.Tests/SonarQubeService_TestBase.cs
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ public class SonarQubeService_TestBase
protected TestLogger logger;

// Note: can't be protected because the interfaces are internal
internal Mock<ISecondaryIssueHashUpdater> secondaryIssueHashUpdater;
internal IRequestFactorySelector requestFactorySelector;
internal Mock<ISSEStreamReaderFactory> sseStreamFactory;

@@ -60,7 +59,6 @@ public void TestInitialize()
messageHandler = new Mock<HttpMessageHandler>(MockBehavior.Strict);

requestFactorySelector = new RequestFactorySelector();
secondaryIssueHashUpdater = new Mock<ISecondaryIssueHashUpdater>();
sseStreamFactory = new Mock<ISSEStreamReaderFactory>();

ResetService();
@@ -117,7 +115,7 @@ protected void ResetService()

protected internal virtual SonarQubeService CreateTestSubject()
{
return new SonarQubeService(messageHandler.Object, UserAgent, logger, requestFactorySelector, secondaryIssueHashUpdater.Object, sseStreamFactory.Object);
return new SonarQubeService(messageHandler.Object, UserAgent, logger, requestFactorySelector, sseStreamFactory.Object);
}

private static IUsernameAndPasswordCredentials MockBasicAuthCredentials(string userName, SecureString password)
2 changes: 0 additions & 2 deletions src/SonarQube.Client/Api/DefaultConfiguration.cs
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ public static RequestFactory ConfigureSonarQube(RequestFactory requestFactory)
.RegisterRequest<IGetVersionRequest, V2_10.GetVersionRequest>("2.1")
.RegisterRequest<IGetPropertiesRequest, V2_60.GetPropertiesRequest>("2.6")
.RegisterRequest<IValidateCredentialsRequest, V3_30.ValidateCredentialsRequest>("3.3")
.RegisterRequest<IGetSourceCodeRequest, V5_00.GetSourceCodeRequest>("5.0")
.RegisterRequest<IGetIssuesRequest, V5_10.GetIssuesRequest>("5.1")
.RegisterRequest<IGetLanguagesRequest, V5_10.GetLanguagesRequest>("5.1")
.RegisterRequest<IGetQualityProfileChangeLogRequest, V5_20.GetQualityProfileChangeLogRequest>("5.2")
@@ -71,7 +70,6 @@ public static UnversionedRequestFactory ConfigureSonarCloud(UnversionedRequestFa
requestFactory
.RegisterRequest<IGetVersionRequest, V2_10.GetVersionRequest>()
.RegisterRequest<IValidateCredentialsRequest, V3_30.ValidateCredentialsRequest>()
.RegisterRequest<IGetSourceCodeRequest, V5_00.GetSourceCodeRequest>()
.RegisterRequest<IGetLanguagesRequest, V5_10.GetLanguagesRequest>()
.RegisterRequest<IGetModulesRequest, V5_40.GetModulesRequest>()
.RegisterRequest<IGetRulesRequest, V10_2.GetRulesWithCCTRequest>()
29 changes: 0 additions & 29 deletions src/SonarQube.Client/Api/IGetSourceCodeRequest.cs

This file was deleted.

39 changes: 0 additions & 39 deletions src/SonarQube.Client/Api/V5_00/GetSourceCodeRequest.cs

This file was deleted.

141 changes: 0 additions & 141 deletions src/SonarQube.Client/Helpers/SecondaryLocationHashUpdater.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/SonarQube.Client/ISonarQubeService.cs
Original file line number Diff line number Diff line change
@@ -138,12 +138,6 @@ Task<IList<SonarQubeNotification>> GetNotificationEventsAsync(string projectKey,
/// <remarks>The method does not check whether the project or hotspot exists or not</remarks>
Uri GetViewHotspotUrl(string projectKey, string hotspotKey);

/// <summary>
/// Returns the source code for the specified file
/// </summary>
/// <param name="fileKey">e.g. my_project:src/foo/Bar.php</param>
Task<string> GetSourceCodeAsync(string fileKey, CancellationToken token);

/// <summary>
/// Returns branch information for the specified project key
/// </summary>
13 changes: 1 addition & 12 deletions src/SonarQube.Client/SonarQubeService.cs
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ public class SonarQubeService : ISonarQubeService, IDisposable
private readonly string userAgent;
private readonly ILogger logger;
private readonly IRequestFactorySelector requestFactorySelector;
private readonly ISecondaryIssueHashUpdater secondaryIssueHashUpdater;
private readonly ISSEStreamReaderFactory sseStreamReaderFactory;

private const string MinSqVersionSupportingBearer = "10.4";
@@ -58,7 +57,7 @@ public async Task<bool> HasOrganizations(CancellationToken token)
public ServerInfo GetServerInfo() => currentServerInfo;

public SonarQubeService(HttpMessageHandler messageHandler, string userAgent, ILogger logger)
: this(messageHandler, userAgent, logger, new RequestFactorySelector(), new SecondaryLocationHashUpdater(), new SSEStreamReaderFactory(logger))
: this(messageHandler, userAgent, logger, new RequestFactorySelector(), new SSEStreamReaderFactory(logger))
{
}

@@ -67,7 +66,6 @@ public SonarQubeService(HttpMessageHandler messageHandler, string userAgent, ILo
string userAgent,
ILogger logger,
IRequestFactorySelector requestFactorySelector,
ISecondaryIssueHashUpdater secondaryIssueHashUpdater,
ISSEStreamReaderFactory sseStreamReaderFactory)
{
if (messageHandler == null)
@@ -87,7 +85,6 @@ public SonarQubeService(HttpMessageHandler messageHandler, string userAgent, ILo
this.logger = logger;

this.requestFactorySelector = requestFactorySelector;
this.secondaryIssueHashUpdater = secondaryIssueHashUpdater;
this.sseStreamReaderFactory = sseStreamReaderFactory;
}

@@ -493,14 +490,6 @@ public Uri GetViewHotspotUrl(string projectKey, string hotspotKey)
return new Uri(currentHttpClient.BaseAddress, string.Format(urlFormat, projectKey, hotspotKey));
}

public async Task<string> GetSourceCodeAsync(string fileKey, CancellationToken token) =>
await InvokeCheckedRequestAsync<IGetSourceCodeRequest, string>(
request =>
{
request.FileKey = fileKey;
},
token);

public async Task<IList<SonarQubeProjectBranch>> GetProjectBranchesAsync(string projectKey, CancellationToken token) =>
await InvokeCheckedRequestAsync<IGetProjectBranchesRequest, SonarQubeProjectBranch[]>(
request =>

0 comments on commit 349ff16

Please sign in to comment.