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

Simplify code #267

Merged
merged 1 commit into from
Feb 2, 2023
Merged
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
16 changes: 2 additions & 14 deletions src/main/java/org/cyclonedx/maven/CycloneDxAggregateMojo.java
Original file line number Diff line number Diff line change
@@ -128,13 +128,7 @@ protected boolean analyze(final Set<Component> components, final Set<Dependency>
if (! mavenProject.isExecutionRoot()) {
// DO NOT include root project as it's already been included as a bom metadata component
// Also, ensure that only one project component with the same bom-ref exists in the BOM
boolean found = false;
for (String s : componentRefs) {
if (s != null && s.equals(projectBomComponent.getBomRef())) {
found = true;
}
}
if (!found) {
if (!componentRefs.contains(projectBomComponent.getBomRef())) {
components.add(projectBomComponent);
}
}
@@ -145,13 +139,7 @@ protected boolean analyze(final Set<Component> components, final Set<Dependency>
final Component component = convert(artifact);

// ensure that only one component with the same bom-ref exists in the BOM
boolean found = false;
for (String s : componentRefs) {
if (s != null && s.equals(component.getBomRef())) {
found = true;
}
}
if (!found) {
if (!componentRefs.contains(component.getBomRef())) {
Component.Scope componentScope = null;
for (String projectId : dependencyAnalysisMap.keySet()) {
ProjectDependencyAnalysis dependencyAnalysis = dependencyAnalysisMap.get(projectId);
8 changes: 1 addition & 7 deletions src/main/java/org/cyclonedx/maven/CycloneDxMojo.java
Original file line number Diff line number Diff line change
@@ -64,13 +64,7 @@ protected boolean analyze(final Set<Component> components, final Set<Dependency>
if (shouldInclude(artifact)) {
final Component component = convert(artifact);
// ensure that only one component with the same bom-ref exists in the BOM
boolean found = false;
for (String s : componentRefs) {
if (s != null && s.equals(component.getBomRef())) {
found = true;
}
}
if (!found) {
if (!componentRefs.contains(component.getBomRef())) {
component.setScope(getComponentScope(component, artifact, dependencyAnalysis));
componentRefs.add(component.getBomRef());
components.add(component);
8 changes: 1 addition & 7 deletions src/main/java/org/cyclonedx/maven/CycloneDxPackageMojo.java
Original file line number Diff line number Diff line change
@@ -68,13 +68,7 @@ protected boolean analyze(Set<Component> components, Set<Dependency> dependencie
if (shouldInclude(artifact)) {
final Component component = convert(artifact);
// ensure that only one component with the same bom-ref exists in the BOM
boolean found = false;
for (String s : componentRefs) {
if (s != null && s.equals(component.getBomRef())) {
found = true;
}
}
if (!found) {
if (!componentRefs.contains(component.getBomRef())) {
componentRefs.add(component.getBomRef());
components.add(component);
}