Add --hide_progress command-line flag to suppress progress bar#264
Add --hide_progress command-line flag to suppress progress bar#264
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Changes
Sequence Diagram(s)sequenceDiagram
participant CLI
participant Orchestrator as run_scanners/merge_results
participant KBScanner as KB traversal (tqdm)
participant ScanCode
participant ScanOSS
CLI->>Orchestrator: parse args (including --hide_progress)
CLI->>Orchestrator: call run_scanners(hide_progress)
Orchestrator->>KBScanner: collect files_to_scan
KBScanner-->>Orchestrator: iterate files with tqdm (disabled if hide_progress)
Orchestrator->>ScanCode: run_scan(..., hide_progress)
Orchestrator->>ScanOSS: run_scanoss_py(..., hide_progress)
ScanCode-->>Orchestrator: scan results
ScanOSS-->>Orchestrator: scanoss results
Orchestrator-->>CLI: merged results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labelschore 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/fosslight_source/run_scancode.py (1)
66-66: Mutable default argument should be replaced withNone.The
excluded_files: list = []uses a mutable default which can lead to unexpected behavior if the list is modified. While this parameter pre-existed this PR, the static analysis correctly flags this issue.♻️ Proposed fix
- excluded_files: list = [], hide_progress: bool = False + excluded_files: list = None, hide_progress: bool = False ) -> Tuple[bool, str, list, list]: if not called_by_cli: global logger + if excluded_files is None: + excluded_files = []🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/fosslight_source/run_scancode.py` at line 66, The parameter excluded_files currently uses a mutable default (excluded_files: list = []) which can cause state leakage; change the function signature to default excluded_files to None (excluded_files: Optional[list] = None) and inside the function initialize it with excluded_files = [] if excluded_files is None; update any type hints/imports (e.g., add typing.Optional if needed) and ensure all uses of excluded_files in run_scancode (and any helper methods called from it) rely on the initialized local list rather than mutating a module-level default.src/fosslight_source/cli.py (1)
318-318: Use explicitOptionaltype hint for nullable parameter.PEP 484 prohibits implicit
Optional. The type should be explicit:set | NoneorOptional[set].♻️ Proposed fix
def merge_results( scancode_result: list = [], scanoss_result: list = [], spdx_downloads: dict = {}, path_to_scan: str = "", run_kb: bool = False, manifest_licenses: dict = {}, - excluded_files: set = None, hide_progress: bool = False + excluded_files: set | None = None, hide_progress: bool = False ) -> list:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/fosslight_source/cli.py` at line 318, The parameter excluded_files currently uses an implicit nullable type "set = None"; update its annotation to an explicit Optional by changing the signature for the function that declares excluded_files to use either "Optional[set]" (and add "from typing import Optional") or the PEP 604 form "set | None" so the parameter is explicitly nullable; keep the default None and ensure the parameter name excluded_files remains unchanged so callers still work.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/fosslight_source/cli.py`:
- Around line 367-384: The project uses tqdm (import tqdm and tqdm.tqdm in
src/fosslight_source/cli.py) but it isn't declared as a dependency; update
pyproject.toml by adding "tqdm" to the dependencies list so the package consumer
won't get ModuleNotFoundError at runtime, and ensure the version specifier
follows your project's dependency format.
In `@src/fosslight_source/run_scanoss.py`:
- Line 79: The logger.debug call in src/fosslight_source/run_scanoss.py uses an
unnecessary f-string (logger.debug(f"|---SCANOSS Parsing")), so change it to a
plain string by removing the f prefix and using logger.debug("|---SCANOSS
Parsing") to avoid creating an unnecessary formatted string.
- Around line 63-71: The Scanner constructor call includes an unsupported
keyword argument quiet which causes a TypeError; remove the unsupported argument
by deleting quiet=hide_progress from the Scanner(...) instantiation so the
Scanner is constructed with only supported parameters (ignore_cert_errors,
skip_folders, scan_output, scan_options, nb_threads, scanoss_settings);
reference the Scanner class and the hide_progress variable to locate and update
the instantiation.
---
Nitpick comments:
In `@src/fosslight_source/cli.py`:
- Line 318: The parameter excluded_files currently uses an implicit nullable
type "set = None"; update its annotation to an explicit Optional by changing the
signature for the function that declares excluded_files to use either
"Optional[set]" (and add "from typing import Optional") or the PEP 604 form "set
| None" so the parameter is explicitly nullable; keep the default None and
ensure the parameter name excluded_files remains unchanged so callers still
work.
In `@src/fosslight_source/run_scancode.py`:
- Line 66: The parameter excluded_files currently uses a mutable default
(excluded_files: list = []) which can cause state leakage; change the function
signature to default excluded_files to None (excluded_files: Optional[list] =
None) and inside the function initialize it with excluded_files = [] if
excluded_files is None; update any type hints/imports (e.g., add typing.Optional
if needed) and ensure all uses of excluded_files in run_scancode (and any helper
methods called from it) rely on the initialized local list rather than mutating
a module-level default.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ec957ec8-f72f-4a85-94e2-ef65eb71bc58
📒 Files selected for processing (4)
src/fosslight_source/_help.pysrc/fosslight_source/cli.pysrc/fosslight_source/run_scancode.pysrc/fosslight_source/run_scanoss.py
6432087 to
85c2af1
Compare
Description
Add
--hide_progresscommand-line flag to suppress progress bar output during scanning operations.