Skip to content

Conversation

@isasmendiagus
Copy link
Contributor

@isasmendiagus isasmendiagus commented Jan 16, 2026

Summary

  • Adds --wfp-output <FILE> option to save fingerprints to a file during scan
  • Allows users to scan and generate WFP in a single command

Related

SP-3942

Summary by CodeRabbit

  • New Features
    • Added --wfp-output option to the scan command for exporting fingerprints to a specified file during scanning operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

The PR adds a --wfp-output command-line option to the scan command, allowing users to specify a file where fingerprints (WFPs) are written during scanning. The Scanner class is extended to accept this parameter and conditionally collect WFPs during fingerprinting, writing the concatenated output to the specified file before threaded scanning begins.

Changes

Cohort / File(s) Summary
CLI Configuration
src/scanoss/cli.py
Added --wfp-output CLI argument (type=str, metavar='FILE') to scan sub-command; modified scan() to pass wfp_output=args.wfp_output to Scanner constructor.
Scanner Implementation
src/scanoss/scanner.py
Added wfp_output: str = None parameter to Scanner.__init__() and stored as instance attribute; implemented WFP list collection and conditional file writing in scan workflows (scan_folder and scan_files) before threaded scanning execution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • eeisegn
  • agustingroh
  • matiasdaloia

Poem

🐰 A fingerprint file, now within your grasp,
WFPs captured in each scanning clasp,
From CLI whisper to Scanner's embrace,
Fresh output written to its destined place! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding a --wfp-output CLI option to save fingerprints during scanning.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
src/scanoss/scanner.py (1)

428-431: Consider adding error handling for the file write operation.

If the file write fails (e.g., permission denied, disk full, invalid path), the exception will propagate and potentially cause an unclear error message. Consider wrapping this in a try/except block with a meaningful error message, or at least verifying the path is writable earlier.

However, I note the existing wfp_folder and wfp_file methods follow the same pattern without explicit error handling, so this is consistent with the current codebase style.

🔧 Optional: Add error handling
         if file_count > 0:
             if wfp_list is not None:
                 self.print_debug(f'Writing fingerprints to {self.wfp_output}')
-                with open(self.wfp_output, 'w') as f:
-                    f.write(''.join(wfp_list))
+                try:
+                    with open(self.wfp_output, 'w') as f:
+                        f.write(''.join(wfp_list))
+                except OSError as e:
+                    self.print_stderr(f'Warning: Failed to write fingerprints to {self.wfp_output}: {e}')

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0d3269 and 6eae2e7.

📒 Files selected for processing (2)
  • src/scanoss/cli.py
  • src/scanoss/scanner.py
🧰 Additional context used
🧬 Code graph analysis (1)
src/scanoss/scanner.py (3)
src/scanoss/cli.py (1)
  • wfp (1364-1430)
src/scanoss/scanossbase.py (1)
  • print_debug (58-63)
src/scanoss/spdxlite.py (1)
  • print_debug (61-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (5)
src/scanoss/scanner.py (3)

111-123: LGTM!

The new wfp_output parameter is correctly added to the constructor signature and stored as an instance variable. This follows the existing pattern for other optional parameters in the class.


645-645: LGTM!

The WFP collection logic in scan_files is consistent with the implementation in scan_folder. The conditional initialization, append logic, and file write are all correctly implemented.

Also applies to: 659-660, 695-698


585-609: Verify: --wfp-output is not supported when scanning a single file.

The scan_file method does not include the WFP output logic that was added to scan_folder and scan_files. This means running scanoss-py scan somefile.py --wfp-output out.wfp will silently ignore the --wfp-output option.

Is this intentional, or should single-file scans also support WFP output?

src/scanoss/cli.py (2)

193-196: LGTM!

The new --wfp-output CLI argument is well-defined with appropriate type, metavar, and help text. It's positioned logically after the deprecated --no-wfp-output option.


1608-1608: LGTM!

The wfp_output parameter is correctly passed to the Scanner constructor, following the established pattern for other CLI arguments.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

SCANOSS SCAN Completed 🚀

  • Detected components: 1
  • Undeclared components: 0
  • Declared components: 1
  • Detected files: 104
  • Detected files undeclared: 0
  • Detected files declared: 104
  • Licenses detected: 1
  • Licenses detected with copyleft: 0
  • Policies: ✅ 1 pass (1 total)

View more details on SCANOSS Action Summary

@eeisegn eeisegn merged commit 0f86cb3 into main Jan 16, 2026
6 checks passed
@eeisegn eeisegn deleted the feat/SP-3942/add-wfp-output-option branch January 16, 2026 17:55
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.

3 participants