Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Copy-Paste Detector

Tags:

php

pear

My problem is that when I run phpcpd command I always get 0% doubled code result, no matter if it's my project, if it's any php module's files, or if it's a file I created to check if phpcpd works...For example when I check the file below it also displays 0%:

phpcpd folder/file.php:

<?php

class Class_Two {

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }   

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
        }
    }
    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
        }
    }
    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
        }
    }
    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
        }
    }
    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
        }
    }
    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
            echo 'ok';
        }
    }

}

class Class_Two {

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }

    public function aaa()
    {
        if(2 == 2)
        {
            echo 'ok';
        }
    }

}

Any suggestions on why isn't it working properly? Or maybe it is supposed to do some other tasks?

like image 436
user1615069 Avatar asked Sep 01 '12 09:09

user1615069


People also ask

What is PHPCPD?

PHPCPD is a Copy/Paste Detector (CPD) for PHP code. It allows developers to detect duplicated code in PHP projects in order to clean code and improve maintenance. There is a PHPCPD GitHub project with details about how to use this tool.


1 Answers

From http://www.codediesel.com/tools/detecting-duplicate-code-in-php-files/

By default phpcpd will search for a minimum of 5 identical lines and 70 identical tokens. So if there are less than 5 duplicate lines in the code or less than 70 identical tokens they will be ignored. To override this you can use the –min-lines and –min-tokens switch.

like image 131
NotGaeL Avatar answered Oct 05 '22 09:10

NotGaeL