Skip to content

Commit 55dd6ed

Browse files
committed
Allow space separated package patterns in framework-aggregated reports
1 parent 74c0038 commit 55dd6ed

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

java/documentation/library-coverage/flow-model-coverage.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ Java framework & library support
1111
`Apache Commons IO <https://commons.apache.org/proper/commons-io/>`_,``org.apache.commons.io``,,22,,,,,,,,
1212
`Apache Commons Lang <https://commons.apache.org/proper/commons-lang/>`_,``org.apache.commons.lang3``,,370,,,,,,,,
1313
`Apache Commons Text <https://commons.apache.org/proper/commons-text/>`_,``org.apache.commons.text``,,272,,,,,,,,
14-
`Apache HttpComponents <https://hc.apache.org/>`_,``org.apache.hc.core5.*``,2,66,1,,,1,,,,
15-
`Apache HttpComponents <https://hc.apache.org/>`_,``org.apache.http``,3,67,2,,,2,,,,
14+
`Apache HttpComponents <https://hc.apache.org/>`_,"``org.apache.hc.core5.*``, ``org.apache.http``",5,133,3,,,3,,,,
1615
`Google Guava <https://guava.dev/>`_,``com.google.common.*``,,107,6,,6,,,,,
1716
Java Standard Library,``java.*``,3,313,15,13,,,,,,2
1817
Java extensions,``javax.*``,22,8,12,,,,,1,1,
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
Framework name,URL,Package prefix
1+
Framework name,URL,Package prefixes
22
Java Standard Library,,java.*
33
Java extensions,,javax.*
44
Google Guava,https://guava.dev/,com.google.common.*
55
Apache Commons IO,https://commons.apache.org/proper/commons-io/,org.apache.commons.io
66
Apache Commons Lang,https://commons.apache.org/proper/commons-lang/,org.apache.commons.lang3
77
Apache Commons Text,https://commons.apache.org/proper/commons-text/,org.apache.commons.text
8-
Apache HttpComponents,https://hc.apache.org/,org.apache.hc.core5.*
9-
Apache HttpComponents,https://hc.apache.org/,org.apache.http
8+
Apache HttpComponents,https://hc.apache.org/,org.apache.hc.core5.* org.apache.http
109
Android,,android.*
1110
Spring,https://spring.io/,org.springframework.*

misc/scripts/library-coverage/frameworks.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,28 @@ def get(self, framework_name):
4848
return framework
4949
return None
5050

51-
def get_patterns(self):
52-
return self.package_patterns
53-
5451
def get_frameworks(self):
5552
return self.frameworks
5653

57-
def __package_match(self, package: packages.Package, pattern):
54+
def __package_match_single(self, package: packages.Package, pattern):
5855
return (pattern.endswith("*") and package.name.startswith(pattern[:-1])) or (not pattern.endswith("*") and pattern == package.name)
5956

57+
def __package_match(self, package: packages.Package, pattern):
58+
patterns = pattern.split(" ")
59+
return any(self.__package_match_single(package, pattern) for pattern in patterns)
60+
6061
def get_package_filter(self, framework: Framework):
6162
"""
6263
Returns a lambda filter that holds for packages that match the current framework.
6364
64-
The pattern is either full name, such as "org.hibernate", or a prefix, such as "java.*"
65+
The pattern is either full name, such as "org.hibernate", or a prefix, such as "java.*".
66+
Patterns can also contain a space separated list of patterns, such as "java.sql javax.swing".
67+
6568
Package patterns might overlap, in case of 'org.apache.commons.io' and 'org.apache.*', the statistics for
6669
the latter will not include the statistics for the former.
6770
"""
6871
return lambda p: \
6972
self.__package_match(p, framework.package_pattern) and \
7073
all(
7174
len(framework.package_pattern) >= len(pattern) or
72-
not self.__package_match(p, pattern) for pattern in self.get_patterns())
75+
not self.__package_match(p, pattern) for pattern in self.package_patterns)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def add_package_stats_to_row(row, sorted_cwes, collect):
207207
row_prefix + "`" + framework.name + " <" + framework.url + ">`_")
208208

209209
# Add the package name to the row
210-
row.append("``" + framework.package_pattern + "``")
210+
row.append(", ".join("``{0}``".format(p)
211+
for p in framework.package_pattern.split(" ")))
211212

212213
# Collect statistics on the current framework
213214
def collect_framework(): return collect_package_stats(

0 commit comments

Comments
 (0)