Skip to content

Commit

Permalink
CaYC: cleanup code applied in touched files
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriela-trutan-sonarsource committed Dec 24, 2024
1 parent 43eb67f commit e65430e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/SonarQube.Client/SonarQubeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,22 +579,15 @@ private static bool ShouldUseBearer(ServerInfo serverInfo)

private async Task<ServerInfo> GetServerInfo(ConnectionInformation connection, CancellationToken token)
{
var http = CreateHttpClient(connection.ServerUri, new NoCredentials(), shouldUseBearer:true);
var http = CreateHttpClient(connection.ServerUri, new NoCredentials(), shouldUseBearer: true);
var versionResponse = await InvokeUncheckedRequestAsync<IGetVersionRequest, string>(request => { }, http, token);
var serverInfo = new ServerInfo(Version.Parse(versionResponse), connection.IsSonarCloud ? ServerType.SonarCloud : ServerType.SonarQube);
return serverInfo;
}

private HttpClient CreateHttpClient(Uri baseAddress, IConnectionCredentials credentials, bool shouldUseBearer)
{
var client = new HttpClient(messageHandler)
{
BaseAddress = baseAddress,
DefaultRequestHeaders =
{
Authorization = AuthenticationHeaderFactory.Create(credentials, shouldUseBearer),
},
};
var client = new HttpClient(messageHandler) { BaseAddress = baseAddress, DefaultRequestHeaders = { Authorization = AuthenticationHeaderFactory.Create(credentials, shouldUseBearer), }, };
client.DefaultRequestHeaders.Add("User-Agent", userAgent);
return client;
}
Expand Down

0 comments on commit e65430e

Please sign in to comment.