Package net.sourceforge.pmd.cpd
Class CSVRenderer
- java.lang.Object
-
- net.sourceforge.pmd.cpd.CSVRenderer
-
- All Implemented Interfaces:
CPDReportRenderer
- Direct Known Subclasses:
CSVWithLinecountPerFileRenderer
public class CSVRenderer extends Object implements CPDReportRenderer
Renders a report to CSV. The CSV format renders each match (duplication) as a single line with the following columns:- lines (optional): The number of lines the first mark of a match spans.
Only output if the
lineCountPerFile
is disabled (see ctor params). - tokens: The number of duplicated tokens in a match (size of the match).
- occurrences: The number of duplicates in a match (number of times the tokens were found in distinct places).
Trailing each line are pairs (or triples, if
lineCountPerFile
is enabled) of fields describing each file where the duplication was found in the format(start line, line count (optional), file path)
. These repeat at least twice.Examples
Example without
lineCountPerFile
:
This describes one match with the following characteristics:lines,tokens,occurrences 10,75,2,48,/var/file1,73,/var/file2
- The first duplicate instance is 10 lines long;
- 75 duplicated tokens;
- 2 duplicate instances;
- The first duplicate instance is in file
/var/file1
and starts at line 48; - The second duplicate instance is in file
/var/file2
and starts at line 73.
Example with
lineCountPerFile
:
This describes one match with the following characteristics:tokens,occurrences 75,2,48,10,/var/file1,73,12,/var/file2
- 75 duplicated tokens
- 2 duplicate instances
- The first duplicate instance is in file
/var/file1
, starts at line 48, and is 10 lines long; - The second duplicate instance is in file
/var/file2
, starts at line 73, and is 12 lines long.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_LINECOUNTPERFILE
static char
DEFAULT_SEPARATOR
-
Constructor Summary
Constructors Constructor Description CSVRenderer()
CSVRenderer(boolean lineCountPerFile)
CSVRenderer(char separatorChar)
CSVRenderer(char separatorChar, boolean lineCountPerFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
render(CPDReport report, Writer writer)
Write out the contents of the report to the given writer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.cpd.CPDReportRenderer
renderToString
-
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATOR
- See Also:
- Constant Field Values
-
DEFAULT_LINECOUNTPERFILE
public static final boolean DEFAULT_LINECOUNTPERFILE
- See Also:
- Constant Field Values
-
-
Method Detail
-
render
public void render(CPDReport report, Writer writer) throws IOException
Description copied from interface:CPDReportRenderer
Write out the contents of the report to the given writer.- Specified by:
render
in interfaceCPDReportRenderer
- Parameters:
report
- The report to writewriter
- A writer for the report file- Throws:
IOException
- If the writer throws
-
-