diff --git a/build.dist.xml b/build.dist.xml index ef0865a5..bb4f9c73 100644 --- a/build.dist.xml +++ b/build.dist.xml @@ -32,6 +32,17 @@ Configure this target to run the tests. + + + + + + + + + + + diff --git a/circle.dist.yml b/circle.dist.yml index 8310b306..9c478ea8 100644 --- a/circle.dist.yml +++ b/circle.dist.yml @@ -42,4 +42,4 @@ test: - vendor/bin/phing build install migrate override: - - vendor/bin/phing test + - vendor/bin/phing code-review test diff --git a/composer.json b/composer.json index 82b27488..a79d7b07 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,9 @@ "require": { "phing/phing": "^2.14", "continuousphp/phing-drush-task": "dev-master", + "drupal/coder": "^8.2", + "phpmd/phpmd" : "^2.4", + "nilportugues/php_todo": "^1.0", "pear/versioncontrol_git": "@dev" } } diff --git a/conf/php_todo_finder.yml b/conf/php_todo_finder.yml new file mode 100644 index 00000000..d01617a9 --- /dev/null +++ b/conf/php_todo_finder.yml @@ -0,0 +1,7 @@ +todo_finder: + total_allowed: 5 + expressions: + - @todo + - TODO + - refactor + - FIX ME diff --git a/conf/phpmd.xml b/conf/phpmd.xml new file mode 100644 index 00000000..c1a66cfc --- /dev/null +++ b/conf/phpmd.xml @@ -0,0 +1,78 @@ + + + + A PMD Ruleset for Drupal coding standards. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/code_review.md b/docs/code_review.md new file mode 100644 index 00000000..ff8a8872 --- /dev/null +++ b/docs/code_review.md @@ -0,0 +1,40 @@ +# Code Review in the-build + +From your project where you have installed the-build, run `vendor/bin/phing code-review` to run the default set of code reviews. This target is provided in the default `build.xml` created for your project during install. + +This will review your code with: + +* Drupal Codesniffer +* PHPmd +* PHP Lint +* PHPtodo + +Generally, you should configure your `build.xml` to run code reviews as part of your `test` target so that developers run the reviews by default. + +### PHP Lint + +PHP Lint uses the PHP interpreter directly to check for syntax errors. There is no configuration for this review. + +### [PHPMD](https://phpmd.org/) + +A more complicated and more general PHP code review than the Drupal Codesniffer standard. The default config for this review can be found within the-build at `conf/phpmd.xml`. To customize this config, copy that file to your project's `conf/` directory and add the build property: + +``` +phpmd.rulesets=conf/phpmd.xml +``` + +### Drupal Codesniffer + +Runs codesniffer using the standard provided by Drupal's [Coder](https://www.drupal.org/project/coder) module. Generally, you should not change the configuration for this review, but if do need to you can provide a different standard: + +``` +drupal_code_sniffer.standard=vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml +``` + +### [PHP To-do Finder](https://github.com/nilportugues/php-todo-finder) + +Sets a threshold for the number of "to do" comments allowable in a codebase. The default config for this review can be found within the-build at `conf/php_todo_finder.yml`. To customize this config, copy that file to your project's `conf/` directory and add the build property: + +``` +phptodo.config=conf/php_todo_finder.yml +``` diff --git a/tasks/code_review/drupal_code_sniffer.xml b/tasks/code_review/drupal_code_sniffer.xml new file mode 100644 index 00000000..b2736ead --- /dev/null +++ b/tasks/code_review/drupal_code_sniffer.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tasks/code_review/phplint.xml b/tasks/code_review/phplint.xml new file mode 100644 index 00000000..389380bf --- /dev/null +++ b/tasks/code_review/phplint.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + PHP Lint was successful + + + + diff --git a/tasks/code_review/phpmd.xml b/tasks/code_review/phpmd.xml new file mode 100644 index 00000000..4c2ad221 --- /dev/null +++ b/tasks/code_review/phpmd.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tasks/code_review/phptodo.xml b/tasks/code_review/phptodo.xml new file mode 100644 index 00000000..5d12d4f2 --- /dev/null +++ b/tasks/code_review/phptodo.xml @@ -0,0 +1,26 @@ + + + + + + + + Checking modules + + Checking profiles + + Checking themes + + + + +