diff --git a/.github/workflows/phpmd.yml b/.github/workflows/phpmd.yml index 7e9af23..8f61d3e 100644 --- a/.github/workflows/phpmd.yml +++ b/.github/workflows/phpmd.yml @@ -47,7 +47,7 @@ jobs: tools: phpmd - name: Run PHPMD - run: phpmd . sarif codesize --reportfile phpmd-results.sarif + run: phpmd --ignore-violations-on-exit . sarif phpmd.ruleset.xml --reportfile phpmd-results.sarif continue-on-error: true - name: Upload analysis results to GitHub diff --git a/composer.json b/composer.json index 8f46bec..384df3c 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "scripts": { "phpcs": "phpcs", "phpstan": "phpstan analyse", - "phpunit": "phpunit" + "phpunit": "phpunit", + "phpmd": "phpmd src,tests ansi phpmd.ruleset.xml" }, "require": { "php": "^7.3 || ^8.0", @@ -34,6 +35,7 @@ "require-dev": { "httpwg/structured-field-tests": "*@dev", "paragonie/constant_time_encoding": "^2.6.3", + "phpmd/phpmd": "^2.15", "phpstan/phpstan": "^1.9", "phpstan/phpstan-phpunit": "^1.3", "phpunit/phpunit": "^9.5.27", diff --git a/phpmd.ruleset.xml b/phpmd.ruleset.xml new file mode 100644 index 0000000..3a24322 --- /dev/null +++ b/phpmd.ruleset.xml @@ -0,0 +1,13 @@ + + + PHPMD Ruleset + + + + diff --git a/src/Parser.php b/src/Parser.php index 2662761..13a59f5 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -4,6 +4,9 @@ namespace gapple\StructuredFields; +/** + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + */ class Parser { public static function parseDictionary(string $string): Dictionary @@ -276,6 +279,9 @@ private static function parseString(string &$string): string throw new ParseException("Invalid end of string"); } + /** + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ private static function parseDisplayString(string &$string): DisplayString { if (strpos($string, '%"') !== 0) { diff --git a/src/Serializer.php b/src/Serializer.php index a3438b0..8c126ae 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -4,6 +4,9 @@ namespace gapple\StructuredFields; +/** + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + */ class Serializer { /** @@ -145,6 +148,8 @@ private static function serializeInnerList(array $value, ?object $parameters = n /** * @param mixed $value + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private static function serializeBareItem($value): string { diff --git a/tests/Httpwg/HttpwgTest.php b/tests/Httpwg/HttpwgTest.php index 78a675d..bea80a0 100644 --- a/tests/Httpwg/HttpwgTest.php +++ b/tests/Httpwg/HttpwgTest.php @@ -29,6 +29,9 @@ abstract class HttpwgTest extends RulesetTest */ protected $ruleset; + /** + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ protected function rulesetDataProvider(): array { $path = __DIR__ . '/../../vendor/httpwg/structured-field-tests/' . $this->ruleset . '.json';