private void outputConflicts()

in maven-plugin/src/main/java/com/spotify/missinglink/maven/CheckMojo.java [539:594]


  private void outputConflicts(Collection<Conflict> conflicts) {
    Map<ConflictCategory, String> descriptions = new EnumMap<>(ConflictCategory.class);
    descriptions.put(ConflictCategory.CLASS_NOT_FOUND, "Class being called not found");
    descriptions.put(ConflictCategory.METHOD_SIGNATURE_NOT_FOUND, "Method being called not found");

    // group conflict by category
    final Map<ConflictCategory, List<Conflict>> byCategory =
        conflicts.stream().collect(Collectors.groupingBy(Conflict::category));

    byCategory.forEach(
        (category, conflictsInCategory) -> {
          final String desc =
              descriptions.getOrDefault(category, category.name().replace('_', ' '));
          getLog().warn("");
          getLog().warn("Category: " + desc);

          // next group by artifact containing the conflict
          final Map<ArtifactName, List<Conflict>> byArtifact =
              conflictsInCategory.stream().collect(Collectors.groupingBy(Conflict::usedBy));

          byArtifact.forEach(
              (artifactName, conflictsInArtifact) -> {
                getLog().warn("  In artifact: " + artifactName.name());

                // next group by class containing the conflict
                final Map<ClassTypeDescriptor, List<Conflict>> byClassName =
                    conflictsInArtifact.stream()
                        .collect(Collectors.groupingBy(c -> c.dependency().fromClass()));

                byClassName.forEach(
                    (classDesc, conflictsInClass) -> {
                      getLog().warn("    In class: " + classDesc.toString());

                      conflictsInClass.stream()
                          .forEach(
                              c -> {
                                final Dependency dep = c.dependency();
                                getLog()
                                    .warn(
                                        "      In method:  "
                                            + dep.fromMethod().prettyWithoutReturnType()
                                            + optionalLineNumber(dep.fromLineNumber()));
                                getLog().warn("      " + dep.describe());
                                getLog().warn("      Problem: " + c.reason());
                                if (c.existsIn() != ConflictChecker.UNKNOWN_ARTIFACT_NAME) {
                                  getLog().warn("      Found in: " + c.existsIn().name());
                                }
                                // this could be smarter about separating each blob of warnings by
                                // method, but for
                                // now just output a bunch of dashes always
                                getLog().warn("      --------");
                              });
                    });
              });
        });
  }