Fork me on GitHub

CPD Results

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

Duplications

File Line
net/nicoulaj/maven/plugins/checksum/execution/target/CsvSummaryFileTarget.java 154
net/nicoulaj/maven/plugins/checksum/execution/target/ShasumSummaryFileTarget.java 154
        @SuppressWarnings("unchecked")
        Map.Entry<ChecksumFile, Map<String, String>>[] entries = filesHashcodes.entrySet().toArray((Map.Entry<ChecksumFile, Map<String, String>>[]) new Map.Entry[0] );
        Arrays.sort(entries, new Comparator<Map.Entry<ChecksumFile, Map<String, String>>>() {
            @Override
            public int compare(Map.Entry<ChecksumFile, Map<String, String>> o1, Map.Entry<ChecksumFile, Map<String, String>> o2) {
                ChecksumFile f1 = o1.getKey();
                ChecksumFile f2 = o2.getKey();
                return f1.getRelativePath(f1, subPath).compareTo(f2.getRelativePath(f2, subPath));
            }
        });

        // Write a line for each file.
        for ( Map.Entry<ChecksumFile, Map<String, String>> entry : entries )
        {
            ChecksumFile file = entry.getKey();
File Line
net/nicoulaj/maven/plugins/checksum/execution/target/CsvSummaryFileTarget.java 90
net/nicoulaj/maven/plugins/checksum/execution/target/ShasumSummaryFileTarget.java 94
    public CsvSummaryFileTarget(File summaryFile, String encoding, Iterable<? extends ArtifactListener> artifactListeners)
    {
        this.summaryFile = summaryFile;
        this.encoding = encoding;
        this.artifactListeners = artifactListeners;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void init()
    {
        filesHashcodes = new HashMap<>();
        algorithms = new TreeSet<>();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void write( String digest, ChecksumFile file, String algorithm )
    {
        // Initialize an entry for the file if needed.
        if ( !filesHashcodes.containsKey( file ) )
        {
            filesHashcodes.put( file, new HashMap<String, String>() );
        }

        // Store the algorithm => hashcode mapping for this file.
        Map<String, String> fileHashcodes = filesHashcodes.get( file );
        fileHashcodes.put( algorithm, digest );

        // Store the algorithm.
        algorithms.add( algorithm );
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void close(final String subPath )
        throws ExecutionTargetCloseException
    {
        // Make sure the parent directory exists.
        try
        {
            Files.createDirectories( summaryFile.getParentFile().toPath() );
        }
        catch ( IOException e )
        {
            throw new ExecutionTargetCloseException( "Could not create summary file parent directory", e );
        }

        StringBuilder sb = new StringBuilder();
File Line
net/nicoulaj/maven/plugins/checksum/execution/target/CsvSummaryFileTarget.java 150
net/nicoulaj/maven/plugins/checksum/execution/target/XmlSummaryFileTarget.java 133
            sb.append( CSV_COLUMN_SEPARATOR ).append( algorithm );
        }

        // Write in sorted order (per globing argument)
        @SuppressWarnings("unchecked")
        Map.Entry<ChecksumFile, Map<String, String>>[] entries = filesHashcodes.entrySet().toArray((Map.Entry<ChecksumFile, Map<String, String>>[]) new Map.Entry[0] );
        Arrays.sort(entries, new Comparator<Map.Entry<ChecksumFile, Map<String, String>>>() {
            @Override
            public int compare(Map.Entry<ChecksumFile, Map<String, String>> o1, Map.Entry<ChecksumFile, Map<String, String>> o2) {
                ChecksumFile f1 = o1.getKey();
                ChecksumFile f2 = o2.getKey();
                return f1.getRelativePath(f1, subPath).compareTo(f2.getRelativePath(f2, subPath));
            }
        });
File Line
net/nicoulaj/maven/plugins/checksum/execution/target/ShasumSummaryFileTarget.java 154
net/nicoulaj/maven/plugins/checksum/execution/target/XmlSummaryFileTarget.java 137
        @SuppressWarnings("unchecked")
        Map.Entry<ChecksumFile, Map<String, String>>[] entries = filesHashcodes.entrySet().toArray((Map.Entry<ChecksumFile, Map<String, String>>[]) new Map.Entry[0] );
        Arrays.sort(entries, new Comparator<Map.Entry<ChecksumFile, Map<String, String>>>() {
            @Override
            public int compare(Map.Entry<ChecksumFile, Map<String, String>> o1, Map.Entry<ChecksumFile, Map<String, String>> o2) {
                ChecksumFile f1 = o1.getKey();
                ChecksumFile f2 = o2.getKey();
                return f1.getRelativePath(f1, subPath).compareTo(f2.getRelativePath(f2, subPath));
            }
        });