Skip to content

Commit

Permalink
update coding standard (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimmi20 authored Aug 1, 2021
1 parent 49413f7 commit 92044d4
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 30 deletions.
92 changes: 66 additions & 26 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: "composer-normalize --dry-run"

install:
name: "Check dependencies"
name: "Install dependencies"

needs: "validate"

Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Check dependencies with composer"
run: "composer outdated --direct --strict"
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run friendsofphp/php-cs-fixer"
run: "vendor/bin/php-cs-fixer fix --dry-run -vv"
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run squizlabs/php_codesniffer"
uses: "chekalsky/phpcs-action@v1.2.0"
Expand Down Expand Up @@ -257,11 +257,63 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run phpstan/phpstan"
run: "vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=768M --no-progress"

phpmd:
name: "Check Rules with PHPMD"

needs: "install"

runs-on: "${{ matrix.operating-system }}"

continue-on-error: false

strategy:
fail-fast: false

matrix:
operating-system:
- "ubuntu-20.04"

php-version:
- "7.4"

dependencies:
- ""

steps:
- name: "Checkout"
uses: "actions/checkout@v2.3.4"

- name: "Install PHP"
uses: "shivammathur/setup-php@2.12.0"
with:
php-version: "${{ matrix.php-version }}"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "${{ env.PHP_INI_VALUES }}"
coverage: "none"
tools: "composer:v2"

- name: "Determine composer cache directory"
id: "determine-composer-cache-directory"
run: "echo \"::set-output name=directory::$(composer config cache-dir)\""

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2.1.6"
with:
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run phpmd/phpmd"
run: "vendor/bin/phpmd src github phpmd.ruleset.xml"

tests:
name: "UnitTests with PHPUnit"

Expand All @@ -278,29 +330,17 @@ jobs:
operating-system:
- "ubuntu-18.04"
- "ubuntu-20.04"
- "windows-2019"
- "macos-10.15"

php-version:
- "7.4"
- "8.0"

dependencies:
- ""

continue-on-error:
- false

include:
- operating-system: "ubuntu-20.04"
php-version: "8.0"
continue-on-error: true
- operating-system: "windows-2019"
php-version: "8.0"
continue-on-error: true
- operating-system: "macos-10.15"
php-version: "8.0"
continue-on-error: true

steps:
- name: "Checkout"
uses: "actions/checkout@v2.3.4"
Expand All @@ -326,10 +366,10 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit -c phpunit.xml --colors --no-coverage"
run: "vendor/bin/phpunit -c phpunit.xml --verbose --no-coverage"

code-coverage:
name: "Code Coverage with PHPUnit"
Expand Down Expand Up @@ -367,7 +407,7 @@ jobs:
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "${{ env.PHP_INI_VALUES }}"
coverage: "${{ matrix.coverage-drivers }}"
tools: "composer:v2"
tools: "composer:v2, infection"

- name: "Determine composer cache directory"
id: "determine-composer-cache-directory"
Expand All @@ -381,20 +421,20 @@ jobs:
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Update dependencies with composer"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -vv --ansi ${{ matrix.dependencies }}"
run: "composer update --optimize-autoloader --prefer-dist --prefer-stable --no-progress --no-interaction -v --ansi ${{ matrix.dependencies }}"

- name: "Create cache directory for phpunit/phpunit"
run: "mkdir -p .build/coverage"

- name: "Collect code coverage with Xdebug and phpunit/phpunit"
run: "vendor/bin/phpunit -c phpunit.xml --colors --coverage-clover=.build/coverage/clover.xml --coverage-text --coverage-xml=.build/coverage/coverage-xml --log-junit=.build/coverage/phpunit.junit.xml"
run: "vendor/bin/phpunit -c phpunit.xml --verbose --coverage-clover=.build/coverage/clover.xml --coverage-text --coverage-xml=.build/coverage/coverage-xml --log-junit=.build/coverage/phpunit.junit.xml"

- name: "Upload coverage to Codecov"
uses: "codecov/codecov-action@v2.0.2"
with:
file: ".build/coverage/clover.xml"
flags: "phpunit,php-${{ matrix.php-version }},${{ matrix.coverage-drivers }}"
verbose: true
flags: "phpunit,php-${{ matrix.php-version }},${{ matrix.coverage-drivers }},${{ matrix.php-version }},${{ matrix.operating-system }}"
verbose: false

- name: "Run mutation tests with infection/infection"
run: "vendor/bin/infection --min-covered-msi=96 --min-msi=91 --git-diff-filter=AM --git-diff-base=origin/$GITHUB_BASE_REF --coverage=.build/coverage --logger-github"
run: "infection -s --min-covered-msi=96 --min-msi=91 --coverage=.build/coverage --logger-github"
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
"ext-mbstring": "*"
},
"require-dev": {
"infection/infection": "^0.23.0",
"mimmi20/coding-standard": "^2.2.3",
"mimmi20/coding-standard": "^2.3.0",
"pepakriz/phpstan-exception-rules": "^0.11.7",
"phpstan/extension-installer": "^1.1.0",
"phpstan/phpstan": "^0.12.93",
"phpstan/phpstan": "^0.12.94",
"phpstan/phpstan-deprecation-rules": "^0.12.6",
"phpstan/phpstan-phpunit": "^0.12.21",
"phpunit/phpunit": "^9.5.7"
"phpunit/phpunit": "^9.5.8"
},
"config": {
"preferred-install": "dist",
Expand Down
25 changes: 25 additions & 0 deletions phpmd.ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<ruleset name="mimmi20-cs"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>The coding standard.</description>

<rule ref="rulesets/cleancode.xml">
<exclude name="BooleanArgumentFlag"/>
<exclude name="ElseExpression"/>
<exclude name="MissingImport"/>
<exclude name="StaticAccess"/>
</rule>

<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/controversial.xml"/>
<rule ref="rulesets/design.xml"/>

<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>

<rule ref="rulesets/unusedcode.xml">
<exclude name="UnusedFormalParameter"/>
</rule>
</ruleset>
6 changes: 6 additions & 0 deletions src/IosData.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,5 +588,11 @@ final class IosData
'18G5023c' => '14.7b1',
'18G5033e' => '14.7b2',
'18G5042c' => '14.7b3',
'18G5052d' => '14.7b4',
'18G5063a' => '14.7b5',
'18G68' => '14.7rc',

'18G69' => '14.7',
'18G82' => '14.7.1',
];
}

0 comments on commit 92044d4

Please sign in to comment.