Pre-scan options
Quick reference
- --ignore <pattern>
Ignore files matching
<pattern>.- --include <pattern>
Include files matching
<pattern>.- --facet <facet_pattern>
Here
<facet_pattern>represents<facet>=<pattern>. Add the<facet>to files with a path matching<pattern>.Sub-options:
--tallies-by-facet
--ignore <pattern>
In a scan, all files inside the directory specified as an input argument is scanned. But if there are some files which you don’t want to scan, the
--ignoreoption can be used to do the same.Example
scancode --ignore "*.java" samples samples.jsonHere, ScanCode ignores files ending with .java, and continues with other files as usual.
More information on Glob Pattern Matching.
--include <pattern>
In a normal scan, all files inside the directory specified as an input argument is scanned. But if you want to run the scan on only some selective files, then
--includeoption can be used to do the same.Example
scancode --include "*.java" samples samples.jsonHere, ScanCode selectively scans files that has names ending with .java, and ignores all other files. This is basically complementary in behavior to the
--ignoreoption.See also Glob Pattern Matching.
--classify
Sub-option
The options
--license-clarity-scoreand--tallies-key-filesare sub-options of--classify.--license-clarity-scoreand--tallies-key-filesare Post-Scan Options.Example
scancode -clpieu --json-pp sample_facet.json samples --classifyThis option makes ScanCode further classify scanned files/directories, to determine whether they fall in these following categories
legal
readme
top-level
manifest
A manifest file in computing is a file containing metadata for a group of accompanying files that are part of a set or coherent unit.
key-file
A KEY file serves as a keystone element, containing essential information about a software package — such as its dependencies, versioning, licensing, and more. It often contains the
primary-licenseor the overall license of the package, among other package metadata which are general or ecosystem specific.As in, to the JSON object of each file scanned, these extra attributes are added.
{ "is_legal": false, "is_manifest": false, "is_readme": true, "is_top_level": true, "is_key_file": true }
--facet <facet>=<pattern>
Sub-option
The option
--summary-by-facetis a sub-option of--facet.--summary-by-facetis a post-scan option.Valid
<facet>values are:
core,
dev,
tests,
docs,
data,
examples.
You can use the
--facetoption in the following mannerscancode -clpieu --json-pp sample_facet.json samples --facet dev="*.java" --facet dev="*.c"This adds to the header object, the following attribute
"--facet": [ "dev=*.java", "dev=*.c" ],Here in this example,
.javaand.cfiles are marked as it belongs to facetdev.As a result,
.javafile has the following attribute added"facets": [ "dev" ],Note
All other files which are not
devare marked to be included in the facetcore.For each facet, the
--facetoption precedes the<facet>=<pattern>argument. For specifying multiple facets, this whole part is repeated, including the--facetoption.See Facets to learn more about what a facet is.
Glob Pattern Matching
All the pre-scan options use pattern matching, so the basics of Glob Pattern Matching is discussed briefly below.
Glob pattern matching is useful for matching a group of files, by using patterns in their names. Then using these patterns, files are grouped and treated differently as required.
Here are some rules from the Linux Manual on glob patterns. Refer the same for more detailed information.
A string is a wildcard pattern if it contains one of the characters ‘?’, ‘*’ or ‘[’. Globbing is the operation that expands a wildcard pattern into the list of pathnames matching the pattern. Matching is defined by:
A ‘?’ (not between brackets) matches any single character.
A ‘*’ (not between brackets) matches any string, including the empty string.
An expression “[…]” where the first character after the leading ‘[’ is not an ‘!’ matches a single character, namely any of the characters enclosed by the brackets.
There is one special convention: two characters separated by ‘-’ denote a range.
An expression “[!…]” matches a single character, namely any character that is not matched by the expression obtained by removing the first ‘!’ from it.
A ‘/’ in a pathname cannot be matched by a ‘?’ or ‘*’ wildcard, or by a range like “[.-0]”.
Note that wildcard patterns are not regular expressions, although they are a bit similar.
For more information on glob pattern matching refer these resources:
You can also import these Python Libraries to practice UNIX style pattern matching: