CPD Results

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

Duplications

File Line
org\apache\maven\plugins\checkstyle\AbstractCheckstyleReport.java 700
org\apache\maven\plugins\checkstyle\CheckstyleViolationCheckMojo.java 869
protected List<File> getTestSourceDirectories() {
        if (testSourceDirectories == null) {
            testSourceDirectories = filterBuildTarget(project.getTestCompileSourceRoots());
        }
        List<File> testSourceDirs = new ArrayList<>(testSourceDirectories.size());
        for (String testSourceDir : testSourceDirectories) {
            testSourceDirs.add(FileUtils.resolveFile(project.getBasedir(), testSourceDir));
        }
        return testSourceDirs;
    }

    private List<String> filterBuildTarget(List<String> sourceDirectories) {
        if (!excludeGeneratedSources) {
            return sourceDirectories;
        }

        List<String> filtered = new ArrayList<>(sourceDirectories.size());
        Path buildTarget = FileUtils.resolveFile(
                        project.getBasedir(), project.getBuild().getDirectory())
                .toPath();

        for (String sourceDir : sourceDirectories) {
            Path src = FileUtils.resolveFile(project.getBasedir(), sourceDir).toPath();
            if (!src.startsWith(buildTarget)) {
                filtered.add(sourceDir);
            }
        }
        return filtered;
    }
}
File Line
org\apache\maven\plugins\checkstyle\AbstractCheckstyleReport.java 580
org\apache\maven\plugins\checkstyle\CheckstyleViolationCheckMojo.java 830
private List<Artifact> collectArtifacts(String hint) {
        List<Artifact> artifacts = new ArrayList<>();

        PluginManagement pluginManagement = project.getBuild().getPluginManagement();
        if (pluginManagement != null) {
            artifacts.addAll(getCheckstylePluginDependenciesAsArtifacts(pluginManagement.getPluginsAsMap(), hint));
        }

        artifacts.addAll(
                getCheckstylePluginDependenciesAsArtifacts(project.getBuild().getPluginsAsMap(), hint));

        return artifacts;
    }

    private List<Artifact> getCheckstylePluginDependenciesAsArtifacts(Map<String, Plugin> plugins, String hint) {
        List<Artifact> artifacts = new ArrayList<>();

        Plugin checkstylePlugin = plugins.get(plugin.getGroupId() + ":" + plugin.getArtifactId());
        if (checkstylePlugin != null) {
            for (Dependency dep : checkstylePlugin.getDependencies()) {
                // @todo if we can filter on hints, it should be done here...
                String depKey = dep.getGroupId() + ":" + dep.getArtifactId();
                artifacts.add(plugin.getArtifactMap().get(depKey));
            }
        }
        return artifacts;
    }
File Line
org\apache\maven\plugins\checkstyle\CheckstyleAggregateReport.java 46
org\apache\maven\plugins\checkstyle\CheckstyleReport.java 46
.setConsoleListener(getConsoleListener())
                .setConsoleOutput(consoleOutput)
                .setExcludes(excludes)
                .setFailsOnError(failsOnError)
                .setIncludes(includes)
                .setResourceIncludes(resourceIncludes)
                .setResourceExcludes(resourceExcludes)
                .setIncludeResources(includeResources)
                .setIncludeTestResources(includeTestResources)
                .setIncludeTestSourceDirectory(includeTestSourceDirectory)
                .setListener(getListener())
                .setProject(project)
                .setSourceDirectories(getSourceDirectories())
                .setResources(resources)
                .setTestResources(testResources)
                .setStringOutputStream(stringOutputStream)
                .setSuppressionsLocation(suppressionsLocation)
                .setTestSourceDirectories(getTestSourceDirectories())
                .setPropertyExpansion(propertyExpansion)
                .setHeaderLocation(headerLocation)
                .setCacheFile(cacheFile)
                .setSuppressionsFileExpression(suppressionsFileExpression)
                .setEncoding(getInputEncoding())
                .setPropertiesLocation(propertiesLocation);
        return request;
    }

    /** {@inheritDoc} */
    public String getOutputName() {
        return "checkstyle-aggregate";
File Line
org\apache\maven\plugins\checkstyle\CheckstyleReport.java 44
org\apache\maven\plugins\checkstyle\CheckstyleViolationCheckMojo.java 527
protected CheckstyleExecutorRequest createRequest() throws MavenReportException {
        CheckstyleExecutorRequest request = new CheckstyleExecutorRequest();
        request.setConsoleListener(getConsoleListener())
                .setConsoleOutput(consoleOutput)
                .setExcludes(excludes)
                .setFailsOnError(failsOnError)
                .setIncludes(includes)
                .setResourceIncludes(resourceIncludes)
                .setResourceExcludes(resourceExcludes)
                .setIncludeResources(includeResources)
                .setIncludeTestResources(includeTestResources)
                .setIncludeTestSourceDirectory(includeTestSourceDirectory)
                .setListener(getListener())
                .setProject(project)
                .setSourceDirectories(getSourceDirectories())
                .setResources(resources)
                .setTestResources(testResources)
                .setStringOutputStream(stringOutputStream)
                .setSuppressionsLocation(suppressionsLocation)
                .setTestSourceDirectories(getTestSourceDirectories())
                .setPropertyExpansion(propertyExpansion)