@@ -383,9 +383,6 @@ public Optional<SpdxPackageVerificationCode> getPackageVerificationCode() throws
383383 * @throws InvalidSPDXAnalysisException
384384 */
385385 public SpdxPackage setPackageVerificationCode (SpdxPackageVerificationCode verificationCode ) throws InvalidSPDXAnalysisException {
386- if (strict && Objects .isNull (verificationCode ) && isFilesAnalyzed ()) {
387- throw new InvalidSPDXAnalysisException ("Can not set required verificationCode to null" );
388- }
389386 setPropertyValue (SpdxConstants .PROP_PACKAGE_VERIFICATION_CODE , verificationCode );
390387 return this ;
391388 }
@@ -606,19 +603,13 @@ protected List<String> _verify(Set<String> verifiedIds, String specVersion) {
606603
607604 // files depends on if the filesAnalyzed flag
608605 try {
609- if (getFiles ().size () == 0 ) {
610- if (filesAnalyzed ) {
611- retval .add ("Missing required package files for " +pkgName );
612- }
613- } else {
614- if (!filesAnalyzed ) {
615- retval .add ("Warning: Found analyzed files for package " +pkgName +" when analyzedFiles is set to false." );
616- }
617- for (SpdxFile file :getFiles ()) {
618- List <String > verify = file .verify (verifiedIds , specVersion );
619- addNameToWarnings (verify );
620- retval .addAll (verify );
621- }
606+ if (getFiles ().size () != 0 && !filesAnalyzed ) {
607+ retval .add ("Warning: Found analyzed files for package " + pkgName + " when analyzedFiles is set to false." );
608+ }
609+ for (SpdxFile file :getFiles ()) {
610+ List <String > verify = file .verify (verifiedIds , specVersion );
611+ addNameToWarnings (verify );
612+ retval .addAll (verify );
622613 }
623614 } catch (InvalidSPDXAnalysisException e ) {
624615 retval .add ("Invalid package files: " +e .getMessage ());
@@ -627,11 +618,11 @@ protected List<String> _verify(Set<String> verifiedIds, String specVersion) {
627618 // verification code
628619 try {
629620 Optional <SpdxPackageVerificationCode > verificationCode = this .getPackageVerificationCode ();
630- if (! verificationCode .isPresent () && filesAnalyzed ) {
631- retval . add ( "Missing required package verification code for package " + pkgName );
632- } else if ( verificationCode . isPresent () && ! verificationCode . get (). getValue (). isEmpty () && !filesAnalyzed ) {
621+ if (verificationCode .isPresent ()
622+ && ! verificationCode . get (). getValue (). isEmpty ()
623+ && !filesAnalyzed ) {
633624 retval .add ("Verification code must not be included when files not analyzed." );
634- } else if (filesAnalyzed ) {
625+ } else if (filesAnalyzed && verificationCode . isPresent () ) {
635626 List <String > verify = verificationCode .get ().verify (verifiedIds , specVersion );
636627 addNameToWarnings (verify );
637628 retval .addAll (verify );
@@ -730,32 +721,30 @@ protected List<String> _verify(Set<String> verifiedIds, String specVersion) {
730721 }
731722
732723 private void verifyLicenseInfosInFiles (Collection <AnyLicenseInfo > licenseInfoFromFiles ,
733- boolean filesAnalyzed , String pkgName , Set <String > verifiedIds , List <String > retval , String specVersion ) {
734- if (licenseInfoFromFiles .size () == 0 && filesAnalyzed ) {
735- if (Version .versionLessThan (specVersion , Version .TWO_POINT_THREE_VERSION )) {
736- retval .add ("Missing required license information from files for " +pkgName );
737- }
738- } else {
739- boolean foundNonSimpleLic = false ;
740- for (AnyLicenseInfo lic :licenseInfoFromFiles ) {
741- List <String > verify = lic .verify (verifiedIds , specVersion );
742- addNameToWarnings (verify );
743- retval .addAll (verify );
744- if (!(lic instanceof SimpleLicensingInfo ||
745- lic instanceof SpdxNoAssertionLicense ||
746- lic instanceof SpdxNoneLicense ||
747- lic instanceof OrLaterOperator ||
748- lic instanceof WithExceptionOperator )) {
749- foundNonSimpleLic = true ;
750- }
751- }
752- if (foundNonSimpleLic ) {
753- retval .add ("license info from files contains complex licenses for " +pkgName );
754- }
755- }
756- }
724+ boolean filesAnalyzed , String pkgName , Set <String > verifiedIds , List <String > retval , String specVersion ) {
725+ if (licenseInfoFromFiles .size () != 0 && !filesAnalyzed ) {
726+ retval .add ("License information from files must not be included when files not analyzed. Package " + pkgName );
727+ } else {
728+ boolean foundNonSimpleLic = false ;
729+ for (AnyLicenseInfo lic :licenseInfoFromFiles ) {
730+ List <String > verify = lic .verify (verifiedIds , specVersion );
731+ addNameToWarnings (verify );
732+ retval .addAll (verify );
733+ if (!(lic instanceof SimpleLicensingInfo ||
734+ lic instanceof SpdxNoAssertionLicense ||
735+ lic instanceof SpdxNoneLicense ||
736+ lic instanceof OrLaterOperator ||
737+ lic instanceof WithExceptionOperator )) {
738+ foundNonSimpleLic = true ;
739+ }
740+ }
741+ if (foundNonSimpleLic ) {
742+ retval .add ("license info from files contains complex licenses for " +pkgName );
743+ }
744+ }
745+ }
757746
758- @ Override
747+ @ Override
759748 public int compareTo (SpdxPackage pkg ) {
760749 // sort order is determined by the name and the version
761750
0 commit comments