From 9e5183f0ad9dc2bdbf0feaabd9c70a4d26b79382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20He=CC=81ritier?= Date: Tue, 11 Jun 2013 22:09:51 +0200 Subject: [PATCH] =?UTF-8?q?Code=20cleanup=20-=20Various=20code=20simplific?= =?UTF-8?q?ations=20(tests,=20loops,=20=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maven/artifact/versioning/Restriction.java | 6 +----- .../DefaultRepositoryMetadataManager.java | 9 +-------- .../StringSearchModelInterpolator.java | 1 - .../maven/repository/MetadataGraphNode.java | 2 +- .../resolver/DefaultArtifactResolverTest.java | 2 +- .../resolver/filter/ExclusionSetFilter.java | 6 +----- .../lifecycle/internal/DependencyContext.java | 9 ++------- .../internal/DefaultPluginVersionResolver.java | 1 - .../project/artifact/MavenMetadataSource.java | 16 ++++------------ .../model/validation/DefaultModelValidator.java | 8 ++------ .../maven/plugin/descriptor/MojoDescriptor.java | 6 +----- 11 files changed, 14 insertions(+), 52 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java index 5787def421..d73d7ea5b0 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/Restriction.java @@ -170,12 +170,8 @@ public class Restriction return false; } - if ( upperBoundInclusive != restriction.upperBoundInclusive ) - { - return false; - } + return upperBoundInclusive == restriction.upperBoundInclusive; - return true; } public String toString() diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java index cbdcf07bee..c94d24cc54 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java @@ -122,14 +122,7 @@ public class DefaultRepositoryMetadataManager + ") in favor of local copy" ); } } - else if ( updateCheckManager.isUpdateRequired( metadata, repository, file ) ) - { - update = true; - } - else - { - update = false; - } + else update = updateCheckManager.isUpdateRequired( metadata, repository, file ); if ( update ) { diff --git a/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java b/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java index 68f282b902..1ef5579e00 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java +++ b/maven-compat/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java @@ -288,7 +288,6 @@ public class StringSearchModelInterpolator + cls.getName() + "; it is an unmodifiable collection." ); } - continue; } } } diff --git a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java b/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java index 22394e7078..c8b9ab4eca 100644 --- a/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java +++ b/maven-compat/src/main/java/org/apache/maven/repository/MetadataGraphNode.java @@ -80,7 +80,7 @@ public class MetadataGraphNode return metadata == null; } - return metadata == null ? false : metadata.toString().equals( node2.metadata.toString() ); + return metadata != null && metadata.toString().equals( node2.metadata.toString() ); } else { diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java index 8e7b2847f9..40d94c2052 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java @@ -68,7 +68,7 @@ public class DefaultArtifactResolverTest // we want to see all top-level thread groups ThreadGroup tg = Thread.currentThread().getThreadGroup(); - while ( !( tg.getParent() != null ) ) + while ( tg.getParent() == null ) { tg = tg.getParent(); } diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionSetFilter.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionSetFilter.java index 7d8740bf29..45ce84585e 100644 --- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionSetFilter.java +++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionSetFilter.java @@ -54,12 +54,8 @@ public class ExclusionSetFilter id = artifact.getGroupId() + ':' + id; - if ( excludes.contains( id ) ) - { - return false; - } + return !excludes.contains( id ); - return true; } @Override diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DependencyContext.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DependencyContext.java index 54e5756889..bed9a73b43 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DependencyContext.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DependencyContext.java @@ -92,13 +92,8 @@ public class DependencyContext public boolean isResolutionRequiredForCurrentProject() { - if ( lastDependencyArtifacts != project.getDependencyArtifacts() - || ( lastDependencyArtifacts != null && lastDependencyArtifactCount != lastDependencyArtifacts.size() ) ) - { - return true; - - } - return false; + return lastDependencyArtifacts != project.getDependencyArtifacts() || ( lastDependencyArtifacts != null + && lastDependencyArtifactCount != lastDependencyArtifacts.size() ); } public boolean isResolutionRequiredForAggregatedProjects( Collection scopesToCollect, diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java index 95e0ba8eaa..5efa8098cf 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java @@ -196,7 +196,6 @@ public class DefaultPluginVersionResolver } catch ( InvalidVersionSpecificationException e ) { - continue; } } diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index d56fdc62a6..002134b4d3 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -734,12 +734,8 @@ public class MavenMetadataSource { return true; } - if ( e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException - && e.getCause().getCause() instanceof ArtifactNotFoundException ) - { - return true; - } - return false; + return e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException + && e.getCause().getCause() instanceof ArtifactNotFoundException; } private boolean isNonTransferrablePom( Exception e ) @@ -748,12 +744,8 @@ public class MavenMetadataSource { return true; } - if ( e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException - && !( e.getCause().getCause() instanceof ArtifactNotFoundException ) ) - { - return true; - } - return false; + return e.getCause() instanceof org.eclipse.aether.resolution.ArtifactResolutionException + && !( e.getCause().getCause() instanceof ArtifactNotFoundException ); } private Properties getSystemProperties() diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java index a1dbb47f38..67d255f3ec 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java @@ -781,13 +781,9 @@ public class DefaultModelValidator return false; } - if ( !validateBannedCharacters( fieldName, problems, severity, version, string, sourceHint, tracker, - ILLEGAL_VERSION_CHARS ) ) - { - return false; - } + return validateBannedCharacters( fieldName, problems, severity, version, string, sourceHint, tracker, + ILLEGAL_VERSION_CHARS ); - return true; } private boolean validate20ProperSnapshotVersion( String fieldName, ModelProblemCollector problems, Severity severity, Version version, diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java index 8c3d9da894..f084b13462 100644 --- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java +++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java @@ -545,12 +545,8 @@ public class MojoDescriptor return false; } - if ( !compareObjects( getGoal(), other.getGoal() ) ) - { - return false; - } + return compareObjects( getGoal(), other.getGoal() ); - return true; } return false;