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

Cleanup and sonar fixes #206

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 0 additions & 11 deletions src/RepoM.Api/IO/IPathFinder.cs

This file was deleted.

5 changes: 4 additions & 1 deletion src/RepoM.App/NotifyIconResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
reuse the same context menu (which is a resource) again (which will have its DataContext set to the old TaskbarIcon)
-->
<controls:AcrylicContextMenu x:Shared="false" x:Key="SysTrayMenu">
<controls:AcrylicMenuItem Header="{DynamicResource Open}" Command="{Binding OpenCommand}" />
<controls:AcrylicContextMenu.DataContext>
<app:NotifyIconViewModel/>
</controls:AcrylicContextMenu.DataContext>
<controls:AcrylicMenuItem Header="{DynamicResource Open}" Command="{Binding OpenCommand}" />
<controls:AcrylicMenuItem Header="{DynamicResource StartWithWindows}"
Command="{Binding StartWithWindows}"
Visibility="{Binding RelativeSource={RelativeSource Self}, Path=IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}}"
Expand Down
8 changes: 4 additions & 4 deletions src/RepoM.App/NotifyIconViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ public class NotifyIconViewModel
/// <summary>
/// Shows a window, if none is already open.
/// </summary>
public ICommand OpenCommand =>
public static ICommand OpenCommand =>
new DelegateCommand
{
CanExecuteFunc = () => (Application.Current.MainWindow as MainWindow)?.IsShown == false,
CommandAction = () => (Application.Current.MainWindow as MainWindow)?.ShowAndActivate(),
};

public ICommand StartWithWindows =>
public static ICommand StartWithWindows =>
new DelegateCommand
{
CanExecuteFunc = () => !AutoStart.IsStartup(APP_NAME),
CommandAction = () => AutoStart.SetStartup(APP_NAME, true),
};

