Skip to content

Commit defa3ac

Browse files
Fix Codacy "issues"
Signed-off-by: Georg Rottensteiner <georg@georg-rottensteiner.de>
1 parent c7af6ec commit defa3ac

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

CycloneDX/Models/NugetInputModel.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
// SPDX-License-Identifier: Apache-2.0
1616
// Copyright (c) OWASP Foundation. All Rights Reserved.
1717

18+
using System.Transactions;
19+
1820
namespace CycloneDX.Models
1921
{
2022
public static class NugetInputFactory
2123
{
2224
public static NugetInputModel Create(string baseUrl, string baseUrlUserName, string baseUrlUserPassword,
23-
bool isPasswordClearText, string feedName = "Unnamed Source" )
25+
bool isPasswordClearText)
26+
{
27+
return Create(baseUrl, baseUrlUserName, baseUrlUserPassword, isPasswordClearText, "Unnamed Source");
28+
}
29+
30+
public static NugetInputModel Create(string baseUrl, string baseUrlUserName, string baseUrlUserPassword,
31+
bool isPasswordClearText, string feedName )
2432
{
2533
if (string.IsNullOrEmpty(baseUrl))
2634
{
@@ -57,7 +65,7 @@ public NugetInputModel(string baseUrl, string baseUrlUserName, string baseUrlUse
5765
nugetUsername = baseUrlUserName;
5866
nugetPassword = baseUrlUserPassword;
5967
IsPasswordClearText = isPasswordClearText;
60-
nugetFeedName = nugetFeedName;
68+
nugetFeedName = feedName;
6169
}
6270
}
6371
}

CycloneDX/Runner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public async Task<int> HandleCommandAsync(RunOptions options)
134134
}
135135

136136
var packages = new HashSet<DotnetDependency>();
137-
var sources = new HashSet<NugetInputModel>();
137+
HashSet<NugetInputModel> sources = null;
138138

139139
// determine what we are analyzing and do the analysis
140140
var fullSolutionOrProjectFilePath = this.fileSystem.Path.GetFullPath(SolutionOrProjectFile);

CycloneDX/Services/NugetConfigFileService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ namespace CycloneDX.Services
2929
{
3030
public class NugetConfigFileService : INugetConfigFileService
3131
{
32-
private XmlReaderSettings _xmlReaderSettings = new XmlReaderSettings
32+
private readonly XmlReaderSettings _xmlReaderSettings = new XmlReaderSettings
3333
{
3434
Async = true
3535
};
3636

37-
private IFileSystem _fileSystem;
38-
private FileDiscoveryService _fileDiscoveryService;
37+
private readonly IFileSystem _fileSystem;
38+
private readonly FileDiscoveryService _fileDiscoveryService;
3939

4040
public NugetConfigFileService(IFileSystem fileSystem)
4141
{

CycloneDX/Services/NugetV3Service.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ namespace CycloneDX.Services
4040
/// </summary>
4141
public class NugetV3Service : INugetService
4242
{
43+
public class PackageNotFoundException : Exception
44+
{
45+
public PackageNotFoundException(string message) : base(message) { }
46+
47+
public PackageNotFoundException(string message, Exception innerException) : base(message, innerException) { }
48+
}
49+
50+
51+
4352
private readonly List<SourceRepository> _sourceRepositories;
4453
private readonly SourceCacheContext _sourceCacheContext;
4554
private readonly CancellationToken _cancellationToken;
@@ -360,7 +369,7 @@ await resource.CopyNupkgToStreamAsync(name, packageVersion, packageStream, _sour
360369
}
361370
if (!foundResource)
362371
{
363-
throw new Exception( $"Did not find package {name} {version}");
372+
throw new PackageNotFoundException( $"Did not find package {name} {version}");
364373
}
365374

366375
using PackageArchiveReader packageReader = new PackageArchiveReader(packageStream);

0 commit comments

Comments
 (0)