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

CA Tool Sonar issue fixes #254

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/ArtifactoryUploader/ArtifactoryUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async Task<AqlResult> TryGetPackageInfo(ComponentsToArtifactory component)


// Handle DEBIAN package name mismatch
if (component.ComponentType == "DEBIAN" && packageInfo?.Name != component.JfrogPackageName)
if (component.ComponentType == "DEBIAN" && packageInfo != null && packageInfo.Name != component.JfrogPackageName)
{
component.CopyPackageApiUrl = component.CopyPackageApiUrl.Replace(component.JfrogPackageName, packageInfo.Name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ArtifactoryUploader/JfrogRepoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static async Task<Bom> UpdateJfrogRepoPathForSucessfullyUploadedItems(Bom
List<ComponentsToArtifactory> uploadedPackages = PackageUploadInformation.GetUploadePackageDetails(displayPackagesInfo);

// Get the details of all the dest repo names from jfrog at once
List<string> destRepoNames = uploadedPackages.Select(x => x.DestRepoName)?.Distinct()?.ToList() ?? new List<string>();
List<string> destRepoNames = uploadedPackages.Select(x => x.DestRepoName).Distinct().ToList();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if this empty or null and not passed, has it been tested already ?

List<AqlResult> jfrogPackagesListAql = await GetJfrogRepoInfoForAllTypePackages(destRepoNames);

// Update the repo path
Expand Down
2 changes: 1 addition & 1 deletion src/LCT.Common/TelemetryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public TelemetryHelper(CommonAppSettings appSettings)

telemetry_ = new LCT.Telemetry.Telemetry(TelemetryConstant.Type, new Dictionary<string, string>
{
{ "InstrumentationKey", appSettings.Telemetry.ApplicationInsightInstrumentKey }
{ "InstrumentationKey", appSettings?.Telemetry?.ApplicationInsightInstrumentKey ?? string.Empty }
});
}

Expand Down
14 changes: 12 additions & 2 deletions src/LCT.PackageIdentifier/ConanProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,18 @@ private static void GetPackagesForBom(ref List<Component> lstComponentForBOM, re

ConanPackage package = nodePackages.Where(x => x.Id == "0").FirstOrDefault();
List<string> directDependencies = new List<string>();
if (package.Dependencies != null) { directDependencies.AddRange(package.Dependencies); }
if (package.DevDependencies != null) { directDependencies.AddRange(package.DevDependencies); }
if (package != null)
{
if (package.Dependencies != null)
{
directDependencies.AddRange(package.Dependencies);
}

if (package.DevDependencies != null)
{
directDependencies.AddRange(package.DevDependencies);
}
}

// Ignoring the root node as it is the package information node and we are anyways considering all
// nodes in the lock file.
Expand Down
7 changes: 5 additions & 2 deletions src/LCT.PackageIdentifier/MavenProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public async Task<List<Component>> GetJfrogRepoDetailsOfAComponent(List<Componen
AqlResult finalRepoData = GetJfrogArtifactoryRepoDetials(aqlResultList, component, bomhelper, out jfrogRepoPath);
Property siemensfileNameProp = new() { Name = Dataconstant.Cdx_Siemensfilename, Value = finalRepoData?.Name ?? Dataconstant.PackageNameNotFoundInJfrog };
Property jfrogRepoPathProp = new() { Name = Dataconstant.Cdx_JfrogRepoPath, Value = jfrogRepoPath };
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoName, Value = finalRepoData.Repo };
Property artifactoryrepo = new() { Name = Dataconstant.Cdx_ArtifactoryRepoName, Value = finalRepoData?.Repo };

Component componentVal = component;
if (artifactoryrepo.Value == appSettings.Maven.DevDepRepo)
Expand Down Expand Up @@ -383,7 +383,10 @@ private static AqlResult GetJfrogArtifactoryRepoDetials(List<AqlResult> aqlResul
aqlResult = aqlResults.FirstOrDefault(x => x.Repo.Equals(repoName));
jfrogRepoPath = GetJfrogRepoPath(aqlResult);
}
aqlResult.Repo ??= repoName;
if (aqlResult != null)
{
aqlResult.Repo ??= repoName;
}
return aqlResult;
}

Expand Down
5 changes: 4 additions & 1 deletion src/LCT.PackageIdentifier/NpmProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,10 @@ public AqlResult GetJfrogArtifactoryRepoDetials(List<AqlResult> aqlResultList,
jfrogRepoPath = GetJfrogRepoPath(aqlResult);
}

aqlResult.Repo ??= NotFoundInRepo;
if (aqlResult != null)
{
aqlResult.Repo ??= NotFoundInRepo;
}
return aqlResult;
}

Expand Down
4 changes: 2 additions & 2 deletions src/LCT.PackageIdentifier/NugetDevDependencyParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private static void GetDirectDependencies(string filePath)
var readValue = File.ReadAllText(filePath);
JObject serializedContent = JObject.Parse(readValue);
JToken projectFramworks = serializedContent["project"]["frameworks"];
if (projectFramworks == null && !projectFramworks.HasValues)
if (projectFramworks == null || !projectFramworks.HasValues)
{
return;
}
Expand All @@ -203,7 +203,7 @@ private static void GetDirectDependencies(string filePath)

if (projectDependencies.HasValues)
{
directDepCollection = projectDependencies.Children().OfType<JProperty>()?.ToList() ?? new List<JProperty>();
directDepCollection = projectDependencies.Children().OfType<JProperty>().ToList();
}
foreach (var child in directDepCollection)
{
Expand Down
5 changes: 4 additions & 1 deletion src/LCT.PackageIdentifier/NugetProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ public AqlResult GetJfrogArtifactoryRepoDetials(List<AqlResult> aqlResultList,
aqlResult = aqlResults.FirstOrDefault(x => x.Repo.Equals(repoName));
jfrogRepoPath = GetJfrogRepoPath(aqlResult);
}
aqlResult.Repo ??= repoName;
if (aqlResult != null)
{
aqlResult.Repo ??= repoName;
}
return aqlResult;
}

Expand Down
2 changes: 1 addition & 1 deletion src/LCT.SW360PackageCreator/CreatorValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static async Task TriggerFossologyValidation(CommonAppSettings appSetting
else
{
int currentPage = page;
int totalPages = (int)(releaseResponse?.Page?.TotalPages);
int totalPages = (int)(releaseResponse?.Page?.TotalPages ?? 0);
if (currentPage < totalPages - 1)
{
page = currentPage + 1;
Expand Down
Loading