CPD Results

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

Duplications

File Line
org/apache/maven/internal/impl/DefaultArtifactFactory.java 36
org/apache/maven/internal/impl/DefaultArtifactFactory.java 61
public Artifact create(@Nonnull ArtifactFactoryRequest request) {
        nonNull(request, "request");
        InternalSession session = InternalSession.from(request.getSession());
        ArtifactType type = null;
        if (request.getType() != null) {
            type = session.getSession().getArtifactTypeRegistry().get(request.getType());
        }
        String str1 = request.getClassifier();
        String classifier =
                str1 != null && !str1.isEmpty() ? request.getClassifier() : type != null ? type.getClassifier() : null;
        String str = request.getExtension();
        String extension =
                str != null && !str.isEmpty() ? request.getExtension() : type != null ? type.getExtension() : null;
        return new DefaultArtifact(
File Line
org/apache/maven/internal/impl/model/DefaultInheritanceAssembler.java 259
org/apache/maven/internal/impl/model/DefaultProfileInjector.java 128
master.put(key, element);

                        if (!pending.isEmpty()) {
                            predecessors.put(key, pending);
                            pending = new ArrayList<>();
                        }
                    } else {
                        pending.add(element);
                    }
                }

                List<Plugin> result = new ArrayList<>(src.size() + tgt.size());
                for (Map.Entry<Object, Plugin> entry : master.entrySet()) {
                    List<Plugin> pre = predecessors.get(entry.getKey());
                    if (pre != null) {
                        result.addAll(pre);
                    }
                    result.add(entry.getValue());
                }
                result.addAll(pending);

                builder.plugins(result);
            }
        }

        @Override
        protected Plugin mergePlugin(
File Line
org/apache/maven/internal/impl/model/MavenModelMerger.java 213
org/apache/maven/internal/impl/model/MavenModelMerger.java 244
List<String> tgt = target.getModules();
            Set<String> excludes = new LinkedHashSet<>(tgt);
            List<String> merged = new ArrayList<>(tgt.size() + src.size());
            merged.addAll(tgt);
            for (int i = 0, n = tgt.size(); i < n; i++) {
                indices.add(i);
            }
            for (int i = 0, n = src.size(); i < n; i++) {
                String s = src.get(i);
                if (!excludes.contains(s)) {
                    merged.add(s);
                    indices.add(~i);
                }
            }
            builder.modules(merged);
File Line
org/apache/maven/internal/impl/model/MavenModelMerger.java 278
org/apache/maven/internal/impl/model/MavenModelMerger.java 315
List<Repository> tgt = target.getRepositories();
            Map<Object, Repository> merged = new LinkedHashMap<>((src.size() + tgt.size()) * 2);

            List<Repository> dominant, recessive;
            if (sourceDominant) {
                dominant = src;
                recessive = tgt;
            } else {
                dominant = tgt;
                recessive = src;
            }

            for (Repository element : dominant) {
                Object key = getRepositoryKey().apply(element);
                merged.put(key, element);
            }

            for (Repository element : recessive) {
                Object key = getRepositoryKey().apply(element);
                if (!merged.containsKey(key)) {
                    merged.put(key, element);
                }
            }

            builder.repositories(merged.values());
File Line
org/apache/maven/internal/impl/resolver/LocalSnapshotMetadata.java 104
org/apache/maven/internal/impl/resolver/RemoteSnapshotMetadata.java 123
Versioning versioning = recessive.getVersioning();
        if (versioning != null) {
            for (SnapshotVersion sv : versioning.getSnapshotVersions()) {
                String key = getKey(sv.getClassifier(), sv.getExtension());
                if (!versions.containsKey(key)) {
                    versions.put(key, sv);
                }
            }
        }

        metadata = metadata.withVersioning(metadata.getVersioning().withSnapshotVersions(versions.values()));

        // just carry-on as-is
        if (recessive.getPlugins() != null && !recessive.getPlugins().isEmpty()) {
            metadata = metadata.withPlugins(new ArrayList<>(recessive.getPlugins()));
        }
File Line
org/apache/maven/internal/impl/resolver/scopes/Maven3ScopeManagerConfiguration.java 118
org/apache/maven/internal/impl/resolver/scopes/Maven4ScopeManagerConfiguration.java 146
ArrayList<ResolutionScope> result = new ArrayList<>();
        result.add(internalScopeManager.createResolutionScope(
                RS_NONE,
                InternalScopeManager.Mode.REMOVE,
                Collections.emptySet(),
                Collections.emptySet(),
                allDependencyScopes));
        result.add(internalScopeManager.createResolutionScope(
                RS_MAIN_COMPILE,
                InternalScopeManager.Mode.ELIMINATE,
                singleton(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.BUILD_PATH_COMPILE),
                Collections.singletonList(system),
                nonTransitiveDependencyScopes));
        result.add(internalScopeManager.createResolutionScope(
                RS_MAIN_COMPILE_PLUS_RUNTIME,
                InternalScopeManager.Mode.ELIMINATE,
                byProjectPath(CommonBuilds.PROJECT_PATH_MAIN),
                Collections.singletonList(system),
                nonTransitiveDependencyScopes));
        result.add(internalScopeManager.createResolutionScope(
                RS_MAIN_RUNTIME,
                InternalScopeManager.Mode.ELIMINATE,
File Line
org/apache/maven/internal/impl/resolver/scopes/Maven3ScopeManagerConfiguration.java 145
org/apache/maven/internal/impl/resolver/scopes/Maven4ScopeManagerConfiguration.java 173
InternalScopeManager.Mode.ELIMINATE,
                singleton(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.BUILD_PATH_RUNTIME),
                Collections.singletonList(system),
                nonTransitiveDependencyScopes));
        result.add(internalScopeManager.createResolutionScope(
                RS_TEST_COMPILE,
                InternalScopeManager.Mode.ELIMINATE,
                select(CommonBuilds.PROJECT_PATH_TEST, CommonBuilds.BUILD_PATH_COMPILE),
                Collections.singletonList(system),
                nonTransitiveDependencyScopes));
        result.add(internalScopeManager.createResolutionScope(
                RS_TEST_RUNTIME,
                InternalScopeManager.Mode.ELIMINATE,
                select(CommonBuilds.PROJECT_PATH_TEST, CommonBuilds.BUILD_PATH_RUNTIME),
                Collections.singletonList(system),
                nonTransitiveDependencyScopes));
        return result;
    }

    // ===

    public static void main(String... args) {
        ScopeManagerDump.dump(Maven3ScopeManagerConfiguration.INSTANCE);
File Line
org/apache/maven/internal/impl/model/DefaultModelValidator.java 305
org/apache/maven/internal/impl/model/DefaultModelValidator.java 627
"parent.artifactId", problems, Severity.FATAL, Version.BASE, parent.getArtifactId(), parent);

            if (equals(parent.getGroupId(), m.getGroupId()) && equals(parent.getArtifactId(), m.getArtifactId())) {
                addViolation(
                        problems,
                        Severity.FATAL,
                        Version.BASE,
                        "parent.artifactId",
                        null,
                        "must be changed"
                                + ", the parent element cannot have the same groupId:artifactId as the project.",
                        parent);
            }

            if (equals("LATEST", parent.getVersion()) || equals("RELEASE", parent.getVersion())) {
                addViolation(
                        problems,
                        Severity.WARNING,
                        Version.BASE,
                        "parent.version",
                        null,
                        "is either LATEST or RELEASE (both of them are being deprecated)",
                        parent);
            }
File Line
org/apache/maven/internal/impl/resolver/DefaultVersionRangeResolver.java 196
org/apache/maven/internal/impl/resolver/DefaultVersionResolver.java 238
VersionRangeResult result) {
        Versioning versioning = null;
        try {
            if (metadata != null) {
                try (SyncContext syncContext = syncContextFactory.newInstance(session, true)) {
                    syncContext.acquire(null, Collections.singleton(metadata));

                    if (metadata.getPath() != null && Files.exists(metadata.getPath())) {
                        try (InputStream in = Files.newInputStream(metadata.getPath())) {
                            versioning =
                                    new MetadataStaxReader().read(in, false).getVersioning();