public ICommand DoNotStartWithWindows =>
public static ICommand DoNotStartWithWindows =>
new DelegateCommand
{
CanExecuteFunc = () => AutoStart.IsStartup(APP_NAME),
Expand All @@ -40,7 +40,7 @@ public class NotifyIconViewModel
/// <summary>
/// Shuts down the application.
/// </summary>
public ICommand ExitApplicationCommand =>
public static ICommand ExitApplicationCommand =>
new DelegateCommand
{
CommandAction = () => Application.Current.Shutdown(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public AzureDevOpsPullRequestService(IAzureDevopsConfiguration configuration, IL
{
if (string.IsNullOrEmpty(configuration.AzureDevOpsPersonalAccessToken))
{
//throw new ArgumentNullException(nameof(configuration.AzureDevOpsPersonalAccessToken));
_logger.LogInformation("No Azure configuration present");
_logger.LogInformation("No Azure configuration present. Module will not be enabled.");
}
else
{
Expand All @@ -56,7 +55,6 @@ public AzureDevOpsPullRequestService(IAzureDevopsConfiguration configuration, IL
_httpClient.DefaultRequestHeaders.Accept.Add(new("application/json"));
_httpClient.DefaultRequestHeaders.Authorization = new("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($":{_configuration.AzureDevOpsPersonalAccessToken}")));
}

}
catch (Exception e)
{
Expand Down Expand Up @@ -124,7 +122,7 @@ public async Task CreatePullRequestWithAutoCompleteAsync(IRepository repository,

if (!response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var content = await response.Content.ReadAsStringAsync(CancellationToken.None);
_logger.LogError("PR creation went wrong with following response: {Message}", content);
throw new HttpRequestException(content, null, response.StatusCode);
}
Expand Down
8 changes: 4 additions & 4 deletions src/RepoM.Plugin.Heidi/Internal/ExtractRepositoryFromHeidi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public bool TryExtract(HeidiSingleDatabaseConfiguration config, [NotNullWhen(tru
return true;
}

private static ReadOnlySpan<char> HandleHashTag(ReadOnlySpan<char> comment, ICollection<string> tags)
private static ReadOnlySpan<char> HandleHashTag(ReadOnlySpan<char> comment, List<string> tags)
{
comment = comment["#".Length..];

Expand All @@ -91,7 +91,7 @@ private static ReadOnlySpan<char> HandleHashTag(ReadOnlySpan<char> comment, ICol
return comment;
}

private static ReadOnlySpan<char> HandleHashTagName(ReadOnlySpan<char> comment, ICollection<string> names)
private static ReadOnlySpan<char> HandleHashTagName(ReadOnlySpan<char> comment, List<string> names)
{
comment = comment[HASH_TAG_NAME.Length..];

Expand Down Expand Up @@ -124,7 +124,7 @@ private static ReadOnlySpan<char> HandleHashTagName(ReadOnlySpan<char> comment,
return comment;
}

private static ReadOnlySpan<char> HandleHashTagOrder(ReadOnlySpan<char> comment, ICollection<int> orders)
private static ReadOnlySpan<char> HandleHashTagOrder(ReadOnlySpan<char> comment, List<int> orders)
{
comment = comment[HASH_TAG_ORDER.Length..];

Expand All @@ -150,7 +150,7 @@ private static ReadOnlySpan<char> HandleHashTagOrder(ReadOnlySpan<char> comment,
return comment;
}

private static ReadOnlySpan<char> HandleHashTagRepo(ReadOnlySpan<char> comment, ICollection<string> repos)
private static ReadOnlySpan<char> HandleHashTagRepo(ReadOnlySpan<char> comment, List<string> repos)
{
comment = comment[HASH_TAG_REPO.Length..];

Expand Down
91 changes: 0 additions & 91 deletions src/RepoM.Plugin.WindowsExplorerGitInfo/PInvoke/WindowFinder.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using FluentAssertions;

namespace RepoM.Plugin.AzureDevOps.Tests;

using System;
Expand Down Expand Up @@ -76,9 +78,10 @@ public async Task RegisterServices_ShouldFail_WhenExternalDependenciesAreNotRegi

// act
await sut.RegisterServicesAsync(_container, _packageConfiguration);
Action act = () => _container.Verify(VerificationOption.VerifyAndDiagnose);

// assert
Assert.Throws<InvalidOperationException>(() => _container.Verify(VerificationOption.VerifyAndDiagnose));
act.Should().ThrowExactly<InvalidOperationException>();
}

[Theory]
Expand Down
4 changes: 3 additions & 1 deletion tests/RepoM.Plugin.Heidi.Tests/HeidiPackageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace RepoM.Plugin.Heidi.Tests;
using System.IO.Abstractions;
using System.Threading.Tasks;
using FakeItEasy;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using RepoM.Core.Plugin;
using RepoM.Plugin.Heidi.PersistentConfiguration;
Expand Down Expand Up @@ -93,9 +94,10 @@ public async Task RegisterServices_ShouldFail_WhenExternalDependenciesAreNotRegi

// act
await sut.RegisterServicesAsync(_container, _packageConfiguration);
Action act = () => _container.Verify(VerificationOption.VerifyAndDiagnose);

// assert
Assert.Throws<InvalidOperationException>(() => _container.Verify(VerificationOption.VerifyAndDiagnose));
act.Should().ThrowExactly<InvalidOperationException>(); ;
}

private static void RegisterExternals(Container container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public void RegisterServices_ShouldFail_WhenExternalDependenciesAreNotRegistered

// act
sut.RegisterServices(_container);
Action act = () => _container.Verify(VerificationOption.VerifyAndDiagnose);

// assert
Assert.Throws<InvalidOperationException>(() => _container.Verify(VerificationOption.VerifyAndDiagnose));
act.Should().ThrowExactly<InvalidOperationException>();
}

private static void RegisterExternals(Container container)
Expand Down
8 changes: 4 additions & 4 deletions tests/RepoM.Plugin.Misc.Tests/PluginInformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public void PluginAssembly_ShouldContainPackageAttributeWithValidValues(Assembly
PackageAttribute? result = assembly.GetCustomAttribute<PackageAttribute>();

// assert
Assert.NotNull(result);
result.Name.Should().NotBeNullOrWhiteSpace();
result.Should().NotBeNull();
result!.Name.Should().NotBeNullOrWhiteSpace();
result.ToolTip.Should().NotBeNullOrWhiteSpace();
}

Expand Down Expand Up @@ -53,7 +53,7 @@ public void AssemblyDescription_ShouldBeUnique()
private static PackageAttribute GetFromAssembly(Assembly assembly)
{
PackageAttribute? result = assembly.GetCustomAttribute<PackageAttribute>();
Assert.NotNull(result);
return result;
result.Should().NotBeNull();
return result!;
}
}
4 changes: 3 additions & 1 deletion tests/RepoM.Plugin.SonarCloud.Tests/SonarCloudPackageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace RepoM.Plugin.SonarCloud.Tests;
using Microsoft.Extensions.Logging;
using RepoM.Core.Plugin;
using RepoM.Plugin.SonarCloud.PersistentConfiguration;
using FluentAssertions;

public class SonarCloudPackageTest
{
Expand Down Expand Up @@ -76,9 +77,10 @@ public async Task RegisterServices_ShouldFail_WhenExternalDependenciesAreNotRegi

// act
await sut.RegisterServicesAsync(_container, _packageConfiguration);
Action act = () => _container.Verify(VerificationOption.VerifyAndDiagnose);

// assert
Assert.Throws<InvalidOperationException>(() => _container.Verify(VerificationOption.VerifyAndDiagnose));
act.Should().ThrowExactly<InvalidOperationException>();
}

private void RegisterExternals(Container container)
Expand Down
4 changes: 3 additions & 1 deletion tests/RepoM.Plugin.Statistics.Tests/StatisticsPackageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace RepoM.Plugin.Statistics.Tests;
using System.IO.Abstractions;
using System.Threading.Tasks;
using FakeItEasy;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using RepoM.Core.Plugin;
using RepoM.Core.Plugin.Common;
Expand Down Expand Up @@ -75,9 +76,10 @@ public async Task RegisterServices_ShouldFail_WhenExternalDependenciesAreNotRegi

// act
await sut.RegisterServicesAsync(_container, _packageConfiguration);
Action act = () => _container.Verify(VerificationOption.VerifyAndDiagnose);

// assert
Assert.Throws<InvalidOperationException>(() => _container.Verify(VerificationOption.VerifyAndDiagnose));
act.Should().ThrowExactly<InvalidOperationException>();
}

private static void RegisterExternals(Container container)
Expand Down
Loading