Update scancode to include all Dockerfile variants (#64)
diff --git a/scancode/ASF-Release.cfg b/scancode/ASF-Release.cfg
index 383297c..7285da2 100644
--- a/scancode/ASF-Release.cfg
+++ b/scancode/ASF-Release.cfg
@@ -36,6 +36,7 @@
*.swift=no_tabs, has_block_license, no_trailing_spaces, eol_at_eof, regex_check
*.yaml=has_block_license, no_trailing_spaces, eol_at_eof, regex_check
*.yml=has_block_license, no_trailing_spaces, eol_at_eof, regex_check
+*Dockerfile*=has_block_license, no_trailing_spaces
# Sanity check files not required to have ASF headers because either they
# are excluded or are not packaged with the Apache source release.
@@ -52,17 +53,25 @@
# General tooling & binary file exclusions
.bin
.dockerignore
+.eslintrc.*
.git
.gitattributes
.github
.gitignore
.gradle
+.idea
.jshintrc
.profiling.*
.pydevproject
.rat-excludes
.tox
+# Exclude Apache standard legal files
+CREDITS.txt
+DISCLAIMER.txt
+LICENSE*.txt
+NOTICE.txt
+
# Exclude cache and 'vendor' directories created by the `gogradle` build tool
.gogradle
vendor
diff --git a/scancode/scanCode.py b/scancode/scanCode.py
index 1743c8f..eb6deb5 100755
--- a/scancode/scanCode.py
+++ b/scancode/scanCode.py
@@ -212,8 +212,7 @@
vprint(MSG_READING_LICENSE_FILE % license_filename)
str1 = str(temp_file.read())
valid_licenses.append(str(str1))
- vprint(MSG_CONFIG_ADDING_LICENSE_FILE % (license_filename,
- str1))
+ # vprint(MSG_CONFIG_ADDING_LICENSE_FILE % (license_filename, str1))
except Exception as e:
raise e
else:
@@ -236,6 +235,7 @@
for line in gitignore_file.read().splitlines():
exclusion_paths.append(line)
+
def read_scan_options(config):
"""Read the Options from the configuration file."""
options_dict = get_config_section_dict(config, SECTION_OPTIONS)
@@ -273,9 +273,9 @@
# by allowing the raw string in the config. to be passed through
config.optionxform = str
if sys.version_info[0] < 3:
- config.readfp(file)
+ config.readfp(file)
else:
- config.read_file(file)
+ config.read_file(file)
read_license_files(config)
read_path_inclusions(config)
read_path_exclusions(config, gitignore_file)
@@ -413,22 +413,24 @@
line_number = 0
# For each line in the file, run all "line checks"
- try: # open file in text mode; skip any binary files
- with open(file_path, 'r') as fp:
- for line in fp:
- line_number += 1
- for check in checks:
- if line_number == 1:
- vprint(col.cyan(MSG_RUNNING_LINE_CHECKS %
- check.__name__))
- err = check(line)
- if err is not None:
- errors.append((line_number, err))
+ # open file in text mode; skip any binary files
+ try:
+ with open(file_path, 'r') as fp:
+ for line in fp:
+ line_number += 1
+ for check in checks:
+ if line_number == 1:
+ vprint(col.cyan(MSG_RUNNING_LINE_CHECKS %
+ check.__name__))
+ err = check(line)
+ if err is not None:
+ errors.append((line_number, err))
except UnicodeDecodeError:
if VERBOSE:
print_error(MSG_SKIPPING_BINARY_FILE % file_path)
return errors
+
def all_paths(root_dir):
"""Generator that returns files with known extensions that can be scanned.
@@ -444,6 +446,7 @@
if filename not in exclusion_files_set:
yield filename
+
def colors():
"""Create a collection of helper functions to colorize strings."""
ansi = hasattr(sys.stderr, "isatty") and platform.system() != "Windows"
@@ -558,10 +561,14 @@
paths_to_check = set(all_paths(root_dir))
for fltr, chks1, chks2 in FILTERS_WITH_CHECK_FUNCTIONS:
- # print_error(col.cyan(MSG_SCANNING_FILTER % fltr))
- # print_error("chks1=" + str(chks1))
- # print_error("chks2=" + str(chks2))
- for path in fnmatch.filter(paths_to_check, fltr):
+ # vprint(col.cyan(MSG_SCANNING_FILTER % fltr))
+ # vprint("chks1=" + str(chks1))
+ # vprint("chks2=" + str(chks2))
+ matches = fnmatch.filter(paths_to_check, fltr)
+ # vprint("paths=" + str(paths_to_check))
+ # vprint("matches=" + str(matches))
+ for path in matches:
+ # vprint("path=[" + path + "]")
errors = run_file_checks(path, chks1)
errors += run_line_checks(path, chks2)
all_errors += map(lambda p: (path, p[0], p[1]), errors)