Allow space separated package patterns in framework-aggregated reports

This commit is contained in:
Tamas Vajk
2021-06-10 10:54:12 +02:00
parent 74c00383d2
commit 55dd6ed3d1
4 changed files with 14 additions and 12 deletions

View File

@@ -11,8 +11,7 @@ Java framework & library support
`Apache Commons IO <https://commons.apache.org/proper/commons-io/>`_,``org.apache.commons.io``,,22,,,,,,,,
`Apache Commons Lang <https://commons.apache.org/proper/commons-lang/>`_,``org.apache.commons.lang3``,,370,,,,,,,,
`Apache Commons Text <https://commons.apache.org/proper/commons-text/>`_,``org.apache.commons.text``,,272,,,,,,,,
`Apache HttpComponents <https://hc.apache.org/>`_,``org.apache.hc.core5.*``,2,66,1,,,1,,,,
`Apache HttpComponents <https://hc.apache.org/>`_,``org.apache.http``,3,67,2,,,2,,,,
`Apache HttpComponents <https://hc.apache.org/>`_,"``org.apache.hc.core5.*``, ``org.apache.http``",5,133,3,,,3,,,,
`Google Guava <https://guava.dev/>`_,``com.google.common.*``,,107,6,,6,,,,,
Java Standard Library,``java.*``,3,313,15,13,,,,,,2
Java extensions,``javax.*``,22,8,12,,,,,1,1,

View File

@@ -1,11 +1,10 @@
Framework name,URL,Package prefix
Framework name,URL,Package prefixes
Java Standard Library,,java.*
Java extensions,,javax.*
Google Guava,https://guava.dev/,com.google.common.*
Apache Commons IO,https://commons.apache.org/proper/commons-io/,org.apache.commons.io
Apache Commons Lang,https://commons.apache.org/proper/commons-lang/,org.apache.commons.lang3
Apache Commons Text,https://commons.apache.org/proper/commons-text/,org.apache.commons.text
Apache HttpComponents,https://hc.apache.org/,org.apache.hc.core5.*
Apache HttpComponents,https://hc.apache.org/,org.apache.http
Apache HttpComponents,https://hc.apache.org/,org.apache.hc.core5.* org.apache.http
Android,,android.*
Spring,https://spring.io/,org.springframework.*
1 Framework name URL Package prefix Package prefixes
2 Java Standard Library java.* java.*
3 Java extensions javax.* javax.*
4 Google Guava https://guava.dev/ com.google.common.* com.google.common.*
5 Apache Commons IO https://commons.apache.org/proper/commons-io/ org.apache.commons.io org.apache.commons.io
6 Apache Commons Lang https://commons.apache.org/proper/commons-lang/ org.apache.commons.lang3 org.apache.commons.lang3
7 Apache Commons Text https://commons.apache.org/proper/commons-text/ org.apache.commons.text org.apache.commons.text
8 Apache HttpComponents https://hc.apache.org/ org.apache.hc.core5.* org.apache.hc.core5.* org.apache.http
Apache HttpComponents https://hc.apache.org/ org.apache.http
9 Android android.* android.*
10 Spring https://spring.io/ org.springframework.* org.springframework.*

View File

@@ -48,20 +48,23 @@ class FrameworkCollection:
return framework
return None
def get_patterns(self):
return self.package_patterns
def get_frameworks(self):
return self.frameworks
def __package_match(self, package: packages.Package, pattern):
def __package_match_single(self, package: packages.Package, pattern):
return (pattern.endswith("*") and package.name.startswith(pattern[:-1])) or (not pattern.endswith("*") and pattern == package.name)
def __package_match(self, package: packages.Package, pattern):
patterns = pattern.split(" ")
return any(self.__package_match_single(package, pattern) for pattern in patterns)
def get_package_filter(self, framework: Framework):
"""
Returns a lambda filter that holds for packages that match the current framework.
The pattern is either full name, such as "org.hibernate", or a prefix, such as "java.*"
The pattern is either full name, such as "org.hibernate", or a prefix, such as "java.*".
Patterns can also contain a space separated list of patterns, such as "java.sql javax.swing".
Package patterns might overlap, in case of 'org.apache.commons.io' and 'org.apache.*', the statistics for
the latter will not include the statistics for the former.
"""
@@ -69,4 +72,4 @@ class FrameworkCollection:
self.__package_match(p, framework.package_pattern) and \
all(
len(framework.package_pattern) >= len(pattern) or
not self.__package_match(p, pattern) for pattern in self.get_patterns())
not self.__package_match(p, pattern) for pattern in self.package_patterns)

View File

@@ -207,7 +207,8 @@ for config in configs:
row_prefix + "`" + framework.name + " <" + framework.url + ">`_")
# Add the package name to the row
row.append("``" + framework.package_pattern + "``")
row.append(", ".join("``{0}``".format(p)
for p in framework.package_pattern.split(" ")))
# Collect statistics on the current framework
def collect_framework(): return collect_package_stats(