From 20d5424408fbdf4b49953b3df53cbc52e526ad0a Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Tue, 26 Sep 2023 14:10:28 +0200 Subject: [PATCH] [MNG-7416] Simplify Boolean expressions and returns (#333) Use this link to re-run the recipe: https://app.moderne.io/recipes/builder/SEvWu02zw?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../internal/impl/DefaultMetadataResolver.java | 7 ++----- .../aether/util/artifact/ArtifactIdUtils.java | 15 +++------------ .../util/filter/ExclusionsDependencyFilter.java | 6 +----- .../selector/ExclusionDependencySelector.java | 5 +---- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java index e28dd75bf..b0620cd7b 100644 --- a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java +++ b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultMetadataResolver.java @@ -435,11 +435,8 @@ private boolean isEnabled(RemoteRepository repository, Metadata.Nature nature) { && repository.getPolicy(false).isEnabled()) { return true; } - if (!Metadata.Nature.RELEASE.equals(nature) - && repository.getPolicy(true).isEnabled()) { - return true; - } - return false; + return !Metadata.Nature.RELEASE.equals(nature) + && repository.getPolicy(true).isEnabled(); } private RepositoryPolicy getPolicy( diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java index 49901a73d..0d2a40180 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/ArtifactIdUtils.java @@ -165,10 +165,7 @@ public static boolean equalsId(Artifact artifact1, Artifact artifact2) { if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) { return false; } - if (!Objects.equals(artifact1.getVersion(), artifact2.getVersion())) { - return false; - } - return true; + return Objects.equals(artifact1.getVersion(), artifact2.getVersion()); } /** @@ -196,10 +193,7 @@ public static boolean equalsBaseId(Artifact artifact1, Artifact artifact2) { if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) { return false; } - if (!Objects.equals(artifact1.getBaseVersion(), artifact2.getBaseVersion())) { - return false; - } - return true; + return Objects.equals(artifact1.getBaseVersion(), artifact2.getBaseVersion()); } /** @@ -225,9 +219,6 @@ public static boolean equalsVersionlessId(Artifact artifact1, Artifact artifact2 if (!Objects.equals(artifact1.getExtension(), artifact2.getExtension())) { return false; } - if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) { - return false; - } - return true; + return Objects.equals(artifact1.getClassifier(), artifact2.getClassifier()); } } diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java index 12d745af3..8c6b18587 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/ExclusionsDependencyFilter.java @@ -65,11 +65,7 @@ public boolean accept(DependencyNode node, List parents) { id = dependency.getArtifact().getGroupId() + ':' + id; - if (excludes.contains(id)) { - return false; - } - - return true; + return !(excludes.contains(id)); } @Override diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java index a9d5a7efb..a44e8c816 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/selector/ExclusionDependencySelector.java @@ -90,10 +90,7 @@ private boolean matches(Exclusion exclusion, Artifact artifact) { if (!matches(exclusion.getExtension(), artifact.getExtension())) { return false; } - if (!matches(exclusion.getClassifier(), artifact.getClassifier())) { - return false; - } - return true; + return matches(exclusion.getClassifier(), artifact.getClassifier()); } private boolean matches(String pattern, String value) {