0

test.c

void fun(){
        printf("int main char");
    }

    int main()
    {
        printf("int main int");
    }

Im giving the command like this "run.sh cpd --minimum-tokens 5 --files /opt/test.c --language c" and the output is as follows :

Found a 2 line (5 tokens) duplication in the following files:
Starting at line 1 of /opt/test.c
Starting at line 5 of /opt/test.c

void fun(){
    printf("int main char ");

Even if there is no duplication, it is telling the code is duplicated because of minimum tokens. Is there any way to specify the command without minimum tokens flag.

void fun(){
    printf("int main int");
}

int main(){
    printf("int main int");
}

I specified the command like this "run.sh cpd --minimum-tokens 9 --files /opt/test.c --language c" the output is as follows:

  Added /opt/test.c <--- (No line duplication reported by tool)

This is because I specified the token value greater than the required token value which is 8. In the above case even if there is a duplicated code the tool is not returning any duplicated code.

So how to conclude on Min token size in such scenario in order to get correct duplication of code

Edited by ANVESH_2

3
Contributors
3
Replies
25
Views
1 Year
Discussion Span
Last Post by ANVESH_2
0

I took a look at this old thing and there's a book and more out there. https://pmdapplied.com/

What I see is something that looks to have no active updates for about 5 years so this is a tool and like any tool of this ilk, once in a while you find someone thinking it does "this." A few others may think it's a panacea.

Don't get me wrong I like automated code inspection but there are folk that want to make it a rule or a gauntlet thou shall pass. (or not.) For me I'll get by with turning all the warnings on with a simple -wall.

0

Honestly, in 35 years of C and C++ software development professionally, I have never seen such an error. What compiler (and version) are you using?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.