Skip to content

Add detect.project.version.create.when.no.components property #1800

Open
bd-samratmuk wants to merge 5 commits into
masterfrom
IDETECT-5210
Open

Add detect.project.version.create.when.no.components property #1800
bd-samratmuk wants to merge 5 commits into
masterfrom
IDETECT-5210

Conversation

@bd-samratmuk

@bd-samratmuk bd-samratmuk commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

  • Adds a boolean property detect.project.version.create.when.no.components (default: true) that when set to false, suppresses project version creation on Black Duck when a scan produces no components and no other scan tools are active.

How

  • Added a hasComponents flag to BdioResult, computed centrally in UniversalStepRunner.generateBdio() by checking root dependencies across all code locations. All detectors benefit, no detector-specific logic. Default flow is unchanged.

Default behaviour

  • Property defaults to true, existing behaviour fully preserved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new configuration switch to optionally skip Black Duck project/version creation when a run yields no detected components and no other scan tools are enabled, while preserving current default behavior.

Changes:

  • Introduces detect.project.version.create.when.no.components (default true) and wires it through configuration to runtime.
  • Tracks whether detectors produced any components via a new hasComponents flag on BdioResult, computed centrally during BDIO generation.
  • Implements the conditional short-circuit in intelligent-mode online runs and documents the new property in current release notes.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/java/com/blackduck/integration/detect/workflow/bdio/BdioResult.java Adds hasComponents flag and accessor to represent whether detector output contains components.
src/main/java/com/blackduck/integration/detect/lifecycle/run/step/UniversalStepRunner.java Computes hasComponents from code location root dependencies and passes it into BdioResult.
src/main/java/com/blackduck/integration/detect/lifecycle/run/step/IntelligentModeStepRunner.java Skips project/version creation when configured and no components/other tools are present.
src/main/java/com/blackduck/integration/detect/lifecycle/run/operation/OperationRunner.java Exposes configuration decision to step runners via a new accessor.
src/main/java/com/blackduck/integration/detect/configuration/DetectPropertyFromVersion.java Adds VERSION_12_0_0 for the new property’s introduction version.
src/main/java/com/blackduck/integration/detect/configuration/DetectProperties.java Defines the new boolean property and help text.
src/main/java/com/blackduck/integration/detect/configuration/DetectConfigurationFactory.java Adds typed config accessor for the new property.
documentation/src/main/markdown/currentreleasenotes.md Documents the new property in the 12.0.0 release notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +117 to +121
if (!operationRunner.shouldCreateProjectVersionWhenNoComponents()) {
boolean hasAnythingToUploadOrScan = bdioResult.hasComponents()
|| detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN)
|| detectToolFilter.shouldInclude(DetectTool.BINARY_SCAN)
|| detectToolFilter.shouldInclude(DetectTool.CONTAINER_SCAN)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The early-return test (property=false, no components, no scan tools → runAsGroup never called) has been added. The inverse test — verifying project version creation proceeds when components exist — has not been added as a unit test, and here's why.

runOnline() is a long orchestration method. After the project version creation step, it continues into BDIO upload, signature scan, binary scan, container scan, impact analysis, IaC scan, policy check, risk report, BOM link publishing, and correlated scan count upload — each requiring its own mocks. Writing a unit test that gets past the early return without NPE-ing on the subsequent steps would require ~15-20 additional mock interactions, producing a test that is mostly scaffolding and obscures the actual assertion.

This path is already covered end-to-end by the battery test suite, which exercises the full runOnline() flow against real detectors. The unit test would add maintenance burden without meaningful coverage beyond what battery tests already provide.

Comment on lines +687 to +689
public boolean shouldCreateProjectVersionWhenNoComponents() {
return detectConfiguration.getValue(DetectProperties.DETECT_PROJECT_VERSION_CREATE_WHEN_NO_COMPONENTS);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed in the latest commit


* Support for npm has been extended to 11.13.0 and Node.js 24.17.0. No newline at end of file
* Support for npm has been extended to 11.13.0 and Node.js 24.17.0.
* Added property `detect.project.version.create.when.no.components` (default: `true`). When set to `false`, Detect will not create a project version on Black Duck if no components are found and no other scan tools are active. No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested revision:

Introduced the property detect.project.version.create.when.no.components (default: true). When configured to false, [detect_product_short] will refrain from creating a project version in [bd_product_long] in cases where no components are identified and no other scan tools are active.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed in the latest commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants