Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just added new method for reducing redundant code #69

Merged
merged 2 commits into from
Apr 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ private void printDependencies(Map<String, Long> sizeOfDependencies, Set<String>
.forEachRemaining(s -> printString("\t" + s + " (" + getSize(s, sizeOfDependencies) + ")"));
}

/**
* Util function to print the information of the analyzed artifacts.
*
* @param info The usage status (used or unused) and type (direct, transitive, inherited) of artifacts.
* @param sizeOfDependencies The size of the JAR file of the artifact.
* @param dependencies The GAV of the artifact.
*/
private void printInfoOfDependencies(String info, Map<String, Long> sizeOfDependencies, Set<String> dependencies) {
printString(info.toUpperCase() + " [" + dependencies.size() + "]" + ": ");
printDependencies(sizeOfDependencies, dependencies);
}

/**
* Utility method to obtain the size of a dependency from a map of dependency -> size. If the size of the dependency
* cannot be obtained form the map (no key with the name of the dependency exists), then it returns 0.
Expand Down Expand Up @@ -535,30 +547,15 @@ public void execute() throws MojoExecutionException, MojoFailureException {
printString(SEPARATOR);
printString(" D E P C L E A N A N A L Y S I S R E S U L T S");
printString(SEPARATOR);

printString("Used direct dependencies".toUpperCase()
+ " [" + usedDirectArtifactsCoordinates.size() + "]" + ": ");
printDependencies(sizeOfDependencies, usedDirectArtifactsCoordinates);

printString("Used inherited dependencies".toUpperCase()
+ " [" + usedInheritedArtifactsCoordinates.size() + "]" + ": ");
printDependencies(sizeOfDependencies, usedInheritedArtifactsCoordinates);

printString("Used transitive dependencies".toUpperCase()
+ " [" + usedTransitiveArtifactsCoordinates.size() + "]" + ": ");
printDependencies(sizeOfDependencies, usedTransitiveArtifactsCoordinates);

printString("Potentially unused direct dependencies".toUpperCase()
+ " [" + unusedDirectArtifactsCoordinates.size() + "]" + ": ");
printDependencies(sizeOfDependencies, unusedDirectArtifactsCoordinates);

printString("Potentially unused inherited dependencies".toUpperCase()
+ " [" + unusedInheritedArtifactsCoordinates.size() + "]" + ": ");
printDependencies(sizeOfDependencies, unusedInheritedArtifactsCoordinates);

printString("Potentially unused transitive dependencies".toUpperCase()
+ " [" + unusedTransitiveArtifactsCoordinates.size() + "]" + ": ");
printDependencies(sizeOfDependencies, unusedTransitiveArtifactsCoordinates);
printInfoOfDependencies("Used direct dependencies", sizeOfDependencies, usedDirectArtifactsCoordinates);
printInfoOfDependencies("Used inherited dependencies", sizeOfDependencies, usedInheritedArtifactsCoordinates);
printInfoOfDependencies("Used transitive dependencies", sizeOfDependencies, usedTransitiveArtifactsCoordinates);
printInfoOfDependencies("Potentially unused direct dependencies", sizeOfDependencies,
unusedDirectArtifactsCoordinates);
printInfoOfDependencies("Potentially unused inherited dependencies", sizeOfDependencies,
unusedInheritedArtifactsCoordinates);
printInfoOfDependencies("Potentially unused transitive dependencies", sizeOfDependencies,
unusedTransitiveArtifactsCoordinates);

if (!ignoreDependencies.isEmpty()) {
printString(SEPARATOR);
Expand Down