Skip to content
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
27 changes: 5 additions & 22 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
composer remove phpunit/phpunit --dev --no-interaction && composer remove sebastian/phpcpd --no-interaction;
# 2) update tools
composer update;
# 3) reinstall sebastian...
# 3) reinstall sebastian... (phpcpd v4)
composer require phpunit/phpunit:~7.0 --dev && composer require sebastian/phpcpd;
# 4) install suggested tools
bin/suggested-tools.sh install;
Expand All @@ -60,8 +60,8 @@ jobs:
composer remove phpunit/phpunit --dev --no-interaction && composer remove sebastian/phpcpd --no-interaction;
# 2) update tools
composer update;
# 3) reinstall latest versions TODO: phpcpd v6
composer require phpunit/phpunit --dev;
# 3) reinstall latest versions (phpcpd v6)
composer require phpunit/phpunit --dev && composer require sebastian/phpcpd;
# 4) install suggested tools
bin/suggested-tools.sh install;
# 5) fix new php versions
Expand All @@ -74,31 +74,14 @@ jobs:
echo

- name: Show versions
env:
CI_PHP_VERSION: ${{ matrix.php }}
run: |
composer outdated --direct --all
if [[ ${CI_PHP_VERSION:0:3} == "8" ]]; then
# TODO: enable phpqa when robo v2 is supported
echo "Old robo causes fatal errors on php8..."
else
./phpqa tools
fi
./phpqa tools

- name: Run tests
env:
CI_PHP_VERSION: ${{ matrix.php }}
run: |
vendor/phpunit/phpunit/phpunit
if [[ ${CI_PHP_VERSION:0:3} == "7.4" ]]; then
# TODO: revert when phpcpd v6 is supported
./phpqa --config tests/.ci --tools "phpmetrics:0,phploc,phpcs:0,php-cs-fixer,phpmd:0,pdepend,phpcpd,phpstan,phpunit:0,psalm,security-checker,parallel-lint:0"
elif [[ ${CI_PHP_VERSION:0:3} == "8" ]]; then
# TODO: enable phpqa when robo v2 is supported
mkdir -p build
else
bin/ci.sh
fi
bin/ci.sh
ls -lAh build

- name: Upload QA files
Expand Down
4 changes: 4 additions & 0 deletions .phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ phpmetrics:

phpstan:
level: 0
# https://github.com/phpstan/phpstan/issues/1880
memoryLimit: null
# https://github.com/phpstan/phpstan#configuration
# standard: tests/.ci/phpstan.neon

Expand All @@ -82,6 +84,8 @@ psalm:
deadCode: false
threads: 1
showInfo: true
# no memory limit = using ini defaults (https://github.com/EdgedesignCZ/phpqa/issues/144
memoryLimit: null

