Skip to content

Add phpmd to project #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@ jobs:
- name: PHP CS Fixer
run: composer lint:check

- name: PHP MD
run: composer phpmd
continue-on-error: true

- name: PHPstan
run: composer phpstan
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ composer lint:check
composer lint:fix
# PHPstan
composer phpstan
# PHPMD
composer phpmd
```

### Using the Docker Environment
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"require-dev": {
"doctrine/annotations": "^2.0",
"doctrine/orm": "^2.9",
"phpmd/phpmd": "^2.13",
"matthiasnoback/symfony-dependency-injection-test": "^4.3",
"nyholm/psr7": "^1.5.1",
"php-cs-fixer/shim": "^3.14",
Expand Down Expand Up @@ -62,6 +63,7 @@
}
},
"scripts": {
"phpmd": "./vendor/bin/phpmd src text phpmd.xml",
"phpstan": "./vendor/bin/phpstan --memory-limit=1G --ansi",
"test:unit": "./vendor/bin/phpunit --colors=always --verbose",
"test:unit:coverage": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always --coverage-html=tests/coverage",
Expand Down
23 changes: 23 additions & 0 deletions phpmd.baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<phpmd-baseline>
<violation rule="PHPMD\Rule\CleanCode\IfStatementAssignment" file="src/Command/IndexCommand.php" method="getEntitiesFromArgs"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/Command/MeiliSearchClearCommand.php"/>
<violation rule="PHPMD\Rule\CyclomaticComplexity" file="src/Command/MeiliSearchCreateCommand.php" method="execute"/>
<violation rule="PHPMD\Rule\CyclomaticComplexity" file="src/Command/MeiliSearchImportCommand.php" method="execute"/>
<violation rule="PHPMD\Rule\Design\NpathComplexity" file="src/Command/MeiliSearchImportCommand.php" method="execute"/>
<violation rule="PHPMD\Rule\Design\CountInLoopExpression" file="src/Command/MeiliSearchImportCommand.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/Command/MeiliSearchImportCommand.php"/>
<violation rule="PHPMD\Rule\CleanCode\IfStatementAssignment" file="src/DependencyInjection/MeiliSearchExtension.php" method="load"/>
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/DependencyInjection/MeiliSearchExtension.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/DependencyInjection/MeiliSearchExtension.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Engine.php"/>
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/Model/Aggregator.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/SearchableEntity.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/SearchableEntity.php"/>
<violation rule="PHPMD\Rule\Design\TooManyPublicMethods" file="src/Services/MeiliSearchService.php"/>
<violation rule="PHPMD\Rule\Design\CouplingBetweenObjects" file="src/Services/MeiliSearchService.php"/>
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/Services/MeiliSearchService.php"/>
<violation rule="PHPMD\Rule\CleanCode\StaticAccess" file="src/Services/MeiliSearchService.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Services/MeiliSearchService.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/Services/MeiliSearchService.php"/>
</phpmd-baseline>
13 changes: 13 additions & 0 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Ruleset for PHP Mess Detector that enforces coding standards</description>
<rule ref="rulesets/cleancode.xml"/>
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/controversial.xml"/>
<rule ref="rulesets/design.xml"/>
<rule ref="rulesets/naming.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
</ruleset>