Repository: open-telemetry/opentelemetry-java
File: all/src/test/java/io/opentelemetry/all/NoSharedInternalCodeTest.java (Java)

Code before:

  private static final Set<String> exemptions =
      new HashSet<>(
          Arrays.asList(
              "opentelemetry-api-incubator",
              "opentelemetry-exporter-common",
              "opentelemetry-exporter-logging",
              "opentelemetry-exporter-logging-otlp",
              "opentelemetry-exporter-prometheus",
              "opentelemetry-exporter-zipkin",
              "opentelemetry-extension-trace-propagators",
              "opentelemetry-opencensus-shim",
              "opentelemetry-sdk-common",
              "opentelemetry-sdk-logs",
              "opentelemetry-sdk-metrics",
              "opentelemetry-sdk-testing",
              "opentelemetry-sdk-trace",
              "opentelemetry-sdk-extension-autoconfigure",
              "opentelemetry-sdk-extension-autoconfigure-spi",
              "opentelemetry-sdk-extension-incubator",
              "opentelemetry-sdk-extension-jaeger-remote-sampler",
              "opentelemetry-exporter-otlp",
              "opentelemetry-exporter-otlp-common",
              "opentelemetry-exporter-sender-grpc-managed-channel",
              "opentelemetry-exporter-sender-jdk",
              "opentelemetry-exporter-sender-okhttp"));

  private static final String OTEL_BASE_PACKAGE = "io.opentelemetry";
  private static final Logger logger = Logger.getLogger(NoSharedInternalCodeTest.class.getName());

  @ParameterizedTest
  @MethodSource("artifactsAndJars")
  void noSharedInternalCode(String artifactId, String absolutePath) throws IOException {
    JavaClasses artifactClasses =
        new ClassFileImporter().importJar(new JarFile(new File(absolutePath)));

    Set<String> artifactOtelPackages =
        artifactClasses.stream()
            .map(JavaClass::getPackageName)
            .filter(packageName -> packageName.startsWith(OTEL_BASE_PACKAGE))
            .collect(Collectors.toSet());

    ClassesShouldConjunction noSharedInternalCodeRule =
        noClasses()
            .that()
            .resideInAnyPackage(artifactOtelPackages.toArray(new String[0]))
            .should()
            .dependOnClassesThat(
                new DescribedPredicate<>(
                    "are in internal modules of other opentelemetry artifacts") {
                  @Override

Review comment (suggestion):
Here's the TODO list. All these modules use shared internal code. 

In contrast, the list of modules which DO NOT use shared internal code is small:

- `opentelemetry-common`
- `opentelemetry-context`
- `opentelemetry-tracing-shim`
- `opentelemetry-api`
- `opentelemetry-extension-kotlin`
- `opentelemetry-sdk`

Code after:
      Set.of(
          "opentelemetry-api-incubator",
          "opentelemetry-exporter-common",
          "opentelemetry-exporter-logging",
          "opentelemetry-exporter-logging-otlp",
          "opentelemetry-exporter-prometheus",
          "opentelemetry-exporter-zipkin",
          "opentelemetry-extension-trace-propagators",
          "opentelemetry-opencensus-shim",
          "opentelemetry-sdk-common",
          "opentelemetry-sdk-logs",
          "opentelemetry-sdk-metrics",
          "opentelemetry-sdk-testing",
          "opentelemetry-sdk-trace",
          "opentelemetry-sdk-extension-autoconfigure",
          "opentelemetry-sdk-extension-autoconfigure-spi",
          "opentelemetry-sdk-extension-incubator",
          "opentelemetry-sdk-extension-jaeger-remote-sampler",
          "opentelemetry-exporter-otlp",
          "opentelemetry-exporter-otlp-common",
          "opentelemetry-exporter-sender-grpc-managed-channel",
          "opentelemetry-exporter-sender-jdk",
          "opentelemetry-exporter-sender-okhttp");

  private static final String OTEL_BASE_PACKAGE = "io.opentelemetry";
  private static final Logger logger = Logger.getLogger(NoSharedInternalCodeTest.class.getName());

  @ParameterizedTest
  @MethodSource("artifactsAndJars")
  void noSharedInternalCode(String artifactId, String absolutePath) throws IOException {
    try (JarFile jarFile = new JarFile(new File(absolutePath))) {
      JavaClasses artifactClasses = new ClassFileImporter().importJar(jarFile);

      Set<String> artifactOtelPackages =
          artifactClasses.stream()
              .map(JavaClass::getPackageName)
              .filter(packageName -> packageName.startsWith(OTEL_BASE_PACKAGE))
              .collect(Collectors.toSet());

      ClassesShouldConjunction noSharedInternalCodeRule =
          noClasses()
              .that()
              .resideInAnyPackage(artifactOtelPackages.toArray(new String[0]))
              .should()
              .dependOnClassesThat(
                  new DescribedPredicate<>(
                      "are in internal modules of other opentelemetry artifacts") {
                    @Override
                    public boolean test(JavaClass javaClass) {
                      String packageName = javaClass.getPackageName();
                      return packageName.startsWith(OTEL_BASE_PACKAGE)