-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add support for multiple phpmd rulesets #164
Add support for multiple phpmd rulesets #164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks useful. Review:
- Isn't escaping necessary? What if path contains space?
- Missing documentation - readme, .phpqa.yml (link to phpmd should be good enough)
Hi @zdenekdrahos, I made the following changes:
For example, with the following config: phpmd:
standard:
- test with spaces/naming.xml
- unusedcode The argument in the command line will be:
|
I'm sorry I haven't noticed it before, but dropping Experiment#!/bin/sh
TEST_DIR="phpmdtest"
STANDARD=${1:-"phpmd.xml"}
run () {
init_dir
configure_phpqa
run_phpqa
}
init_dir() {
rm -rf $TEST_DIR
mkdir $TEST_DIR
}
configure_phpqa () {
cp app/phpmd.xml $TEST_DIR
cat > $TEST_DIR/.phpqa.yml << EOL
phpmd:
standard: $STANDARD
EOL
}
run_phpqa () {
./phpqa --verbose --report --config $TEST_DIR --tools phpmd:0
}
run Current results$ bash phpmd-test.sh
[FileSystem\CleanDir] Cleaned build/
[FileSystem\FilesystemStack] mkdir ["build\/"]
[Edge\QA\Task\ParallelExec] "/root-dir/vendor/bin/phpmd" "./" xml "phpmd.xml" --exclude /vendor/ --suffixes php --reportfile "build//phpmd.xml"
1/1 [============================] 100%
[Edge\QA\Task\ParallelExec] Output for "/root-dir/vendor/bin/phpmd" "./" xml "phpmd.xml" --exclude /vendor/ --suffixes php --reportfile "build//phpmd.xml"
Cannot find specified rule-set "phpmd.xml". Expected results$ bash phpmd-test.sh
[FileSystem\CleanDir] Cleaned build/
[FileSystem\FilesystemStack] mkdir ["build\/"]
[Edge\QA\Task\ParallelExec] "/root-dir/vendor/bin/phpmd" "./" xml "/root-dir/phpmdtest/phpmd.xml" --exclude /vendor/ --suffixes php --reportfile "build//phpmd.xml"
1/1 [============================] 100%
[Edge\QA\Task\ParallelExec] Output for "/root-dir/vendor/bin/phpmd" "./" xml "/root-dir/phpmdtest/phpmd.xml" --exclude /vendor/ --suffixes php --reportfile "build//phpmd.xml" $ bash phpmd-test.sh "[unusedcode,phpmd.xml]"
[FileSystem\CleanDir] Cleaned build/
[FileSystem\FilesystemStack] mkdir ["build\/"]
[Edge\QA\Task\ParallelExec] "/root-dir/vendor/bin/phpmd" "./" xml "unusedcode,/root-dir/phpmdtest/phpmd.xml" --exclude /vendor/ --suffixes php --reportfile "build//phpmd.xml"
1/1 [============================] 100%
[Edge\QA\Task\ParallelExec] Output for "/root-dir/vendor/bin/phpmd" "./" xml "unusedcode,/root-dir/phpmdtest/phpmd.xml" --exclude /vendor/ --suffixes php --reportfile "build//phpmd.xml" Possible ImplementationI would add this method below public function pathsOrValues($path)
{
return $this->get(
$path,
function ($values, $dir) {
return array_map(
function ($pathOrValue) use ($dir) {
$realpath = realpath("{$dir}{$pathOrValue}");
return $realpath ? $realpath : $pathOrValue;
},
(array) $values
);
}
);
} |
@zdenekdrahos Thanks for the input, I updated the commit with the modification you suggested :) |
Hi!
Currently, the .phpqa file only allows to specify one PHPMD ruleset, whereas phpmd allows to specify multiple rulesets.
For example:
bin/phpmd src/ xml cleancode,codesize,design,naming,unusedcode --suffixes php
This PR adds support for specifying multiple rulesets, and preserves backwards-compatibility.
To allow specifying default rulesets (e.g.
unusedcode
), I also removed the call to thepath
function.The following configurations would all work: