Skip to content

Commit

Permalink
correct some sonarcloud complaints and use newer hashing library (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
sensslen authored Dec 29, 2024
1 parent d1a88ff commit 61975d0
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/NuGetUtility/NuGetUtility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
<PackageReference Include="System.IO.Hashing" Version="9.0.0" />
<PackageReference Include="System.Collections.Immutable" Version="9.0.0" />
<PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" Version="17.12.*" />
<PackageReference Include="PolySharp" Version="1.15.*">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NuGetUtility.Wrapper.NuGetWrapper
{
internal class NugetWrapperException : Exception
public class NugetWrapperException : Exception
{
public NugetWrapperException(string message)
: base(message) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace NuGetUtility.Wrapper.NuGetWrapper.Protocol.Core.Types
{
internal class CachingDisposableSourceRepository : IDisposableSourceRepository
internal sealed class CachingDisposableSourceRepository : IDisposableSourceRepository
{
private readonly SourceCacheContext _cacheContext = new SourceCacheContext();
private readonly SourceRepository _sourceRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace NuGetUtility.Wrapper.NuGetWrapper.Protocol.Core.Types
{
internal class WrappedSourceRepositoryProvider : IWrappedSourceRepositoryProvider, IDisposable
internal sealed class WrappedSourceRepositoryProvider : IWrappedSourceRepositoryProvider, IDisposable
{
private readonly IDisposableSourceRepository[] _repositories;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace NuGetUtility.Test.Helper.AutoFixture.NuGet.Versioning
{
[AttributeUsage(AttributeTargets.Method)]
public class ExtendedAutoDataAttribute : AutoDataAttribute
{
public ExtendedAutoDataAttribute(params System.Type[] customizations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace NuGetUtility.Test.Helper.AutoFixture.NuGet.Versioning
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ExtendedInlineAutoDataAttribute : InlineAutoDataAttribute
{
public ExtendedInlineAutoDataAttribute(System.Type customization, params object[] arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ internal class NuGetVersionBuilder : ISpecimenBuilder

public object Create(object request, ISpecimenContext context)
{
if (request is System.Type t)
if (request is System.Type t && t == typeof(INuGetVersion))
{
if (t == typeof(INuGetVersion))
{
return new NuGetVersion($"{_rnd.Next(100, 999)}.{_rnd.Next(100, 999)}{GetPatch()}{GetBeta()}");
}
return new NuGetVersion($"{_rnd.Next(100, 999)}.{_rnd.Next(100, 999)}{GetPatch()}{GetBeta()}");
}

return new NoSpecimen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public int GetHashCode(LicenseValidationResult obj)
obj.PackageVersion,
obj.PackageProjectUrl);
}
private HashCode GetHashCode(List<ValidationError> validationErrors)
private static HashCode GetHashCode(List<ValidationError> validationErrors)
{
var code = new HashCode();
foreach (ValidationError error in validationErrors)
Expand Down
4 changes: 2 additions & 2 deletions tests/NuGetUtility.Test/Output/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void SetUp()
}
protected abstract IOutputFormatter CreateUut();

private T? GetNullable<T>(Faker faker, Func<T> getter) where T : class
private static T? GetNullable<T>(Faker faker, Func<T> getter) where T : class
{
if (faker.Random.Bool())
{
Expand All @@ -63,7 +63,7 @@ public void SetUp()
return getter();
}

private IEnumerable<ValidationError> GetErrorList(Faker faker)
private static IEnumerable<ValidationError> GetErrorList(Faker faker)
{
int itemCount = faker.Random.Int(3, 10);
for (int i = 0; i < itemCount; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public async Task GetPackageInfo_Should_PreferLocalPackageCacheOverRepositories(
}
}

private void SetupPackagesForRepositories(IEnumerable<CustomPackageInformation> packages, IEnumerable<IPackageMetadataResource> packageMetadataResources)
private static void SetupPackagesForRepositories(IEnumerable<CustomPackageInformation> packages, IEnumerable<IPackageMetadataResource> packageMetadataResources)
{
foreach (CustomPackageInformation package in packages)
{
Expand Down

0 comments on commit 61975d0

Please sign in to comment.