Skip to content

Commit

Permalink
Signed-off-by: Carolina Oliveira
Browse files Browse the repository at this point in the history
fix Codacy Static Code Analysis issues
  • Loading branch information
CarolinaOliiveira committed Sep 9, 2024
1 parent 0a31ace commit 9229ac7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ public static List<File> GetSpdxFiles(this Bom bom)

var copyrightText = component.Copyright;
if (!String.IsNullOrEmpty(copyrightText) && copyrightText != "NOASSERTION")
{
file.CopyrightText = copyrightText;
}

var licenseConcluded = component.Properties?.GetSpdxElement(PropertyTaxonomy.LICENSE_CONCLUDED);
if (!String.IsNullOrEmpty(licenseConcluded) && licenseConcluded != "NOASSERTION")
{
file.LicenseConcluded = licenseConcluded;
}

if (file.SPDXID == null)
{
Expand Down Expand Up @@ -102,7 +106,7 @@ public static void AddSpdxFiles(this Bom bom, List<File> files)
component.Properties.AddSpdxElement(PropertyTaxonomy.SPDXID, file.SPDXID);
component.Properties.AddSpdxElement(PropertyTaxonomy.COMMENT, file.Comment);
component.Properties.AddSpdxElements(PropertyTaxonomy.FILE_TYPE, file.FileTypes);
component.Properties.AddSpdxElements<Models.v2_3.Annotation>(PropertyTaxonomy.ANNOTATION, file.Annotations);
component.Properties.AddSpdxElements(PropertyTaxonomy.ANNOTATION, file.Annotations);
component.Properties.AddSpdxElement(PropertyTaxonomy.LICENSE_COMMENTS, file.LicenseComments);
component.Properties.AddSpdxElement(PropertyTaxonomy.LICENSE_CONCLUDED, file.LicenseConcluded);
component.Properties.AddSpdxElements(PropertyTaxonomy.FILE_CONTRIBUTOR, file.FileContributors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ public static void AddSpdxPackages(this Bom bom, SpdxDocument doc)
component.Type = Component.Classification.Library;
break;
}
} else
}
else
{
component.Type = Component.Classification.Library;
}


if (package.LicenseInfoFromFiles != null && package.LicenseInfoFromFiles.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public static void AddCycloneDXComponents(this SpdxDocument doc, Bom bom)

var copyrightText = component.Copyright;
if (!String.IsNullOrEmpty(copyrightText) && copyrightText != "NOASSERTION")
{
package.CopyrightText = copyrightText;
}

package.SPDXID = component.Properties?.GetSpdxElement(PropertyTaxonomy.SPDXID);
if (package.SPDXID == null)
Expand All @@ -72,20 +74,25 @@ public static void AddCycloneDXComponents(this SpdxDocument doc, Bom bom)

var licenseConcluded = component.Properties?.GetSpdxElement(PropertyTaxonomy.LICENSE_CONCLUDED);
if (!String.IsNullOrEmpty(licenseConcluded) && licenseConcluded != "NOASSERTION")
{
package.LicenseConcluded = licenseConcluded;
}

var builtDate = component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_BUILT_DATE);
if ( ! String.IsNullOrEmpty(builtDate)){
var builtDate = component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_BUILT_DATE);
if ( ! String.IsNullOrEmpty(builtDate))
{
package.BuiltDate = DateTime.Parse(builtDate.Trim('"'));
}

var releaseDate = component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_RELEASE_DATE);
if ( ! String.IsNullOrEmpty(releaseDate)){
if ( ! String.IsNullOrEmpty(releaseDate))
{
package.ReleaseDate = DateTime.Parse(releaseDate.Trim('"'));
}

var validUntilDate = component.Properties?.GetSpdxElement(PropertyTaxonomy.PACKAGE_VALID_UNTIL_DATE);
if ( ! String.IsNullOrEmpty(validUntilDate)){
if ( ! String.IsNullOrEmpty(validUntilDate))
{
package.ValidUntilDate = DateTime.Parse(validUntilDate.Trim('"'));
}

Expand Down Expand Up @@ -138,8 +145,11 @@ public static void AddCycloneDXComponents(this SpdxDocument doc, Bom bom)

// LicenseDeclared
var licenseDeclared = component.Properties?.GetSpdxElement(PropertyTaxonomy.LICENSE_DECLARED);
if(!String.IsNullOrEmpty(licenseDeclared) && licenseDeclared != "NOASSERTION")
if (!String.IsNullOrEmpty(licenseDeclared) && licenseDeclared != "NOASSERTION")
{
package.LicenseDeclared = licenseDeclared;
}

if (component.Licenses != null && component.Licenses.Count == 1)
{

Expand Down Expand Up @@ -197,15 +207,16 @@ public static void AddCycloneDXComponents(this SpdxDocument doc, Bom bom)
case Component.Classification.Framework:
package.PrimaryPackagePurpose = PrimaryPackagePurposeType.FRAMEWORK;
break;
case Component.Classification.Library:
package.PrimaryPackagePurpose = PrimaryPackagePurposeType.LIBRARY;
break;

case Component.Classification.Operating_System:
package.PrimaryPackagePurpose = PrimaryPackagePurposeType.OPERATING_SYSTEM;
break;
case Component.Classification.Container:
package.PrimaryPackagePurpose = PrimaryPackagePurposeType.CONTAINER;
break;
default:
package.PrimaryPackagePurpose = PrimaryPackagePurposeType.LIBRARY;
break;
}

//TODO HasFile
Expand Down

0 comments on commit 9229ac7

Please sign in to comment.