Skip to content

Commit

Permalink
Merge pull request #10 from lcobucci/improve-qa-checks
Browse files Browse the repository at this point in the history
Improve QA checks
  • Loading branch information
lcobucci committed Aug 12, 2018
2 parents d2013bc + 55930fe commit 13fda71
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 93 deletions.
12 changes: 6 additions & 6 deletions .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
12 changes: 7 additions & 5 deletions .gitignore
@@ -1,5 +1,7 @@
vendor
phpunit.xml
composer.lock
humbuglog.txt
coverage
/vendor
/phpunit.xml
/phpcs.xml
/composer.lock
/.phpcs.cache
/infection-log.txt
/phpstan.neon
99 changes: 35 additions & 64 deletions .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)'
48 changes: 40 additions & 8 deletions .travis.yml
@@ -1,22 +1,54 @@
dist: trusty
language: php
sudo: false

php:
- 7.1
- 7.2
- nightly

cache:
directories:
- $HOME/.composer/cache

before_script:
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; 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

jobs:
allow_failures:
- php: nightly

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

- stage: Metrics and quality
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

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
- stage: Metrics and quality
env: STATIC_ANALYSIS
script:
- ./vendor/bin/phpstan analyse
10 changes: 8 additions & 2 deletions composer.json
Expand Up @@ -10,10 +10,16 @@
}
],
"require": {
"php": "^7.1"
"php": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "^6.1"
"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": {
"psr-4": {
Expand Down
11 changes: 11 additions & 0 deletions infection.json.dist
@@ -0,0 +1,11 @@
{
"timeout": 3,
"source": {
"directories": [
"src"
]
},
"logs": {
"text": "infection-log.txt"
}
}
17 changes: 17 additions & 0 deletions phpcs.xml.dist
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>
<arg name="basepath" value="." />
<arg name="extensions" value="php" />
<arg name="parallel" value="80" />
<arg name="colors" />
<arg name="cache" value=".phpcs.cache" />
<arg value="p" />

<rule ref="Lcobucci"/>

<file>src</file>
<file>test</file>
</ruleset>
11 changes: 11 additions & 0 deletions 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
1 change: 0 additions & 1 deletion src/Clock.php
@@ -1,5 +1,4 @@
<?php

declare(strict_types=1);

namespace Lcobucci\Clock;
Expand Down
1 change: 0 additions & 1 deletion src/FrozenClock.php
@@ -1,5 +1,4 @@
<?php

declare(strict_types=1);

namespace Lcobucci\Clock;
Expand Down
4 changes: 2 additions & 2 deletions src/SystemClock.php
@@ -1,11 +1,11 @@
<?php

declare(strict_types=1);

namespace Lcobucci\Clock;

use DateTimeImmutable;
use DateTimeZone;
use function date_default_timezone_get;

final class SystemClock implements Clock
{
Expand All @@ -14,7 +14,7 @@ final class SystemClock implements Clock
*/
private $timezone;

public function __construct(DateTimeZone $timezone = null)
public function __construct(?DateTimeZone $timezone = null)
{
$this->timezone = $timezone ?: new DateTimeZone(date_default_timezone_get());
}
Expand Down
5 changes: 2 additions & 3 deletions test/FrozenClockTest.php
@@ -1,5 +1,4 @@
<?php

declare(strict_types=1);

namespace Lcobucci\Clock;
Expand All @@ -15,7 +14,7 @@ final class FrozenClockTest extends TestCase
* @covers \Lcobucci\Clock\FrozenClock::__construct
* @covers \Lcobucci\Clock\FrozenClock::now
*/
public function nowShouldReturnAlwaysTheSameObject()
public function nowShouldReturnAlwaysTheSameObject(): void
{
$now = new DateTimeImmutable();
$clock = new FrozenClock($now);
Expand All @@ -31,7 +30,7 @@ public function nowShouldReturnAlwaysTheSameObject()
* @uses \Lcobucci\Clock\FrozenClock::__construct()
* @uses \Lcobucci\Clock\FrozenClock::now
*/
public function nowSetChangesTheObject()
public function nowSetChangesTheObject(): void
{
$oldNow = new DateTimeImmutable();
$clock = new FrozenClock($oldNow);
Expand Down
1 change: 0 additions & 1 deletion test/SystemClockTest.php
@@ -1,5 +1,4 @@
<?php

declare(strict_types=1);

namespace Lcobucci\Clock;
Expand Down

0 comments on commit 13fda71

Please sign in to comment.