aboutcode-org / aboutcode-org/scancode-toolkit

`--ignore` does not appear to work for directories

Open
#4,212 2 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Python
Stars
2.6k
Forks
791
Avg merge
1d 12h
Merged PRs (30d)
5

Description

Directories specified in the `--ignore` list still appear in the result list.

```none
$ scancode --version
ScanCode version: 32.3.3
ScanCode Output Format version: 4.0.0
SPDX License list version: 3.26
```

I tried the following basic invocations...

```sh
scancode --ignore build/* --verbose --json-pp - .
```

The way it evaluated the glob without parenthesis in the `options` was interesting...

```none
"options": {
"input": [
"build/CMakeFiles",
"build/CTestTestfile.cmake",
"build/DartConfiguration.tcl",
"build/Makefile",
"build/Testing",
"build/_deps",
"build/cmake_install.cmake",
"build/compile_commands.json",
"build/generated-includes",
"build/libnote_c.a",
"build/libnote_c.so",
"build/test",
"."
],
"--ignore": [
"build/CMakeCache.txt"
],
"--json-pp": "-",
"--verbose": true
},
```

I tried putting parenthesis in around the ignore, then it captures the `ignore` literally, and gets the `input` correct (but that results in no filtering)...

```sh
scancode --ignore "build/*" --verbose --json-pp - .
```

but I still see these in my output...

```none
$ scancode --ignore "note-c/build/*" --verbose --json-pp - .
Setup plugin: pre_scan:ignore...
Setup plugin: output:json-pp...
Collect file inventory...
Run pre-scans...
Run pre-scan: ignore...
Save scan results...
Save scan results as: json-pp...
{
"headers": [
{
"tool_name": "scancode-toolkit",
"tool_version": "32.3.3",
"options": {
"input": [
"."
],
"--ignore": [
"build/*"
],
"--json-pp": "-",
"--verbose": true
},
"notice": "Generated with ScanCode and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied. No content created from\nScanCode should be considered or used as legal advice. Consult an Attorney\nfor any legal advice.\nScanCode is a free software code scanning tool from nexB Inc. and others.\nVisit https://github.com/nexB/scancode-toolkit/ for support and download.",
"start_timestamp": "2025-03-25T132932.971187",
"end_timestamp": "2025-03-25T132933.313648",
"output_format_version": "4.0.0",
"duration": 0.3424708843231201,
"message": null,
"errors": [],
"warnings": [],
"extra_data": {
"system_environment": {
"operating_system": "linux",
"cpu_architecture": "64",
"platform": "Linux-6.8.0-55-generic-x86_64-with-glibc2.36",
"platform_version": "#57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025",
"python_version": "3.11.2 (main, Nov 30 2024, 21:22:50) [GCC 12.2.0]"
},
"spdx_license_list_version": "3.26",
"files_count": 202
}
}
],
"files": [
{
"path": "note-c",
"type": "directory",
"scan_errors": []
},
...
{
"path": "note-c/build",
"type": "directory",
"scan_errors": []
},
{
"path": "note-c/build/_deps",
"type": "directory",
"scan_errors": []
},
{
"path": "note-c/build/_deps/catch2-build",
"type": "directory",
"scan_errors": []
},
{
"path": "note-c/build/_deps/catch2-build/CMakeFiles",
"type": "directory",
"scan_errors": []
},
{
"path": "note-c/build/_deps/catch2-build/generated-includes",
"type": "directory",
"scan_errors": []
},
...
```
_truncated for readability_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.