npm install grunt-phpmd-runner> A phpmd runner that works
~0.4.5If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
``shell`
npm install grunt-phpmd-runner --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js`
grunt.loadNpmTasks('grunt-phpmd-runner');
to the data object passed into grunt.initConfig().`js
grunt.initConfig({
'phpmd-runner': {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
}
}
});
`phpmd currently doesn't support individual files to deal with.
grunt-phpmd-runner bridges that gap... sort of.$3
`js
grunt.initConfig({
'phpmd-runner': {
options: {
phpmd: 'vendor/bin/phpmd',
reportFormat: 'xml',
reportFile: 'reports/md.xml'
rulesets: [
'cleancode',
'codesize',
'controversial',
'design',
'naming',
'unusedcode'
],
strict: true
},
files: '*/.php'
}
});
`$3
`js
grunt.initConfig({
watch: {
php: {
files: '*/.php',
tasks: [
'phpmd-runner'
],
options: {
spawn: false
}
}
},
'phpmd-runner': {
options: {
phpmd: 'vendor/bin/phpmd'
},
files: '*..php'
}
});grunt.event.on('watch', function (action, filepath) {
if (grunt.file.isMatch(grunt.config('watch.php.files'), filepath)) {
grunt.config('phpmd-runner.files', [filepath]);
}
});
`$3
The options more or less mimic
phpmd's configuration parameters.$3
Type: stringThe location of the
phpmd binary$3
Type: stringValid values are:
xml, text, html$3
Type: stringWhere you want the report to be saved
$3
Type: ArrayA collection of rulesets to apply.
$3
Type: stringEquivalent of:
--minimumpriority: rule priority threshold; rules with lower priority than this will not be used$3
Type: string or Array> You can use an array version, it will be converted to the comma separated string phpmd needs
Equivalent of:
--suffixes: comma-separated string of valid source code filename extensions`js
options: {
suffixes: [
'.php',
'.inc'
]
}
`$3
Type: string or Array> You can use an array version, it will be converted to the comma separated string phpmd needs
Equivalent of:
--exclude: comma-separated string of patterns that are used to ignore directories`