Questions tagged [phpmd]

PHPMD - the PHP Mess Detector -- is a code quality analysis tool for PHP, similar to PMD for Java.

80 questions
2
votes
1 answer

PHPMD not outputting file results

I was asked to implement PHPMD at work (as well as PHPCS... another upcoming posted question, I assume). I am not very Linux-savvy, either. Sorry. I followed the download instructions on PHPMD. I used Composer and got all the dependencies properly…
Robert Broden
  • 118
  • 4
  • 11
2
votes
1 answer

How to avoid superglobals using PHPMD

I really love phpmd to ensure a minimum level of code quality in our PHP projects. Now I like to add a rule to dectect the use of superglobals. But I do not want to have the whole controversial ruleset included. I tried the following line (phpmd…
Trendfischer
  • 7,112
  • 5
  • 40
  • 51
2
votes
1 answer

PHPMD @bin_dir@ error

I try to install PHPMD on Windows computer using the comments below $ git clone git://github.com/phpmd/phpmd.git cd phpmd $ git submodule update --init $ php composer.phar install After installed PHPMD, I am getting the below error when I am trying…
Muthamizhchelvan. V
  • 1,241
  • 1
  • 17
  • 30
2
votes
1 answer

Sublime-phpcs - Can't get PHP MD and CS packages to function properly

I've been trying to configure sublime-phpcs. I've installed pear and from command line installed PHP_CodeSniffer, and PHPMD using their documented install procedures. PHP and pear are in my path at d:/Program Files/xampp/php and d:/Program…
mtpultz
  • 17,267
  • 22
  • 122
  • 201
2
votes
2 answers

Sonar and PHPMD: how to exclude directories

I'm trying Sonar and i've got some issues with it for a php project. I have to do it multi-module to get at least php and js analysis. this is my…
apelliciari
  • 8,241
  • 9
  • 57
  • 92
1
vote
3 answers

Fix code with high NPath complexity

I was analyzing my code with PHP Mess Detector when PHPMD reported some of my codes has high NPath Complexity. One example would be: function compareDates($date1, $date2){ if($date->year < $date2->year){ return -1; } …
mauris
  • 42,982
  • 15
  • 99
  • 131
1
vote
0 answers

PHP Mess Detector did not allow private methods with underscore prefix

I tested my code and encountered an error on mess detector. It seems like PHP Mess Detector did not allow private methods to be prefixed with underscore as it did not fulfil mess detector requirements, and stated that the methods shall be named in…
1
vote
1 answer

Problem with phpmd and Function libxml_disable_entity_loader()

I'm trying to run this command: docker run -it --rm -v ${pwd}:/project -w /project jakzal/phpqa phpmd app text cleancode,codesize,controversial,design,naming,unusedcode And it returns: Deprecated: Function libxml_disable_entity_loader() is…
1
vote
1 answer

Why PhpStorm doesn't see files in /usr/bin?

I'm trying to configure PhpStorm 2019.3, my system is Linux Mint. When I trying to set paths for utilities Mess Detector (phpmd), Code Sniffer (phpcs) and Mercurial (hg), PhpStorm is saying: error=2, no such file or directory. Problem is that…
markel12
  • 21
  • 2
1
vote
1 answer

Unable to change ExcessiveMethodLength on phpmd via codeclimate

Warnings like this keep popping up in Code Climate for my project: File YummySearchComponent.php has 360 lines of code (exceeds 250 allowed). Consider refactoring. Method getYummyHelperData has 43 lines of code (exceeds 25 allowed). Consider…
cnizzardini
  • 1,196
  • 1
  • 13
  • 29
1
vote
0 answers

Issue with Code Sniffer on Ubuntu 16 - Install pfff

I am trying to setup PHPCS, PHPMD on my Ubuntu 16.04 I was following these instruction but I am getting stuck at Installing pfff which phpcs -/usr/bin/phpcs which phpcbf -/usr/bin/phpcbf which php-cs-fixer -/usr/local/bin/php-cs-fixer which…
1
vote
0 answers

PHPMD not working rules ShortVariable and ignore TooManyFields

Can anyone tell me why under PHPSTORM 2017.1 and PHPMD 2.6.0 some configuration options doesn't work: ShortVariable PhpStorm mark variable private $id; as "Configured minimum length is 3" ignore field TooManyFields PhpStorm show: "The…
Arkowsky
  • 851
  • 7
  • 19
1
vote
1 answer

PhpStorm phpmd custom ruleset

I did the following Download PHP Mess Detector Plugin Choose a PHP Interpreter (Languages & Frameworks -> PHP -> CLI Interpeter Made sure that my Mess Detector Plugin is setup is properly and has a Interpreter assigned, that has phpmd installed.…
Max Schindler
  • 380
  • 2
  • 17
1
vote
1 answer

PHPCS / PHPMD : Is there a PHP Code Sniffer / Mess Detector way to ensure there are docblocks?

Is there a way I can use PHP Code Sniffer and/or PHP Mess Detector to detect if my classes/properties/methods have proper docblocks? For example: class Foo { protected $bar; public function doStuff(){ // ... } } The above…
Giel Berkers
  • 2,852
  • 3
  • 39
  • 58
1
vote
1 answer

PHPMD ignoring ruleset

I have set this rule in the phpmd.xml file: But this rule is being ignored, I still get this…
albanx
  • 6,193
  • 9
  • 67
  • 97