Skip to content

Commit 233728c

Browse files
jonatanrdsantosmcfbrunoocasali
authored andcommitted
Add phpmd to project
1 parent 008f093 commit 233728c

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

.github/workflows/tests.yml

+3
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@ jobs:
7575
- name: PHP CS Fixer
7676
run: composer lint:check
7777

78+
- name: PHP MD
79+
run: composer phpmd
80+
7881
- name: PHPstan
7982
run: composer phpstan

CONTRIBUTING.md

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ composer lint:check
6161
composer lint:fix
6262
# PHPstan
6363
composer phpstan
64+
# PHPMD
65+
composer phpmd
6466
```
6567

6668
### Using the Docker Environment

composer.json

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"require-dev": {
3030
"doctrine/annotations": "^2.0",
3131
"doctrine/orm": "^2.9",
32+
"phpmd/phpmd": "^2.13",
3233
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
3334
"nyholm/psr7": "^1.5.1",
3435
"php-cs-fixer/shim": "^3.14",
@@ -62,6 +63,7 @@
6263
}
6364
},
6465
"scripts": {
66+
"phpmd": "./vendor/bin/phpmd src text phpmd.xml",
6567
"phpstan": "./vendor/bin/phpstan --memory-limit=1G --ansi",
6668
"test:unit": "./vendor/bin/phpunit --colors=always --verbose",
6769
"test:unit:coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always --coverage-html=tests/coverage",

phpmd.baseline.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<phpmd-baseline>
3+
<violation rule="PHPMD\Rule\CleanCode\IfStatementAssignment" file="src/Command/IndexCommand.php" method="getEntitiesFromArgs"/>
4+
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/Command/MeiliSearchClearCommand.php"/>
5+
<violation rule="PHPMD\Rule\CyclomaticComplexity" file="src/Command/MeiliSearchCreateCommand.php" method="execute"/>
6+
<violation rule="PHPMD\Rule\CyclomaticComplexity" file="src/Command/MeiliSearchImportCommand.php" method="execute"/>
7+
<violation rule="PHPMD\Rule\Design\NpathComplexity" file="src/Command/MeiliSearchImportCommand.php" method="execute"/>
8+
<violation rule="PHPMD\Rule\Design\CountInLoopExpression" file="src/Command/MeiliSearchImportCommand.php"/>
9+
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/Command/MeiliSearchImportCommand.php"/>
10+
<violation rule="PHPMD\Rule\CleanCode\IfStatementAssignment" file="src/DependencyInjection/MeiliSearchExtension.php" method="load"/>
11+
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/DependencyInjection/MeiliSearchExtension.php"/>
12+
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/DependencyInjection/MeiliSearchExtension.php"/>
13+
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Engine.php"/>
14+
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/Model/Aggregator.php"/>
15+
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/SearchableEntity.php"/>
16+
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/SearchableEntity.php"/>
17+
<violation rule="PHPMD\Rule\Design\TooManyPublicMethods" file="src/Services/MeiliSearchService.php"/>
18+
<violation rule="PHPMD\Rule\Design\CouplingBetweenObjects" file="src/Services/MeiliSearchService.php"/>
19+
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/Services/MeiliSearchService.php"/>
20+
<violation rule="PHPMD\Rule\CleanCode\StaticAccess" file="src/Services/MeiliSearchService.php"/>
21+
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Services/MeiliSearchService.php"/>
22+
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/Services/MeiliSearchService.php"/>
23+
</phpmd-baseline>

phpmd.xml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="Ruleset"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
6+
<description>Ruleset for PHP Mess Detector that enforces coding standards</description>
7+
<rule ref="rulesets/cleancode.xml"/>
8+
<rule ref="rulesets/codesize.xml"/>
9+
<rule ref="rulesets/controversial.xml"/>
10+
<rule ref="rulesets/design.xml"/>
11+
<rule ref="rulesets/naming.xml"/>
12+
<rule ref="rulesets/unusedcode.xml"/>
13+
</ruleset>

0 commit comments

Comments
 (0)