From eef42da9a2e0106c1912d160bbaf7943db0f1434 Mon Sep 17 00:00:00 2001 From: Kristen Kozak Date: Tue, 17 Apr 2018 19:57:22 -0700 Subject: Control package dependencies with Checkstyle. This commit uses the Checkstyle ImportControl feature (http://checkstyle.sourceforge.net/config_imports.html#ImportControl) to specify the allowed imports for each package. Specifying imports has several benefits: - It makes some parts of the design more concrete. For example, it shows that 'stats' can depend on 'tags', but 'tags' shouldn't depend on 'stats' or 'trace'. - We can use it to restrict access to 'internal' packages. - It can help us remove the dependency on Guava incrementally. For example, this commit specifies that the API can only depend on com.google.common.io.BaseEncoding, which should help us avoid accidentally adding more uses of Guava to the API. One downside is that the check seems to only apply to import statements, not qualified class names. This commit specifies imports positively, using "allow" XML elements. If the lists of imports are too difficult to maintain, especially for packages such as exporters that have many imports, we could switch to using "disallow" elements in some places. --- buildscripts/checkstyle.xml | 4 + buildscripts/import-control.xml | 172 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 buildscripts/import-control.xml (limited to 'buildscripts') diff --git a/buildscripts/checkstyle.xml b/buildscripts/checkstyle.xml index fdea0c5e..6c7cfa49 100644 --- a/buildscripts/checkstyle.xml +++ b/buildscripts/checkstyle.xml @@ -227,6 +227,10 @@ + + + + diff --git a/buildscripts/import-control.xml b/buildscripts/import-control.xml new file mode 100644 index 00000000..49e253b2 --- /dev/null +++ b/buildscripts/import-control.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3