Skip to content

Commit 6dc46ec

Browse files
committed
Add org.apache.commons.io to frameworks, and handle overlapping package prefixes
1 parent 663e6a8 commit 6dc46ec

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

misc/scripts/frameworks-java.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Framework name,URL,Package prefix
22
Java Standard Library,,java.*
33
Google,,com.google.common.*
44
Apache,,org.apache.*
5+
Apache Commons IO,https://commons.apache.org/proper/commons-io/,org.apache.commons.io
56
Android,,android.*
67
Spring,https://spring.io/,org.springframework.*
78
Java extensions,,javax.*

misc/scripts/generate-csv-coverage-report.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ def __init__(self, lang, capitalized_lang, ext, ql_path):
255255

256256
processed_packages = set()
257257

258+
all_package_patterns = set(
259+
(frameworks[fr]["package"] for fr in frameworks))
260+
258261
# Write a row for each framework.
259262
for framework in sorted(frameworks):
260263
row = []
@@ -269,12 +272,17 @@ def __init__(self, lang, capitalized_lang, ext, ql_path):
269272
# Add the package name to the row
270273
row.append("``" + frameworks[framework]["package"] + "``")
271274

272-
prefix = frameworks[framework]["package"]
275+
current_package_pattern = frameworks[framework]["package"]
273276

274277
# Collect statistics on the current framework
275-
# package name is either full name, such as "org.hibernate", or a prefix, such as "java.*"
278+
# current_package_pattern is either full name, such as "org.hibernate", or a prefix, such as "java.*"
279+
# Package patterns might overlap, in case of 'org.apache.commons.io' and 'org.apache.*', the statistics for
280+
# the latter will not include the statistics for the former.
281+
def package_match(package_name, pattern): return (pattern.endswith(
282+
"*") and package_name.startswith(pattern[:-1])) or (not pattern.endswith("*") and pattern == package_name)
283+
276284
def collect_framework(): return collect_package_stats(
277-
packages, cwes, lambda p: (prefix.endswith("*") and p.startswith(prefix[:-1])) or (not prefix.endswith("*") and prefix == p))
285+
packages, cwes, lambda p: package_match(p, current_package_pattern) and all(len(current_package_pattern) >= len(pattern) or not package_match(p, pattern) for pattern in all_package_patterns))
278286

279287
row, f_processed_packages = add_package_stats_to_row(
280288
row, sorted_cwes, collect_framework)

0 commit comments

Comments
 (0)