Skip to content

Commit

Permalink
fix: fix Sonarcloud findings
Browse files Browse the repository at this point in the history
  • Loading branch information
remisbaima committed Apr 23, 2022
1 parent e771043 commit a1de9fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/main/java/org/remis/cyclonedx/LicenseChecker.java
Expand Up @@ -39,16 +39,12 @@ protected Map<String, String> checkBom(Bom bom, Set<String> allowedLicenses) {
for (Component component : bom.getComponents()) {
String dependencyId = getDependencyId(component);
LicenseChoice licenseChoice = component.getLicenseChoice();
if (licenseChoice == null) {
nonCompliantDependencies.put(dependencyId, null);
continue;
}
List<License> licenses = licenseChoice.getLicenses();
if (licenses == null) {
if (licenseChoice == null || licenseChoice.getLicenses() == null) {
nonCompliantDependencies.put(dependencyId, null);
continue;
}

List<License> licenses = licenseChoice.getLicenses();
for (License license : licenses) {
String licenseId = license.getId();
if (!allowedLicenses.contains(StringUtils.lowerCase(licenseId))) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/remis/cyclonedx/LicenseCheckerTest.java
Expand Up @@ -19,7 +19,7 @@
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;

public class LicenseCheckerTest {
class LicenseCheckerTest {
private static final URL JSON_FILE_URL =
LicenseCheckerTest.class.getResource("/complex-project/allowedLicenses.json");
private static final String JSON_PATH = "$[?(@.License_Conflicts=='No')].License_SPDX";
Expand Down

0 comments on commit a1de9fd

Please sign in to comment.