From 94835cb123377156a190e2ab4b50981d586539d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 12 Aug 2018 18:08:39 +0200 Subject: [PATCH 1/7] Require PHP 7.2 --- .scrutinizer.yml | 99 +++++++++++++++++------------------------------- .travis.yml | 4 +- composer.json | 2 +- 3 files changed, 38 insertions(+), 67 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index cf3d404a..53e89b0d 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,66 +1,37 @@ build: - environment: - mysql: false - postgresql: false - redis: false - rabbitmq: false - php: - version: 7.1.0 -tools: - php_sim: true - php_pdepend: true - php_analyzer: true - php_changetracking: true - sensiolabs_security_checker: true - php_mess_detector: true - php_code_coverage: true - external_code_coverage: - timeout: 1800 - php_code_sniffer: - enabled: true - config: - standard: "PSR2" - php_cpd: - enabled: true - excluded_dirs: ["test", "vendor"] - php_loc: - enabled: true - excluded_dirs: ["test", "vendor"] + nodes: + analysis: + environment: + mysql: false + postgresql: false + redis: false + rabbitmq: false + mongodb: false + php: + version: 7.2 + cache: + disabled: false + directories: + - ~/.composer/cache + + project_setup: + override: true + tests: + override: + - php-scrutinizer-run + - phpcs-run + + dependencies: + override: + - composer install --no-interaction --prefer-dist + checks: - php: - code_rating: true - duplication: true - argument_type_checks: true - assignment_of_null_return: true - avoid_conflicting_incrementers: true - avoid_useless_overridden_methods: true - catch_class_exists: true - closure_use_modifiable: true - closure_use_not_conflicting: true - deprecated_code_usage: true - method_calls_on_non_object: true - missing_arguments: true - no_duplicate_arguments: true - no_non_implemented_abstract_methods: true - no_property_on_interface: true - parameter_non_unique: true - precedence_in_conditions: true - precedence_mistakes: true - require_php_tag_first: true - security_vulnerabilities: true - sql_injection_vulnerabilities: true - too_many_arguments: true - unreachable_code: true - unused_methods: true - unused_parameters: true - unused_properties: true - unused_variables: true - use_statement_alias_conflict: true - useless_calls: true - variable_existence: true - verify_access_scope_valid: true - verify_argument_usable_as_reference: true - verify_property_names: true -filter: - excluded_paths: - - test/* + php: true + +tools: + external_code_coverage: true + +build_failure_conditions: + - 'elements.rating(<= C).new.exists' + - 'issues.severity(>= MAJOR).new.exists' + - 'project.metric_change("scrutinizer.test_coverage", < -0.01)' diff --git a/.travis.yml b/.travis.yml index 290d1708..9c65480d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: php sudo: false php: - - 7.1 + - 7.2 - nightly cache: @@ -10,7 +10,7 @@ cache: - $HOME/.composer/cache before_script: - - if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then PHPUNIT_FLAGS="--coverage-clover ./clover.xml"; else PHPUNIT_FLAGS=""; fi + - if [[ $TRAVIS_PHP_VERSION = '7.2' ]]; then PHPUNIT_FLAGS="--coverage-clover ./clover.xml"; else PHPUNIT_FLAGS=""; fi - composer self-update - composer install diff --git a/composer.json b/composer.json index 89225c86..af6fb774 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ } ], "require": { - "php": "^7.1" + "php": "^7.2" }, "require-dev": { "phpunit/phpunit": "^6.1" From e3170595ce67b4fe907d7425e82dbe9285c5bddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 12 Aug 2018 18:19:28 +0200 Subject: [PATCH 2/7] Use Travis-CI build stages --- .travis.yml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c65480d..4454679b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: trusty language: php sudo: false @@ -9,14 +10,28 @@ cache: directories: - $HOME/.composer/cache -before_script: - - if [[ $TRAVIS_PHP_VERSION = '7.2' ]]; then PHPUNIT_FLAGS="--coverage-clover ./clover.xml"; else PHPUNIT_FLAGS=""; fi +before_install: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" - composer self-update - - composer install + +install: travis_retry composer install script: - - ./vendor/bin/phpunit $PHPUNIT_FLAGS + - ./vendor/bin/phpunit --testsuite=unit + - ./vendor/bin/phpunit + +jobs: + allow_failures: + - php: nightly -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - if [ -f clover.xml ]; then php ocular.phar code-coverage:upload --format=php-clover ./clover.xml; fi + include: + - stage: Metrics and quality + env: COVERAGE + before_script: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} + - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi + script: + - ./vendor/bin/phpunit --coverage-clover ./clover.xml + after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover ./clover.xml From 629b2952f03d9a12fbed495ac8b702a97f658ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 12 Aug 2018 18:22:15 +0200 Subject: [PATCH 3/7] Check code standard --- .gitattributes | 12 ++++++------ .gitignore | 10 +++++----- .travis.yml | 5 +++++ composer.json | 1 + phpcs.xml.dist | 17 +++++++++++++++++ src/Clock.php | 1 - src/FrozenClock.php | 1 - src/SystemClock.php | 4 ++-- test/FrozenClockTest.php | 5 ++--- test/SystemClockTest.php | 1 - 10 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/.gitattributes b/.gitattributes index f97b4b51..4722732a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ -/test export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore +/test export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore /.scrutinizer.yml export-ignore -/.travis.yml export-ignore -/README.md export-ignore -/phpunit.xml.dist export-ignore +/.travis.yml export-ignore +/README.md export-ignore +/*.xml.dist export-ignore diff --git a/.gitignore b/.gitignore index 4e7599cf..650dbf59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -vendor -phpunit.xml -composer.lock -humbuglog.txt -coverage +/vendor +/phpunit.xml +/phpcs.xml +/composer.lock +/.phpcs.cache diff --git a/.travis.yml b/.travis.yml index 4454679b..23d48e6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,3 +35,8 @@ jobs: after_script: - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover ./clover.xml + + - stage: Metrics and quality + env: CODE_STANDARD + script: + - ./vendor/bin/phpcs diff --git a/composer.json b/composer.json index af6fb774..2d685162 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "php": "^7.2" }, "require-dev": { + "lcobucci/coding-standard": "^1.0", "phpunit/phpunit": "^6.1" }, "autoload": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 00000000..5257bbf8 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,17 @@ + + + + + + + + + + + + src + test + diff --git a/src/Clock.php b/src/Clock.php index bd13fe60..f356776e 100644 --- a/src/Clock.php +++ b/src/Clock.php @@ -1,5 +1,4 @@ timezone = $timezone ?: new DateTimeZone(date_default_timezone_get()); } diff --git a/test/FrozenClockTest.php b/test/FrozenClockTest.php index 80be833d..6b85fbae 100644 --- a/test/FrozenClockTest.php +++ b/test/FrozenClockTest.php @@ -1,5 +1,4 @@ Date: Sun, 12 Aug 2018 18:23:17 +0200 Subject: [PATCH 4/7] fixup build stages --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 23d48e6d..08281e8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ before_install: install: travis_retry composer install script: - - ./vendor/bin/phpunit --testsuite=unit - ./vendor/bin/phpunit jobs: From 394d11a1c0e45f9576f21d65ffd077be490bf365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 12 Aug 2018 18:24:50 +0200 Subject: [PATCH 5/7] Upgrade PHPUnit to 7.3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2d685162..6e2a8d54 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ }, "require-dev": { "lcobucci/coding-standard": "^1.0", - "phpunit/phpunit": "^6.1" + "phpunit/phpunit": "^7.3" }, "autoload": { "psr-4": { From 94a155b70745ac013f1f056e7f98ca23d6cdf7af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 12 Aug 2018 18:32:37 +0200 Subject: [PATCH 6/7] Check for escaped/uncovered mutations --- .gitignore | 1 + .travis.yml | 8 ++++++++ composer.json | 1 + infection.json.dist | 11 +++++++++++ 4 files changed, 21 insertions(+) create mode 100644 infection.json.dist diff --git a/.gitignore b/.gitignore index 650dbf59..1e56cb64 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /phpcs.xml /composer.lock /.phpcs.cache +/infection-log.txt diff --git a/.travis.yml b/.travis.yml index 08281e8f..e4d5f1b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,3 +39,11 @@ jobs: env: CODE_STANDARD script: - ./vendor/bin/phpcs + + - stage: Metrics and quality + env: MUTATION + before_script: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,} + - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi + script: + - ./vendor/bin/infection -s --threads=4 --min-msi=100 --min-covered-msi=100 diff --git a/composer.json b/composer.json index 6e2a8d54..4dd3e6f4 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "php": "^7.2" }, "require-dev": { + "infection/infection": "^0.10", "lcobucci/coding-standard": "^1.0", "phpunit/phpunit": "^7.3" }, diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 00000000..a3a96f2a --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,11 @@ +{ + "timeout": 3, + "source": { + "directories": [ + "src" + ] + }, + "logs": { + "text": "infection-log.txt" + } +} \ No newline at end of file From 55930fef41e3522546a58f8f3a318fbe607c07ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 12 Aug 2018 18:39:20 +0200 Subject: [PATCH 7/7] Check code quality with PHPStan --- .gitignore | 1 + .travis.yml | 5 +++++ composer.json | 4 ++++ phpstan.neon.dist | 11 +++++++++++ 4 files changed, 21 insertions(+) create mode 100644 phpstan.neon.dist diff --git a/.gitignore b/.gitignore index 1e56cb64..ea7c474c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /composer.lock /.phpcs.cache /infection-log.txt +/phpstan.neon diff --git a/.travis.yml b/.travis.yml index e4d5f1b3..12ae7f13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,3 +47,8 @@ jobs: - if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi script: - ./vendor/bin/infection -s --threads=4 --min-msi=100 --min-covered-msi=100 + + - stage: Metrics and quality + env: STATIC_ANALYSIS + script: + - ./vendor/bin/phpstan analyse diff --git a/composer.json b/composer.json index 4dd3e6f4..a1c50e28 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,10 @@ "require-dev": { "infection/infection": "^0.10", "lcobucci/coding-standard": "^1.0", + "phpstan/phpstan": "^0.10", + "phpstan/phpstan-deprecation-rules": "^0.10", + "phpstan/phpstan-phpunit": "^0.10", + "phpstan/phpstan-strict-rules": "^0.10", "phpunit/phpunit": "^7.3" }, "autoload": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..52d355a4 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,11 @@ +includes: + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-phpunit/rules.neon + - vendor/phpstan/phpstan-strict-rules/rules.neon + - vendor/phpstan/phpstan-deprecation-rules/rules.neon + +parameters: + level: 7 + paths: + - src + - test