Running cpd3.5 with the following commandline java
net.sourceforge.pmd.cpd.CPD --minimum-tokens 2 --files
test3 --language cpp
I get different result depending on if the line
with int i is commented away or not.
Moreover CPD report duplicate duplicates ;)
That is: it reports duplicates that are in range
of another duplicate.
Notice that in the first example CPD doesn't
even detect the 4 line duplicate.
Moreover the output is not correct in the second case.
Output follows:
First with the int i variable present.
java net.sourceforge.pmd.cpd.CPD --minimum-tokens 2
--files test3 --language cpp
Added /work/pkg/pmd/test3/test3.cpp
=====================================================================
Found a 2 line (2 tokens) duplication in the following
files:
Starting at line 2 of /work/pkg/pmd/test3/test3.cpp
Starting at line 3 of /work/pkg/pmd/test3/test3.cpp
Starting at line 4 of /work/pkg/pmd/test3/test3.cpp
Starting at line 5 of /work/pkg/pmd/test3/test3.cpp
int c;
int d;
Then with int i commented away:
java net.sourceforge.pmd.cpd.CPD --minimum-tokens 2
--files test3 --language cpp
Added /work/pkg/pmd/test3/test3.cpp
=====================================================================
Found a 4 line (12 tokens) duplication in the following
files:
Starting at line 3 of /work/pkg/pmd/test3/test3.cpp
Starting at line 8 of /work/pkg/pmd/test3/test3.cpp
int a;
int b;
int c;
int d;
=====================================================================
Found a 3 line (2 tokens) duplication in the following
files:
Starting at line 3 of /work/pkg/pmd/test3/test3.cpp
Starting at line 4 of /work/pkg/pmd/test3/test3.cpp
Starting at line 5 of /work/pkg/pmd/test3/test3.cpp
Starting at line 6 of /work/pkg/pmd/test3/test3.cpp
int d;
int main() {
int i; // Comment this line away with // and get a
different result
int a;
int b;
int c;
int d;
int a;
int b;
int c;
int d;
}