CPD Results

The following document contains the results of PMD's CPD 6.49.0.

Duplications

File Line
org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java 147
org/eclipse/aether/util/graph/manager/TransitiveDependencyManager.java 143
depth + 1, managedVersions, managedScopes, managedOptionals, managedLocalPaths, managedExclusions);
    }

    public DependencyManagement manageDependency(Dependency dependency) {
        requireNonNull(dependency, "dependency cannot be null");
        DependencyManagement management = null;

        Object key = getKey(dependency.getArtifact());

        if (depth >= 2) {
            String version = managedVersions.get(key);
            if (version != null) {
                management = new DependencyManagement();
                management.setVersion(version);
            }

            String scope = managedScopes.get(key);
            if (scope != null) {
                if (management == null) {
                    management = new DependencyManagement();
                }
                management.setScope(scope);

                if (!JavaScopes.SYSTEM.equals(scope)
                        && dependency.getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null) != null) {
                    Map<String, String> properties =
                            new HashMap<>(dependency.getArtifact().getProperties());
                    properties.remove(ArtifactProperties.LOCAL_PATH);
                    management.setProperties(properties);
                }
            }

            if ((JavaScopes.SYSTEM.equals(scope))
                    || (scope == null && JavaScopes.SYSTEM.equals(dependency.getScope()))) {
                String localPath = managedLocalPaths.get(key);
                if (localPath != null) {
                    if (management == null) {
                        management = new DependencyManagement();
                    }
                    Map<String, String> properties =
                            new HashMap<>(dependency.getArtifact().getProperties());
                    properties.put(ArtifactProperties.LOCAL_PATH, localPath);
                    management.setProperties(properties);
                }
            }

            Boolean optional = managedOptionals.get(key);
            if (optional != null) {
                if (management == null) {
                    management = new DependencyManagement();
                }
                management.setOptional(optional);
            }
        }

        Collection<Exclusion> exclusions = managedExclusions.get(key);
        if (exclusions != null) {
            if (management == null) {
                management = new DependencyManagement();
            }
            Collection<Exclusion> result = new LinkedHashSet<>(dependency.getExclusions());
            result.addAll(exclusions);
            management.setExclusions(result);
        }

        return management;
    }

    private Object getKey(Artifact a) {
        return new Key(a);
    }

    @Override
    public boolean equals(Object obj) {
File Line
org/eclipse/aether/util/graph/manager/DefaultDependencyManager.java 234
org/eclipse/aether/util/graph/manager/TransitiveDependencyManager.java 234
hashCode = Objects.hash(managedVersions, managedScopes, managedOptionals, managedExclusions);
        }
        return hashCode;
    }

    static class Key {

        private final Artifact artifact;

        private final int hashCode;

        Key(final Artifact artifact) {
            this.artifact = artifact;
            this.hashCode = Objects.hash(artifact.getGroupId(), artifact.getArtifactId());
        }

        @Override
        public boolean equals(final Object obj) {
            boolean equal = obj instanceof Key;

            if (equal) {
                final Key that = (Key) obj;
                return Objects.equals(artifact.getArtifactId(), that.artifact.getArtifactId())
                        && Objects.equals(artifact.getGroupId(), that.artifact.getGroupId())
                        && Objects.equals(artifact.getExtension(), that.artifact.getExtension())
                        && Objects.equals(artifact.getClassifier(), that.artifact.getClassifier());
            }

            return false;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }
}
File Line
org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java 179
org/eclipse/aether/util/graph/manager/DefaultDependencyManager.java 175
org/eclipse/aether/util/graph/manager/TransitiveDependencyManager.java 175
if ((JavaScopes.SYSTEM.equals(scope))
                    || (scope == null && JavaScopes.SYSTEM.equals(dependency.getScope()))) {
                String localPath = managedLocalPaths.get(key);
                if (localPath != null) {
                    if (management == null) {
                        management = new DependencyManagement();
                    }
                    Map<String, String> properties =
                            new HashMap<>(dependency.getArtifact().getProperties());
                    properties.put(ArtifactProperties.LOCAL_PATH, localPath);
                    management.setProperties(properties);
                }
            }

            Boolean optional = managedOptionals.get(key);
            if (optional != null) {
                if (management == null) {
                    management = new DependencyManagement();
                }
                management.setOptional(optional);
            }
File Line
org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java 157
org/eclipse/aether/util/graph/manager/DefaultDependencyManager.java 152
org/eclipse/aether/util/graph/manager/TransitiveDependencyManager.java 153
String version = managedVersions.get(key);
            if (version != null) {
                management = new DependencyManagement();
                management.setVersion(version);
            }

            String scope = managedScopes.get(key);
            if (scope != null) {
                if (management == null) {
                    management = new DependencyManagement();
                }
                management.setScope(scope);

                if (!JavaScopes.SYSTEM.equals(scope)
                        && dependency.getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null) != null) {
                    Map<String, String> properties =
                            new HashMap<>(dependency.getArtifact().getProperties());
                    properties.remove(ArtifactProperties.LOCAL_PATH);
                    management.setProperties(properties);
                }
            }

            if ((JavaScopes.SYSTEM.equals(scope))
File Line
org/eclipse/aether/util/artifact/ArtifactIdUtils.java 152
org/eclipse/aether/util/artifact/ArtifactIdUtils.java 183
public static boolean equalsId(Artifact artifact1, Artifact artifact2) {
        if (artifact1 == null || artifact2 == null) {
            return false;
        }
        if (!Objects.equals(artifact1.getArtifactId(), artifact2.getArtifactId())) {
            return false;
        }
        if (!Objects.equals(artifact1.getGroupId(), artifact2.getGroupId())) {
            return false;
        }
        if (!Objects.equals(artifact1.getExtension(), artifact2.getExtension())) {
            return false;
        }
        if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) {
            return false;
        }
        if (!Objects.equals(artifact1.getVersion(), artifact2.getVersion())) {
File Line
org/eclipse/aether/util/graph/manager/ClassicDependencyManager.java 262
org/eclipse/aether/util/graph/transformer/ConflictMarker.java 229
}

        @Override
        public boolean equals(Object obj) {
            if (obj == this) {
                return true;
            } else if (!(obj instanceof Key)) {
                return false;
            }
            Key that = (Key) obj;
            return artifact.getArtifactId().equals(that.artifact.getArtifactId())
                    && artifact.getGroupId().equals(that.artifact.getGroupId())
                    && artifact.getExtension().equals(that.artifact.getExtension())
                    && artifact.getClassifier().equals(that.artifact.getClassifier());
        }

        @Override
        public int hashCode() {
File Line
org/eclipse/aether/util/artifact/ArtifactIdUtils.java 152
org/eclipse/aether/util/artifact/ArtifactIdUtils.java 183
org/eclipse/aether/util/artifact/ArtifactIdUtils.java 215
public static boolean equalsId(Artifact artifact1, Artifact artifact2) {
        if (artifact1 == null || artifact2 == null) {
            return false;
        }
        if (!Objects.equals(artifact1.getArtifactId(), artifact2.getArtifactId())) {
            return false;
        }
        if (!Objects.equals(artifact1.getGroupId(), artifact2.getGroupId())) {
            return false;
        }
        if (!Objects.equals(artifact1.getExtension(), artifact2.getExtension())) {
            return false;
        }
        if (!Objects.equals(artifact1.getClassifier(), artifact2.getClassifier())) {
            return false;
        }