Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cpp] Repeated Duplication blocks #2438

Closed
augustboland opened this issue Apr 24, 2020 · 2 comments · Fixed by #4966
Closed

[cpp] Repeated Duplication blocks #2438

augustboland opened this issue Apr 24, 2020 · 2 comments · Fixed by #4966
Labels
a:bug PMD crashes or fails to analyse a file. in:cpd Affects the copy-paste detector
Milestone

Comments

@augustboland
Copy link

augustboland commented Apr 24, 2020

Affects PMD Version:
6.22.0+
7.0.0

Description:

When I ran a scan on Linux I received an XML file containing the same duplication block repeated multiple times

Code Sample demonstrating the issue:

<?xml version="1.0" encoding="UTF-8"?>
<pmd-cpd>
   <duplication lines="5" tokens="128">
      <file column="24" endcolumn="31" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="32" endcolumn="31" endline="28" line="24"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="126">
      <file column="24" endcolumn="29" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="2" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="124">
      <file column="24" endcolumn="27" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="4" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="122">
      <file column="24" endcolumn="25" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="6" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="120">
      <file column="24" endcolumn="23" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="8" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="118">
      <file column="24" endcolumn="21" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="10" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="116">
      <file column="24" endcolumn="19" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="12" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="114">
      <file column="24" endcolumn="17" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="14" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="112">
      <file column="24" endcolumn="15" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="16" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="110">
      <file column="24" endcolumn="13" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="18" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="108">
      <file column="24" endcolumn="11" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="20" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="106">
      <file column="24" endcolumn="9" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="22" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="104">
      <file column="24" endcolumn="7" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="24" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="102">
      <file column="24" endcolumn="5" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="26" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
   <duplication lines="5" tokens="100">
      <file column="24" endcolumn="3" endline="24" line="20"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <file column="28" endcolumn="31" endline="28" line="25"
            path="/Users/chris/work/vaults/tvl2/projects/linux/systems/linux-0.01/code/linux/lib/ctype.c"/>
      <codefragment><![CDATA[_L,_L,_L,_P,_P,_P,_P,_C,			/* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 144-159 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 160-175 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,		/* 176-191 */]]></codefragment>
   </duplication>
</pmd-cpd>

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

  1. Linux version 0.01 was scanned using cpd via the CLI
  2. ~/Downloads/pmd-bin-6.22.0/bin/run.sh cpd --minimum-tokens 100 --files tvl2/projects/linux/systems/linux-0.01/code --language cpp --format xml --skip-lexical-errors > tvl2/linux.xml was run

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
CLI

@augustboland augustboland added the a:bug PMD crashes or fails to analyse a file. label Apr 24, 2020
@newtypes9
Copy link

newtypes9 commented May 9, 2020

Is that a bug? The follow blocks have different token numbers. What should be the correct one?

@augustboland
Copy link
Author

Is that a bug? The follow blocks have different token numbers. What should be the correct one?

It seems like it is definitely a bug. The token count is different but the blocks are all identical. I'm assuming the correct token count is the highest and the rest should be ignored.

@jsotuyod jsotuyod added needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale in:cpd Affects the copy-paste detector and removed needs:pmd7-revalidation The issue hasn't yet been retested vs PMD 7 and may be stale labels Apr 2, 2024
jsotuyod added a commit to Monits/pmd that referenced this issue Apr 18, 2024
@jsotuyod jsotuyod added this to the 7.1.0 milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug PMD crashes or fails to analyse a file. in:cpd Affects the copy-paste detector
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants