Skip to content

Commit

Permalink
Bind SonarCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
jerone committed Aug 18, 2024
1 parent 6796913 commit feb8e62
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .sonarlint/Jvw.DevToys.SemverCalculator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"SonarCloudOrganization": "jerone",
"ProjectKey": "jerone_Jvw.DevToys.SemverCalculator"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Jvw.DevToys.SemverCalculator.Components;
/// <summary>
/// Cheat sheet component.
/// </summary>
internal class CheatSheetComponent
internal static class CheatSheetComponent
{
/// <summary>
/// Columns for the cheat sheet.
Expand Down
15 changes: 9 additions & 6 deletions Jvw.DevToys.SemverCalculator/Gui.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Net;
using System.Text.Json;
using DevToys.Api;
Expand Down Expand Up @@ -232,7 +233,7 @@ private List<IUIElement> MatchVersions()

foreach (var version in versions)
{
if (_includePreReleases == false && version.IsPrerelease)
if (!_includePreReleases && version.IsPrerelease)
{
continue;
}
Expand All @@ -258,7 +259,7 @@ public void OnDataReceived(string dataTypeName, object? parsedData)

private async Task<PackageJson?> FetchPackage(string packageName)
{
_logger.LogInformation($"Fetching package \"{packageName}\"...");
_logger.LogInformation("Fetching package \"{PackageName}\"...", packageName);
try
{
var client = new HttpClient();
Expand All @@ -268,7 +269,7 @@ public void OnDataReceived(string dataTypeName, object? parsedData)
var response = await client.GetAsync($"https://registry.npmjs.org/{packageName}/");

response.EnsureSuccessStatusCode();
_logger.LogInformation($"Fetched packages \"{packageName}\".");
_logger.LogInformation("Fetched packages \"{PackageName}\".", packageName);

var contentStream = await response.Content.ReadAsStreamAsync();

Expand All @@ -281,13 +282,15 @@ public void OnDataReceived(string dataTypeName, object? parsedData)
}
catch (HttpRequestException e) when (e.StatusCode == HttpStatusCode.NotFound)
{
_logger.LogWarning($"Package \"{packageName}\" not found.");
Console.WriteLine(e.Message);
#pragma warning disable S6667
_logger.LogWarning("Package \"{PackageName}\" not found.", packageName);
#pragma warning restore S6667
Debug.WriteLine(e.Message);
return null;
}
catch (Exception e)
{
_logger.LogError(e, $"Failed to fetch package \"{packageName}\".");
_logger.LogError(e, "Failed to fetch package \"{PackageName}\".", packageName);
Console.WriteLine(e.Message);
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Jvw.DevToys.SemverCalculator/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ internal static class Settings
/// <summary>
/// When user closes the HTTP agreement info-bar, this setting is set to true.
/// </summary>
public static SettingDefinition<bool> HttpAgreementClosed =
public static readonly SettingDefinition<bool> HttpAgreementClosed =
new(name: "Settings." + nameof(HttpAgreementClosed), defaultValue: false);
}

0 comments on commit feb8e62

Please sign in to comment.