Skip to content

Commit

Permalink
enables more phpmd rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Apr 21, 2023
1 parent cef60d1 commit a357f2c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: "Run PHPMD checks"
if: ${{ env.DIFF != '' }}
run: php phpmd `echo "$DIFF" | tr ' ' ','` text phpmd.xml
run: php phpmd `echo "$DIFF" | tr ' ' ','` github phpmd.xml
env:
DIFF: ${{ steps.diff.outputs.diff_php }}

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@
"symfony/web-profiler-bundle": "4.4.*",
"symfony/yaml": "4.4.*",
"twig/twig": "^2.14",
"willdurand/js-translation-bundle": "^4.0"
"willdurand/js-translation-bundle": "^4.0",
"http-interop/http-factory-guzzle": "^1.2"
},
"require-dev": {
"symfony/dom-crawler": "4.4.*",
"symfony/css-selector": "4.4.*",
"friendsofphp/php-cs-fixer": "^2.15",
"mockery/mockery": "^1.2",
"mikey179/vfsstream": "1.6.8",
"phpmd/phpmd": "^2.9.1",
"phpmd/phpmd": "^2.13",
"symfony/phpunit-bridge": "^4.4"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion docs/sections/dev/code-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The ruleset used in the project is defined in *phpmd.xml*.
Usage example :
```sh
$ phpmd src/plugin/FooVendor/BarBundle text app/dev/config/phpmd.xml
$ vendor/bin/phpmd src/plugin/FooVendor/BarBundle text phpmd.xml
```


Expand Down
33 changes: 27 additions & 6 deletions docs/sections/dev/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,38 @@ You can create an empty database using:
$ php bin/console doctrine:database:create
```

### Generating migrations
### Database migrations

A properly installed platform will include the MigrationBundle.
It includes several usefull commands.
Please read the MigrationBundle readme for me informations
> **ATTENTION: ** You MUST NOT use the doctrine default `doctrine:schema:update --force` to apply
> schema modifications to your DB.
Generate migrations for entity modifications :

```sh
$ php bin/console claroline:migration:generate FooBarBundle
```

Apply migrations to the database :

```sh
$ php bin/console claroline:migration:upgrade FooBarBundle
```

> **NB: ** Pending migrations are automatically run by the `claroline:update` command.

### Plugins management

Plugins are registered with the command:

```sh
$ php bin/console claroline:plugin:install
$ php bin/console claroline:plugin:install FooBarBundle
```

You can remove plugins with:

```sh
$ php bin/console claroline:plugin:uninstall
$ php bin/console claroline:plugin:uninstall FooBarBundle
```

**Tips:** The list of registered bundle is saved in the file
Expand Down Expand Up @@ -85,6 +98,14 @@ $ php bin/console cache:clear

## Code quality

See [Code analysis](Claroline/sections/dev/code-analysis) for more information.

### PHP Mess Detector

```sh
$ vendor/bin/phpmd src/plugin/FooVendor/BarBundle text phpmd.xml
```

## Tests

## Translations
Expand Down
19 changes: 13 additions & 6 deletions phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,30 @@

<rule ref="rulesets/cleancode.xml/IfStatementAssignment" />
<rule ref="rulesets/cleancode.xml/DuplicatedArrayKey" />
<!--<rule ref="rulesets/cleancode.xml/MissingImport" />-->
<rule ref="rulesets/cleancode.xml/ErrorControlOperator" />
<rule ref="rulesets/cleancode.xml/UndefinedVariable" />

<rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" />
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" />

<rule ref="rulesets/design.xml/ExitExpression" />
<rule ref="rulesets/design.xml/EvalExpression" />
<rule ref="rulesets/design.xml/GotoStatement" />
<rule ref="rulesets/design.xml/DevelopmentCodeFragment" />

<!-- NICE TO HAVE -->
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength" />
<rule ref="rulesets/codesize.xml/ExcessiveParameterList" />
<rule ref="rulesets/codesize.xml/ExcessivePublicCount" />

<!-- <rule ref="rulesets/codesize.xml/ExcessiveMethodLength" /> -->
<!-- <rule ref="rulesets/codesize.xml/ExcessiveParameterList" /> -->
<!-- <rule ref="rulesets/naming.xml/BooleanGetMethodName" /> -->
<!-- <rule ref="rulesets/controversial.xml" /> -->
<rule ref="rulesets/naming.xml/BooleanGetMethodName" />
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />

<rule ref="rulesets/controversial.xml/Superglobals" />
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
</ruleset>

0 comments on commit a357f2c

Please sign in to comment.