# paths are relative to .phpqa.yml, so don't copy-paste this section if you don't have custom templates
report:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,15 @@ Tool | Settings | Default Value | Your value
[pdepend.coverageReport](https://github.com/EdgedesignCZ/phpqa/pull/124) | Load Clover style CodeCoverage report | `null` | Path to report produced by PHPUnit's `--coverage-clover` option
[phpmd.standard](http://phpmd.org/documentation/creating-a-ruleset.html) | Ruleset | [Edgedesign's standard](/app/phpmd.xml) | Path to ruleset. To specify [multiple rule sets](https://phpmd.org/documentation/index.html#using-multiple-rule-sets), you can use an array
[phpcpd](https://github.com/sebastianbergmann/phpcpd/blob/de9056615da6c1230f3294384055fa7d722c38fa/src/CLI/Command.php#L136) | Minimum number of lines/tokens for copy-paste detection | 5 lines, 70 tokens |
[phpstan](https://github.com/phpstan/phpstan#configuration) | Level, config file | Level 0, `%currentWorkingDirectory%/phpstan.neon` | Take a look at [phpqa config in tests/.ci](/tests/.ci/) |
[phpstan](https://github.com/phpstan/phpstan#configuration) | Level, config file, memory limit | Level 0, `%currentWorkingDirectory%/phpstan.neon`, memoryLimit: null | Take a look at [phpqa config in tests/.ci](/tests/.ci/) |
[phpunit.binary](https://github.com/EdgedesignCZ/phpqa/blob/4947416/.phpqa.yml#L40) | Phpunit binary | phpqa's phpunit | Path to phpunit executable in your project, typically [`vendor/bin/phpunit`](https://gitlab.com/costlocker/integrations/blob/master/basecamp/backend/.phpqa.yml#L2) |
[phpunit.config](https://phpunit.de/manual/current/en/organizing-tests.html#organizing-tests.xml-configuration) | PHPUnit configuration, `analyzedDirs` and `ignoredDirs` are not used, you have to specify test suites in XML file | `null` | Path to `phpunit.xml` file
[phpunit.reports](https://phpunit.de/manual/current/en/textui.html) | Report types | no report | List of reports and formats, corresponds with CLI option, e.g. `--log-junit` is `log: [junit]` in `.phpqa.yml` |
[psalm.config](https://github.com/vimeo/psalm/wiki/Configuration) | Psalm configuration, `analyzedDirs` and `ignoredDirs` are appended to `projectFiles` | [Predefined config](/app/psalm.xml) | Path to `psalm.xml` file
[psalm.deadCode](https://github.com/vimeo/psalm/wiki/Running-Psalm#command-line-options) | Enable or not `--find-dead-code` option of psalm | `false` | Boolean value
[psalm.threads](https://github.com/vimeo/psalm/wiki/Running-Psalm#command-line-options) | Set the number of process to use in parallel (option `--threads` of psalm) (Only if `--execution == parallel` for phpqa) | `1` | Number (>= 1)
[psalm.showInfo](https://github.com/vimeo/psalm/wiki/Running-Psalm#command-line-options) | Display or not information (non-error) messages (option `--show-info=` of psalm) | `true` | Boolean value
[psalm.memoryLimit](https://github.com/vimeo/psalm/issues/842) | Custom memory limit, ignore unless you are getting `Fatal error: Allowed memory size of ... bytes exhausted` | `null` | String value, e.g. `'1024M'`, `'1G'`

`.phpqa.yml` is automatically detected in current working directory, but you can specify
directory via option:
Expand Down
6 changes: 3 additions & 3 deletions bin/suggested-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ then
echo "Installing suggested tools"
if [ ! -z "$requireMode" ]; then
# docker build OR travis + php 7.0 OR symfony2 (default composer.lock)
composer require symfony/filesystem:~2 symfony/process:~2 symfony/finder:~2 jakub-onderka/php-parallel-lint jakub-onderka/php-console-highlighter phpstan/phpstan:~0.12.0 nette/neon friendsofphp/php-cs-fixer:~2.2 vimeo/psalm:~1 sensiolabs/security-checker:~5 $requireMode
composer require symfony/filesystem:~2 symfony/process:~2 symfony/finder:~2 php-parallel-lint/php-parallel-lint php-parallel-lint/php-console-highlighter phpstan/phpstan nette/neon friendsofphp/php-cs-fixer:~2.2 vimeo/psalm:~2 sensiolabs/security-checker $requireMode
else
# symfony 3
composer require jakub-onderka/php-parallel-lint jakub-onderka/php-console-highlighter phpstan/phpstan nette/neon friendsofphp/php-cs-fixer:~2.2 vimeo/psalm sensiolabs/security-checker
composer require php-parallel-lint/php-parallel-lint php-parallel-lint/php-console-highlighter phpstan/phpstan nette/neon friendsofphp/php-cs-fixer vimeo/psalm sensiolabs/security-checker
fi
else
echo "Removing suggested tools"
composer remove jakub-onderka/php-parallel-lint jakub-onderka/php-console-highlighter phpstan/phpstan friendsofphp/php-cs-fixer vimeo/psalm sensiolabs/security-checker
composer remove php-parallel-lint/php-parallel-lint php-parallel-lint/php-console-highlighter phpstan/phpstan friendsofphp/php-cs-fixer vimeo/psalm sensiolabs/security-checker
fi
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"require": {
"php": ">=5.4",
"ext-xsl": "*",
"consolidation/robo": "~0.5|~1",
"consolidation/robo": "~0.5|~1|~2",
"phpmd/phpmd" : "*",
"phploc/phploc": "*",
"symfony/dependency-injection": ">=2.8.50",
"symfony/filesystem": ">=2.8",
"symfony/process": ">=2.8",
"symfony/finder": ">=2.8",
"symfony/yaml": ">=2.8",
"twig/twig": "~1.38|~2.7",
"twig/twig": "~1.38|~2.7|~3",
"pdepend/pdepend": "*",
"sebastian/phpcpd": "*",
"squizlabs/php_codesniffer": "*",
Expand All @@ -39,8 +39,8 @@
"phpunit/phpunit": "The PHP Unit Testing framework",
"phpstan/phpstan": "PHP Static Analysis Tool - discover bugs in your code without running it!",
"vimeo/psalm": "A static analysis tool for finding errors in PHP applications",
"jakub-onderka/php-parallel-lint": "Check PHP syntax",
"jakub-onderka/php-console-highlighter": "Colored output in parallel-lint"
"php-parallel-lint/php-parallel-lint": "Check PHP syntax",
"php-parallel-lint/php-console-highlighter": "Colored output in parallel-lint"
},
"require-dev": {
"hamcrest/hamcrest-php": ">=2.0.1",
Expand Down
134 changes: 118 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Tools/Analyzer/ParallelLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ParallelLint extends \Edge\QA\Tools\Tool
'optionSeparator' => ' ',
'internalClass' => 'JakubOnderka\PhpParallelLint\ParallelLint',
'outputMode' => OutputMode::RAW_CONSOLE_OUTPUT,
'composer' => 'jakub-onderka/php-parallel-lint',
'composer' => 'php-parallel-lint/php-parallel-lint',
);

public function __invoke()
Expand Down
14 changes: 10 additions & 4 deletions src/Tools/Analyzer/Phpcpd.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Edge\QA\Tools\Analyzer;

use Edge\QA\Tools\GetVersions;

class Phpcpd extends \Edge\QA\Tools\Tool
{
public static $SETTINGS = array(
Expand All @@ -14,20 +16,24 @@ class Phpcpd extends \Edge\QA\Tools\Tool
public function __invoke()
{
$args = array(
'progress' => '',
$this->options->ignore->bergmann(),
$this->options->getAnalyzedDirs(' '),
'min-lines' => $this->config->value('phpcpd.minLines'),
'min-tokens' => $this->config->value('phpcpd.minTokens'),
);
$isOlderVersion = $this->toolVersionIs('<', '6');
$phpcpdNames = array_map(
function ($extension) {
return "*.{$extension}";
function ($extension) use ($isOlderVersion) {
return $isOlderVersion ? "*.{$extension}" : ".{$extension}";
},
array_filter(explode(',', $this->config->csv('phpqa.extensions')))
);
if ($isOlderVersion) {
$args['progress'] = '';
}
if ($phpcpdNames) {
$args['names'] = \Edge\QA\escapePath(implode(',', $phpcpdNames));
$namesOptions = $isOlderVersion ? 'names' : 'suffix';
$args[$namesOptions] = \Edge\QA\escapePath(implode(',', $phpcpdNames));
}
if ($this->options->isSavedToFiles) {
$args['log-pmd'] = $this->tool->getEscapedXmlFile();
Expand Down
Loading