From ace442020ea1eba632dffa7c01223ad5fb16d88b Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 28 Sep 2023 15:03:58 +0200 Subject: [PATCH] Now working with phpmd/phpmd 2.14.0 and up Fixes #243 --- composer.json | 2 +- composer.lock | 19 ++++++++++--------- docs/CHANGELOG.md | 3 +++ src/Command/MessDetectorCommand.php | 9 ++++++++- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 84d745ab..93bb5096 100755 --- a/composer.json +++ b/composer.json @@ -61,7 +61,7 @@ "sebastian/phpcpd": "^6.0.3", "sebastian/version": "^3.0.2", "phpunit/php-timer": "^5.0.3", - "phpmd/phpmd": "2.13.*", + "phpmd/phpmd": "^2.14.0", "symfony/dotenv": "^5.4", "symfony/filesystem": "^5.4", "symfony/finder": "^5.4", diff --git a/composer.lock b/composer.lock index b6fd672c..2b9c4262 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "271cdb231ad7b0c5b053d502cf2a8a14", + "content-hash": "538b1ea2f0258c36ea65262025469fdf", "packages": [ { "name": "composer/pcre", @@ -935,22 +935,22 @@ }, { "name": "phpmd/phpmd", - "version": "2.13.0", + "version": "2.14.0", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "dad0228156856b3ad959992f9748514fa943f3e3" + "reference": "247f84ef5d87323dabe953edc48b09ebabe3a0e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/dad0228156856b3ad959992f9748514fa943f3e3", - "reference": "dad0228156856b3ad959992f9748514fa943f3e3", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/247f84ef5d87323dabe953edc48b09ebabe3a0e6", + "reference": "247f84ef5d87323dabe953edc48b09ebabe3a0e6", "shasum": "" }, "require": { "composer/xdebug-handler": "^1.0 || ^2.0 || ^3.0", "ext-xml": "*", - "pdepend/pdepend": "^2.12.1", + "pdepend/pdepend": "^2.15.0", "php": ">=5.3.9" }, "require-dev": { @@ -960,7 +960,7 @@ "gregwar/rst": "^1.0", "mikey179/vfsstream": "^1.6.8", "phpunit/phpunit": "^4.8.36 || ^5.7.27", - "squizlabs/php_codesniffer": "^2.0" + "squizlabs/php_codesniffer": "^2.9.2 || ^3.7.2" }, "bin": [ "src/bin/phpmd" @@ -997,6 +997,7 @@ "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", "homepage": "https://phpmd.org/", "keywords": [ + "dev", "mess detection", "mess detector", "pdepend", @@ -1006,7 +1007,7 @@ "support": { "irc": "irc://irc.freenode.org/phpmd", "issues": "https://github.com/phpmd/phpmd/issues", - "source": "https://github.com/phpmd/phpmd/tree/2.13.0" + "source": "https://github.com/phpmd/phpmd/tree/2.14.0" }, "funding": [ { @@ -1014,7 +1015,7 @@ "type": "tidelift" } ], - "time": "2022-09-10T08:44:15+00:00" + "time": "2023-09-26T17:42:41+00:00" }, { "name": "phpunit/php-file-iterator", diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1a86b6a0..673d9090 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com). ## [Unreleased] +### Fixed +- Fixed the `phpcmd` command for compatibility with versions `^2.14.0`. + ## [4.1.6] - 2023-09-28 ### Changed - Updated project dependencies to current [moodle-cs](https://github.com/moodlehq/moodle-cs) and [moodle-local_ci](https://github.com/moodlehq/moodle-local_ci) versions. diff --git a/src/Command/MessDetectorCommand.php b/src/Command/MessDetectorCommand.php index 48e47748..aedbf1f0 100644 --- a/src/Command/MessDetectorCommand.php +++ b/src/Command/MessDetectorCommand.php @@ -51,9 +51,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int $ruleSetFactory = new RuleSetFactory(); $ruleSetFactory->setMinimumPriority(5); + $ruleSets = $ruleSetFactory->createRuleSets($rules); $messDetector = new PHPMD(); - $messDetector->processFiles(implode(',', $files), $rules, [$renderer], $ruleSetFactory, new Report()); + $messDetector->processFiles( + implode(',', $files), + [], // Ignored paths and files are managed by the plugin, so they are not needed here. + [$renderer], + $ruleSets, + new Report(), + ); return 0; }